multiplication of two numbers
x*y ----> x =(x0*10^(n/3)+x1*10^(n/3)+x2) and y=(y0*10^(n/3)+y1*10^(n/3)+y2)
It is 9 multiplication of 10^n/3 numbers so 9T(n/3) but it can be reduced to 5 by the following method.
x*y= x0*y0+x1*y1+x2*y2+x0*y1+x0*y2+x1*y0+x1*y3+x2*y0+x2*y1
I am able to reduce the multiplication of two numbers to 5T(n/3) by similar trick like Karatsuba's algorithm
(x0+x1+x2)(y0+y1+y2)-x0*y0-x1*y1-x2*y2= x0*y1+x0*y2+x1*y0+x1*y3+x2*y0+x2*y1
All and all 5 multiplication of n/3 bits number so 5T(n/3)+O(n)
but how can I do in 6 multiplication like 6T(n/3)+O(n)
Q1 Can it be reduced to 6 instead of 5 ?
[edit1] correction copied from the reasked question by Spektre
x and y has n bits
x=x0*(10^2n/3)+x1*10^n/3+x2
y=y0*(10^2n/3)+y1*10^n/3+y2
x*y=x2y2+(x2y1+x1y2)10^n/3+(x2y0+x1y1+x0y2)10^2n/3+(x1y0+x0y1)10^n+x0y0*10^4n/3
- now 9 multiplication of n/3 bit numbers running time 9T(n/3) which is O(n^2)
with little trick like Karatsuba's multiplication:
- first calculate x0y0, x1y1 and x2y2 this is 3 multiplication of n/3 bit numbers
- then use x0y0, x1y1 and x2y2 to calculate the others follow:
x2y1+x1y2=(x1+x2)(y1+y2)-x1y1-x2y2
->> 1 multiplication of n/3 bit numberx2y1+x1y1+x0y2=(x0+x2)(y0+y2)-x0y0-x2y2+x1y1
->> 1 multiplication of n/3 bit numberx1y0+x0y1=(x0+x1)(y0+y1)-x0y0-x1y1
->> 1 multiplication of n/3 bit number
Recursively solve the 6 subproblems
- and combine them with 7 additions on O(n)-digit numbers.
- total it takes now 6 multiplication of n/3 bit numbers running time 6T(n/3)
Q2 how can I reduce this to 5 multiplication instead of 6 ?
- Q1 is now obsolete due to mistake in OP