Download On the multiplication of two multi-digit numbers using

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Functional decomposition wikipedia , lookup

Ambiguity wikipedia , lookup

History of mathematics wikipedia , lookup

List of first-order theories wikipedia , lookup

Large numbers wikipedia , lookup

Mechanical calculator wikipedia , lookup

Bra–ket notation wikipedia , lookup

Horner's method wikipedia , lookup

Surreal number wikipedia , lookup

Elementary mathematics wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Factorization wikipedia , lookup

History of logarithms wikipedia , lookup

Peano axioms wikipedia , lookup

Classical Hamiltonian quaternions wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Location arithmetic wikipedia , lookup

Algebra wikipedia , lookup

Elementary arithmetic wikipedia , lookup

Addition wikipedia , lookup

Arithmetic wikipedia , lookup

Transcript
On the multiplication of two multi-digit numbers using Bino’s Model of
Multiplication.
YUMNAM KIRANI SINGH & SWAPAN KUMAR PARUI
Computer Vision &Pattern Recognition Unit
Indian Statistical Institute
203, B.T. Road, Cal-35.
COUNTRY: INDIA
[email protected] http://home.123india.com/yumnam_kirani/level_2.html
Abstract: The complexity of multiplication of any two multi-digit numbers depends on the types of the
numbers to be multiplied. If one or both of the numbers is/are made up of same digit, then the multiplication
can be done in linear time. Or if one of the number is the reverse of the other or both the numbers are the same,
then the computational steps can be doubly reduced as compared with the conventional methods. Also the
result of multiplication of the reverse numbers can found out without any cost of complexity. All this can be
visualized clearly using a new model of multiplication entitled as Bino’s Model of Multiplication. The model
also shows us that number multiplication, polynomial multiplication and vector multiplication or discrete
convolution are the same and one process. One can be obtained from the other. It is recursive process and can
be easily generalized for multiplication of three or more multi-digit numbers at a time.
Keywords: Complexity of Multiplication, Fast convolution, Polynomial Multiplication, Number multiplication,
Bino's Model of multiplication, Multiplication terms.
1 Introduction
Everyone knows multiplication.
In conventional
method, generally n2 multiplication steps are
required for multiplying two n-digit numbers. The
number of multiplication operations required can be
reduced much less than the n2 under different
conditions e,g, if the two numbers are the same, then
multiplication can be done in less steps than the
conventional methods of multiplication. Karatsuba
and offman(1962) proposed an algorithm to reduce
the number of multiplication operations less than
the conventional method. But their algorithm
requires tremendous number of addition operations
in exchange for some reduction in multiplication
operations and is not generalizable.
The conventional way of multiplication enable us
to multiply two numbers at a time. We cannot
multiply three or more different numbers at a time.
Also we treat polynomial and integer multiplication
differently and the way of multiplication is not
generalizable. Bino's Model of multiplication takes
care of all such inconvenience and opens a new
chapter in multiplication. The model can lead us to a
general formula for multiplying many different
multi-digit numbers at a time. Also this model
enables us to show that polynomial multiplication
and integer multiplication can be performed in the
same way. But we will discuss here only for the
multiplication of two numbers.
In Bino’s Model of multiplication we will use a
different way of variable representation for numbers.
Here instead of representing any multi-digit number
by a variable, we will represent a multi-digit number
by a multi-variable combination. For simplicity, we
will represent each digit in the number by a variable
i.e., a 3-digit number will be represented by a 3variable combination so that each variable has the
corresponding place value of the digit being
represented by it in a particular number system. Also
we define level of multiplication. If two numbers are
multiplied, we call it level two multiplication; three
numbers multiplication is called level three
multiplication and so on.
We organize the rest of the paper into four
sections. Section 2 introduces briefly about the
Bino’s Model of Multiplication. Section 2.1 gives
formulations for multiplication of two numbers
under different conditions. An elaborate discussion
is given in section 3. And Conclusion is given in
section
2.Bino's Model of Multiplication.
Multiplication we usually do can be drawn
diagrammatically . The model, which shows the way
of multiplication, is entitled as Bino's Model of
Multiplication (I,Y.K.Singh, gave the name after my
late father Yumnam Bino Singh). The diagram is
drawn according to some rules. These rules are the
torch to go ahead in some of the dark alleys of
mathematics.
Rule 1: When two digits/elements are multiplied,
a straight line called multiplication line will connect
them.
Rule 2: The result of multiplication, I call
multiplication term, comes from the middle of the
multiplication line.
Rule 3: If two or more multiplication lines bisect
each other /one another the multiplication term
comes from the point of bisection and the result of
each multiplication line should be summed up.
Rule 4: Each multiplication term is connected to
the middle of each multiplication line by a dotted
line known as result line.
Rule 5: If each element in each number has place
value, then each multiplication term has
corresponding place value, otherwise not.
Following the above rules, the model is shown in
Figure1.
1
5
T1  a11 2 T1  a12
T2
a 21
a 22
4
3
T2
T2
3
T1  a13
a 23
2
T2
1
T2
Figure-1: 3-digit level-2 Bino’s
Model of Multiplication.
This model is for the multiplication of two 3-digit
numbers or sequences of length 3. Here the empty
circles represent digits (for simplicity) or elements to
be multiplied. The filled circles are the
multiplication terms, which will gives the result of
the operation. The multiplication terms are the same
for any operation performed following this model.
The multiplication terms are written as capital T
with upper right superscript and lower left subscript.
The lower left subscript denote the level of
multiplication and the upper right superscript denote
the term number in a particular level of
multiplication. For example, 3T2 denotes the third
multiplication term in the level-2 multiplication. For
simplicity of representation and interpretation each
element is considered representing a digit for
number multiplication. But it is not essential; we
may represent an element for a two or more digit. In
that case, care must be taken to correctly assign the
place value to each variable used in representing the
number. For polynomial multiplication or
convolution, each element represents an element in
the polynomials or the sequences to be multiplied or
convolved.
Let a11 a12 a13 and a 21 a 22 a 23 be the two 3digit numbers to be multiplied. There are five
multiplication terms in the model. The first
multiplication term has the place value of 1, the
second multiplication term has the place value of 10,
the third multiplication term has the place value of
(10)2 and so on. The respective level 2 multiplication
terms as determined by the model are
1
T2  a 23 .a13
2
T2  a 23 .a12  a 22 .a13
3
T2  a 23 .a11  a 22 .a12  a 21 .a13
4
T2  a 22 .a11  a 21 .a12
5
T2  a 21 .a11
The first and the last terms involve no addition
because they are multiplication terms from nonbisecting multiplication lines. The second and the
fourth multiplication terms involve a plus sign
because two multiplication lines bisects each other
and the corresponding multiplication terms come
from the respective points of bisection which is
indicated by a plus sign in the model. And the third
multiplication term involves two plus signs because
three multiplication lines bisect each other and the
corresponding multiplication term comes from the
point of bisection of the three multiplication lines.
The result of the above level-2 multiplication, can be
written mathematically as
5
R 2   (10) r 1 . r T2 ,
r 1
number has place value.
if each element in the
Manually it can be done shortly and easily in two
ways: Forward slant addition and Backward slant
addition of multiplication terms. These two are the
shortest and convenient way of obtaining result of
multiplication from the corresponding multiplication
terms.
In Forward slant addition of multiplication terms,
the multiplication terms are written vertically, as if
we will do conventional addition of multiplication
terms. Dotted slant lines are drawn starting from the
top rightmost element. Those elements/values
crossed by a slant line will be added together.
For clarity, let 1T2=x11 x 12 x 13; 2T2= x21 x 22 x 23;
3
T2= x31 x 32 x 33 x34;
4
T2=x41 x42; 5T2=x51 x52 x53 x54; 6T2=x61 x62 x63 ;
7
T2=x71 .
Then, the Forward slant addition is shown as shown
in figure-2:
1
T3=
T3=
3
T3=
4
T3=
5
T3=
6
T3=
7
T3=
2
x11 x12 x13
x21 x22 x23
x31 x32 x33 x34
x41 x42
x51 x52 x53 x54
x61 x62 x63
x71
First forward slant line
1
2nd forward slant line
Last forward slant line
Figure-2: Forward Slant Addition
Last backward slant line
1
T3=
T3=
3
T3=
4
T3=
5
T3=
6
T3=
7
T3=
2
x31
x51
x11 x12
x21 x22
x32 x33
x41
x52 x53
x61 x62
Forward slant addition gives the result of the direct
multiplication. Whereas Backward slant addition
gives the result of multiplication of the reversed
numbers, from the values of the multiplication terms
of the direct multiplication. For example, 235 and
641 are to be multiplied. If multiplication terms for
this level-2 multiplication are known. then by doing
Forward slant addition of the multiplication terms
we get the result of multiplication of 235 and 641.
And by doing backward slant addition of the same
multiplication terms
we get the result of
multiplication of the reversed numbers i.e., 532 and
146.
Using the multiplication terms of level-2
multiplication of three digit numbers derived earlier,
we get the corresponding multiplication terms of
multiplication of 235 and 641
x13
x23
x34
x42
x54
x63
x71
First backward slant line
Figure-3: Backward Slant Addition
Backward slant lines are also drawn similarly as
shown in the figure-3 above. The value crossed by
the first slant line corresponds to the first value of
the result i.e., the value of the result of
multiplication in the unit's place. Addition is done
for each remaining slant line to get the result.
T2=
T2=
3
T2=
4
T2=
5
T2=
2
2
4
2
1
5
3
4
6
2
77672
1
T2=
T2=
3
T2=
4
T2=
5
T2=
2
2
4
2
1
5
3
4
6
2
110
1
T2 =
T2=
3
T2=
4
T2=
5
T2=
2
5
2 3
4 4
2 6
1 2
150635
Writing the multiplication terms in the top down
fashion i.e., writing the last multiplication term first
and the first multiplication term last and doing
forward slant addition, is the same as backward slant
addition. Similarly, doing backward slant addition in
the top down written multiplication term is the same
as doing the forward slant addition.
If each element in the number were in the vector
form or a set e.g., a=[2 3 5] and
b=[6 4 1], then axb=[12 26 44 23 5] i.e., putting
simply the multiplication terms as a vector. This is
what is generally called convolution.
Thus, we see that, by simply finding multiplication
terms once we can find out the result of
multiplication of the reverse numbers, convolution
and the result of polynomial multiplication.
2.1 Level-2 Multiplication:
Any number can be thought as the level-1
multiplication. Multiplication of two numbers is
called level-2 multiplication. The level number can
also be thought to be the power of the number when
the numbers are equal.
For the simplicity of derivation and manipulation we
will assume that each variable represent a digit in a
number.
Let a11 a12  a1k 1 and a 21 a 22  a 2 k 2 be
any two numbers having length k1 and k2
respectively. Then, according to Bino’s Model of
multiplication
( a11 a12  a1k 1 ) ( a 21 a 22  a 2 k 2 )
is given by
L
R2   (10)
r 1 r
r 1
T2
.........................(1)
where L=(k1 + k2) – 1 is the total number of
multiplication terms in level-2 multiplication of two
numbers of length k1 and k2.
Assuming k2<k1, each multiplication term is given
by
r
k2
T2   a 2( k 21i ) .
r 1i
i 1
where
r
being
a1 j
a2 j
T1 ...................(2)
beginning from the right (
a1k1 ), subject to the conditions
 0 for j0 jk1
 0 for j0 jk2
