Algebra of Concatenation cat() and multiplication & square of big numbers

  
  Concatenation is a famous activity in computer programming and there are notation for this action as a function or a method like concat() in Excel or cat() in UNIX operating systems. Concatenation means link together in a series or chain. In Excel, the notation "&" is also used representing the operation of concatenation. Example is like "use"&"ful" will yield result "useful". The same result can be achieved by concat("use","ful"). For shortening the notation, we can use cat() in place of concat() for our discussion here.

 Now let us take subject of multiplication, where if two numbers are multiplied, how quickly, we get the result if we resort to concatenation process.

 Any number written in decimal system, say 25, is concatenation of certain unit digits. For 25, it is concatenation of 2 and 5. So concat(2,5) will give 25 or "2"&"5" will yield to 25.

A two digit number having digits tens place "a" and unit place "b" mathematically is represented as 10a+b, while in cat() format, it is cat(a,b) or "a"&"b". Thus 25= 2*10+5.

 Representational number 25 in decimal system, is algebraically 2*10+5, is in concatenation form as cat(2,5) or operand forms as 2&5. For our convenience, let us write 2a for 2*a, but "ab" is not for a*b rather, it is for 10a+b or it is for a&b. Thus 2a, where 2 is a represented numeral, will not be considered as "2"&"a". Let us assume this for our discussion of algebra of concatenation. 

 Now take two numbers both two digited, first one is "ab", another be "cd". Then ab = 10a+b
cd = 10c+d, multiplying them we get 
(ab)*(cd) 
=(10a+b)*(10c+d)
=(100a*c+10(a*d+b*c)+b*d)
= cat(a*c, ((a*d+b*c),\n), (b*d,\n))
Or further shorter notation like
= cat(a*c, (a*d+b*c)\n, b*d\n)
Where (x,\n) or x\n is a format function on "x" and keeps the result of "x" only upto one digit becaise of single n in \n and the rest of digits, if any, will shift to left for addition to the number availabe in left of this number. If it is \nn, then it will keep two digits and will shift extra digits, if any, to left for addition. Moreover in case of format function \nn, if the number of digits are less than two, then it will concatenate by as many no of zeroes to the left of it, as it is short of. 

Example to clarify this operation of format function we see that 
(3+6)\nn = 09, (9+9)\nn =18
(3+6)\nnn = 009, (9+9)\nnn = 018
(3*6)\nnn = 018, (9*9)\nnn = 081
(3+6)\n = 9, (9+9)\n =1\8
(3*6)\nn = 18, (9*9)\nn = 81
(3*6)\n = 1\8, (9*9)\n =8\1

The a\b means "b" is kept at that position, where it occurred and carry "a" has been given to further left place to get it added over there, which is next left to the position of b.

Thus,
(ab)*(cd) 
= cat(a*c, (a*d+b*c)\n, b*d\n)
= cat( product of Tens, sumproduct of Tens with Units\n, product of Units\n)

 Thus, let ab=43, "a" is 4 and "b" is 3. Similarly cd=65, then 43*65 will be 
43*65 =
= cat(24, (20+18)\n, 15\n)
= cat(24, 38\n, 1\5)
= cat(24, (38+1)\n, 5)
= cat(24, 39\n, 5)
= cat(24, 3\9, 5)
= cat(24+3,9,5)
= cat(27, 9,5)
=2795
This method we usually use. 
However, it also gives a short cut method for multiplication of two numbers of two digits each or those that can be made into two sections
a&b * c&d = cat( a*c, (a*d+b*c)\n, b*d\n)

Ex1.1) 48 * 64 =
= cat(24, (16+48)\n, 32\n)
= cat(24, 64\n, 3\2)
= cat(24, (64+3)\n, 2)
= cat(24,6\7,2) = cat (30,7,2)
= 3072
Ex1.2) 47 * 98 =
= cat(36, (32+63)\n, 56\n)
= cat(36,(32+63+5)\n,6)
= cat(36+10,0,6)=4606