Condition
1
T1
(A)
k2
T2   a 2( k 2 1i ) .a1( k 11i )
....................(3)
i 1
T2   a 2( k 2 1i ) .a1( k 11i )
if r<k2
i 1
k2
  a 2( k 2 1i ) .a1( k 11i )
if r  k2  L-r
i 1
...........................(4)
Lr
  a 2( k 21i ) .a1( k 11i )
if k2>L-r
i 1
Equation (4) can be conveniently used for
multiplication of any two multi-digit numbers
manually and computationally.
For the multiplication of two polynomials, i.e.,
( a11  a12    a1k 1 )
( a 21  a 22    a 2 k 2 )
The multiplication terms are the same as given by
r
T2 . But their result
R p 2   r T2 ............(5)
r 1
If the numbers were vectors,
i.e.,[ a11
, a12 , a13 , , a1k1 ]
[ a 21 , a 22 , a 23 ,  , a 2 k 2 ], then it is known as
convolution operation and their result is given by
simply placing the multiplication terms in vector
form. Let Rc2 be the result of convolution of two
sequences or vectors. Then
Rc 2  [ L T2 , L 1 T2 ,  , r T2 ,  , 2 T2 ,1 T2 ] .
..............(6)
Subject to the above condition (A).
Equation (3) requires k2 multiplication operations
and k2-1 additions for each multiplication term. But
r
for any multiplication term T2 , when r is less than
k2, we can find the multiplication term with less
multiplication operations than k2. When r  k2  L-r
r
then estimation of T2 requires k2 multiplication
operations. And again when L-r < k2 for any value of
r
r
L
Equation (2) can also be written as
r
r
any of the above formula for
Rp2 is given by
T1 is the rth element of the multiplicand (i.e.,
a11 a12  a1k 1 )
So equation (3) can be written in the following way
r then T2 reqiures less multiplication operations
than k2. In all the above equation the upper limit of
the summation is the minimum of the two lengths of
the number. As we assumed k2< k1, the upper limit
is made k2.
r
Here, again T2 is given by any of the equations
for multiplication term given above.
From the above results, R2, Rp2 and Rc2, we know
that what is required is the multiplication terms. If
once the multiplication terms we can find one from
the other by simply manipulating the terms in
different ways. So we can say that these three
number multiplication, polynomial multiplication
and convolution are the same operations.
We will now consider some interesting conditions,
which will be useful for performing multiplication
quickly easily and in short.
Condition 1: If
a 2 j ’s
a 21  a 22    a 2k 2  (a 2 , say ) ,
r
T2  a 2 . a1( k 11i )
for r < k2
i 1
k2
 a 2 . a1( k 11i ) for r  k2  L-r .............(7)
i 1
Lr
 a 2 .  a1( k 11i )
for k2 >L-r
and
a 2 j ’s
are the same,
i.e., if the two sequences or the numbers are made up
of the same digit say a , then the multiplication
terms becomes
r
T2  a 2 .r
 a 2 .k 2
 Lr T2
for r<k2
for r  k2  L-r
.................(8)
for k2>L-r
Under this condition we require to calculate only
the first k2 multiplication terms involving one
multiplication, others multiplication terms are
simply obtained from them. So the total number of
multiplication operations required under this
condition is only k2.
Condition 3: If k1 =k2 (=k, say) in condition (2),
then
r
T2  a 2 .r

2k r
T2
.................(9)
Here also, we need to calculate only k multiplication
terms each of which requires only one
multiplication.
Condition 5:
If
r
a11  a 21 ( a1 ), a12  a 22 ( a 2 ), ,
a1k1  a 2 k 2 ( a k )
i 1
r 1
r
where
T2 is given by either of equation (10)
Condition 4: If a1 a 2  a k and a k a k 1  a1
be the two numbers to be multiplied, then the
multiplication term is given by
r
r
T2   ai .a k  r i

i 1
2 k r
if r  k ..............(12)
T2
if r > k
Here we need to calculate only first k multiplication
terms each requiring r multiplication and r-1
addition operations.
2.2 Further reduction in multiplication
operations:
If the multiplication is to be done manually, then the
above given formula for multiplication terms are
better. If the multiplication is to be done by
computer, then we can further reduce the number of
multiplication operation at the expense of increase in
addition operations.
We know multiplication terms of
a12 a13 a1k1 )
( a21 a22 a23 a2k 2 ) and
( a11  a12  a13    a1k1 )
( a21  a22  a23    a2k 2 ) are the same.
, then
And
 a12  a13    a1k1 )