Concatenation in any arbitrary way will not work !!!
Ex1.3) 207 * 108 =
=2&07 * 10&8 // we divided into two sections//
= cat(2*10, (16+70)\n, 56\n)
= cat(20,(16+70+5)\n,6)
=cat(20,9\1,6) = cat(29,1,6)
= 2916 ??? We do not get proper result 22356, while if we do two sections like the following 
207 * 108 =
=20&7 * 10&8 // we divided two sections keeping unit place as one section//
= cat(20*10, (160+70)\n, 56\n)
= cat(200,(160+70+5)\n,6)
=cat(200, 235\n,6) 
= cat(200,23\5,6)
= cat(223,5,6)
= 22356, and this is the correct answer.

Case: when unit place digit is 5.
If unit digit is 5 then
(a&5)*(c&5) 
= cat(a*c, 5*(a+c)\n, 25\n)
= cat(a*c, (5*(a+c)+2)\n,5)
= cat(a*c, (((a+c)*10+4)/2)\n, 5)
= cat (a*c, (cat(a+c, 4)/2)\n,5)
= cat (a*c, (((a+c)&4)/2)\n,5)
(a&5)*(c&5) 
= cat (a*c, (((a+c)&4)/2)\n, 5)

Ex2.1) 205*25 =20&5 * 2&5
= cat(40, ((20+2)&4/2)\n,5)
= cat(40,(224/2)\n,5)
= cat(40,(112)\n,5)
= cat(40,11\2,5)
= cat(40+11,2,5)
= 5125
Ex2.2) 315*305 = 31&5 * 30&5
= cat(31*30, (614/2)\n, 5)
= cat(930,307\n,5)
= cat(930+30,7,5) 
= 96075

Case : If only one number has unit digit is 5 then
(a&b)*(c&5) , where a,b,c,d are digits
= (10a+b)*(10c+5)
= (100a*c+50a+10b*c+5b)
= cat(a*c, (5a+b*c)\n,5b\n);
Which is basically the same formulae that is given for general a&b*c&d

Let us take example
Ex3.1) To find 315*98, we have 
315*98 = 31&5 * 9&8
= 9&8 * 31&5
= cat(31*9, (5*9+8*31)\n,40\n)
= cat(279,(45+248)\n,4\0)
= cat(279,(45+248+4)\n,0)
= cat(279,(297\n),0)
= cat(279+29,7,0)
= cat(308,7,0)
= 30870

Case: To find square 
We have,
(ab)*(cd) 
= cat(a*c, (a*d+b*c)\n, b*d\n)
= cat( product of Tens, sumproduct of Tens with Units\n, product of Units\n)
Now substituting cd as ab, we get
ab^2 = (ab)*(ab) 
= cat(a*a, (a*b+b*a)\n, b*b\n)
= cat(a^2, 2a*b\n, b^2\n)
Ex 4.1) 45^2 = cat(4^2, 40\n, 25\n)
= cat(16,40\n, 2\5)
= cat(16,(40+2)\n, 5)
= cat(16,4\2,5)
= cat(16+4,2,5)
= cat(20,2,5)
= 2025
Ex 4.2) 63^2 
= cat(6*6,2(6*3)\n,3*3\n)
= cat(36,36\n, 9\n)
= cat(39,6,9) = 3969
Ex 4.3) 78^2 = cat(49,2(56)\n,64\n)
= cat(49,112\n,64\n)
= cat(49,(112+6)\n,4)
= cat(49+11,8,4)
= 6084
Case: To find square by another form 
(a&b)^2 = (10a+b)^2
= 100a^2+b^2+10*2a*b
= 100a^2+b^2+ 2ab&0
= (100a^2+b^2) + 2ab&0
= cat(a^2, b^2\nn) + 2ab&0, thus
(a&b)^2 = cat(a^2, b^2\nn) + 2ab&0
Ex 4.1.1) 45^2 
= cat(16, 25\nn)+2*4*5&0
= 1625+400
= 2025
Ex 4.2.1) 63^2 =
= cat( 36, 9\nn)+6*3*2&0
= 3609 + 360
= 3969
Ex 4.3.1) 78^2 =
= cat(49,64\nn) + 7*8*2&0
= 4964 + 1120
= 6084
Case: To find square in the vicinity of a base:
 Another inkling that surfaces here, is that the expression for given base B for a that is a= B+d, we have