( a21  a22  a23    a2k 2 )
( a11
L
t
T2  2. a ( k 1i ) .a ( k 1i )
  r T2 ...............(11)
( a11
for r  k
for r  k
i 1
................ (10)
where t=r/2 if r  k
=k-r/2 if r > k
It indicates that the addition and multiplication
operation is reduced approximately to half.
Now we can write square of polynomial of length k
as follows
L
Here each multiplication term requires only one
multiplication operation. So, for multiplying two
sequence or numbers having lengths k1 and k2 , only
(k1+k2-1) multiplication need be performed which
would otherwise require (k1k2) multiplication
operations. Also there is no apparent increase in the
number of addition operations.
a1 j ’s
.if r is odd
(a1  a2    ak ) 2
i 1
Condition 2: If
 2. a( k 1i ) .a( k 1i )  a k2t
then
from equation (4), we have
r
t
are the same, i.e.,
if r is even
  r T2
r 1
where L=k1+k2-1
If k2<k1, there can’t be more multiplication
operations than k2 for any multiplication term. Also
k2
we can find
T2 from the other remaining
multiplication terms without doing k2 multiplication
operations in the following way.
k2
T2 =( a11  a12    a1k1 )
L
( a 21
 a22    a2k 2 )   r T2 for rk2
r 1
..........................(13)
From the equation (13), we know that for finding
k2
T2
we require only one multiplication operation
and others are addition of the remaining
multiplication terms.
This concept can be applied in all cases of
multiplying two multi-digit numbers except in the
case where the one or both of the numbers are
composed of the same digit to further reduce the
number of multiplication operations.
So, the kth multiplication term in equation (11) can
be found out in the following way
k
2 k 1
T2  (a1  a 2    a k ) 2   r T2
i 1
for rk .........(14)
For finding the
k
T2
of equation (11) and (12),
r
respective values of T2 should be replaced in
equation (14). Using equation (14) , the number of
multiplication
operations
in
calculating
multiplication terms using equation (11) and (4) is
further reduced by k-1 multiplication operations at
the expense of 2k addition operations.
3 Discussion
We have seen a number of formula which will
reduce the number of multiplication operations in
many different conditions i.e., when the two
numbers each of length k, are the same or one of
the numbers is made of same digit or the two
numbers are equal and all digits in the numbers are
same, and so on. These can also be done easily
manually in shorter time than the conventional
methods of multiplication. Karatsuba and Offman
algorithm for multiplication increases the number of
addition operations tremendously if the numbers are
large. So their algorithm cannot be performed
manually in shorter time than the conventional
method of multiplication. Also it weren't possible in
their case to generalize the multiplication operation.
Their algorithm also didn't consider the possibilities
of reducing the number of multiplication operations
in the cases stated above.
Also the above formula can be used for the
multiplication of two polynomials or sequences.
Hence this can be used for convolving two
sequences. So convolution, polynomial
multiplication and number multiplication are the
same process. For convolving two sequences, fast
convolution algorithm exists. Fast convolution
algorithm is useful for convolving sequences of
length greater than 128. If the length is less than
128, then the our algorithm is much better.
4 Conclusion
Bino’s model of multiplication for multiplying two
multi-digit numbers is much better than the other
existing multiplication algorithms. It is faster and
easier to perform manually as well as
computationally. It can be used for polynomial
multiplication and discrete non-cyclic convolution.
The model can be extended for multiplication
formulas of multi-level multiplication of multi-digit
numbers. It can be used for solving simple linear or
higher order equations, polynomial division, etc. As
the model can represent convolution and polynomial
multiplication, which is closely related to Ztransform, it will have greater role in signal
processing especially for digital filter design.
References:
1. Karatsuba, A. and Ofman, Yu. "Multiplication
of Many-Digital Numbers by Automatic "
Doklady Akad. Nauk SSSR 145, 293-294, 1962.
Translation in Physics-Doklady 7, 595-596,
1963.
2. Gathen Jaochim VonZur, Gerhard Jergen,
Modern Computer Algebra, CUP-1999
3. Zuras, D. "More on Squaring and Multiplying
Large Integers." IEEE Trans. Comput. 43, 899908, 1994.
4. James H. McClellan, CharlesM. Rader, Number
Theory in Digital signal Processing, PrenticeHall, 1979.
5. S.K. Mitra, James F. Kaiser, Handbook for
Digital Signal Processing, Wesley Interscience,
1993.