a^2 = (B+d)^2
= B^2 + d^2 + 2B*d
= B*(B+2d)+d^2
= B*(B+2d)*100/100 + d^2
= cat((B+2d)*B/100,d^2\nn) [ This is algebra of Concatenation cat(), when 100 can be extracted from first term, needs to be further developed ]
(B+d)^2 = cat((B+2d)*B/100,d^2\nn)
Ex 5.1) 70003^2 = (70000+3)^2
= cat (70000+2*3)*70000/100, 3^2\nn)
= cat (70000+6)*700, 3^2\nn)
= cat ( 70006*700,09)
= cat ( 49004200,09)
= 4900420009
Ex 5.2) 508^2 = (500+8)^2
= cat( 500*(500+2*8)/100, 8^2\nn)
= cat (5*(516),64)
= cat(2580,64)
= 258064
Ex 5.3) 17^2 =(10+7)^2
= 10*(10+2*7)+7^2
= cat (10*(10+2*7)/10, 7^2\n) [ This is algebra of cat(), when 10 can be extracted from first term.]
= cat(24,49\n)
= cat (24+4,9)
= 289
In the first example, 70003^2, even 10^4 can be extracted from first term, so can this formulae be generalised as 
(B+d)^2 
= cat((B+2d)*B/10000,d^2\nnnn) ; because B/10000 is possible for getting whole digit integer.
Let us see
Ex 5.1.1) 70003^2 = (70000+3)^2
= (70000+2*3)*70000+9
= cat((70000+6)*70000/10000, 9\nnnn)
= cat(70006*7, 9\nnnn)
= cat(490042,9\nnnn)
= cat(490042,0009)
= 4900420009
Thus, we can represent the formulae in general format like 
(B+d)^2 
= cat((B+2d)*B/10^m,d^2\n^m) ;
Where base B has 10^m digits available in form of 10s, and n^m means n is repeated m times in format specification.

Case: To find square near to a base:
Now we can see the case, when number is near to a base. Like in 70076, the 70076^2 can be represented as (70000+76)^2, which gives B= 70000 and d =76. Thus, let us take the following example:
Ex 6.1) 70076^2 
= (70000+2*76)*70000 + 76^2
= cat((70000+2*76)*7,76^2\nnnn) ..Eq. 6.1.1
Now 76^2 can be evaluated as (70+6)^2, where base is 70 and d is 6, so as to give :
76^2= cat ((70+2*6)*70/10, 6^2\n)
= cat(82*7,36\n)
= cat (574,3\6)
= cat ( 574+3,6) = 5776. ..... Eq. 6.1.2
Substituting Eq 6.1.2 in Eq 6.1.1, we get 
70076^2 
= cat((70000+152)*7,5776\nnnn)
= cat((70152)*7,5776)
= cat((491064),5776)
= 4910645776
This way recursively the square formulae can be applied to get square of a number which is near to a base, but not it being in the vicinity of it. 

Ex 6.2) 8123^2
= cat((8000+123*2)*8000/1000, 123^2\nnn)
= 8246*8&(123^2\nnn) 
= 65968&(123^2\nnn) Eq... 6.2.1
Now find 123^2\nnn, we go by first formula 
(a&b)^2 = cat(a^2, b^2\nn) + 2a*b&0
So 123^2 = (12&3)^2
= cat (144,9\nn)+cat(2*12*3,0)
= cat (144,09)+cat(72,0)
= 14409+720 = 15129 Eq... 6.2.2
So by Eq 6.1.1, 6.1.2 we get 
8123^2 = 65968&(15129\nnn)
= (65968+15)&129
= 65983129

Thus, we had seen there is an algebra of Concatenation (cat()), that can be developed around multiplication and square of big numbers. It will still be challenging to develop such algebra for binary and hexadecimal system and then to find a generalization across all number systems. 

Popular posts from this blog

हजरत मुहम्मद

दीपावली में तीनों युगों का समावेश !

Navratri (नवरात्रि), Dussehra (दशहरा)