Answer the question
In order to leave comments, you need to log in
Who can explain the Karatsuba Multiplication Algorithm?
Hello, tell me please.
I'm analyzing the Karatsuba multiplication algorithm and ran into a problem that I can't understand how step5 works correctly .
That is, we took step1 and added four zeros to it, why?
Because we have four digits in step2 ?
Why did we add two zeros in step4 ?
Please explain "on your fingers" how to work with this formula correctly and how to get step5 correctly , or rather, how and where these zeros come from.
Thanks for your help and your time.
Answer the question
In order to leave comments, you need to log in
ab × cd
According to the formula we get:
(a × c) × 1000 + b × d + ( (a + b) × (c + d) - a × c - b × d ) × 100 =
= 1000 × a × c + b × d + ( a × c + a × d + b × c + b × d - a × c - b × d ) × 100 =
= 1000 × a × c + b × d + ( a × d + b × c ) × 100 =
= 1000 × a × c + 100 × a × d + 100 × b × c + b × d
On fingers. Suppose we have two integers of dimension n . Then
X = 10^(n/2) * a + b;
Y = 10^(n/2) * c + d;
s1 = ac; // step 1
s2 = bd; // step 2
s3 = ad + bc; //step 3
X * Y = 10^n * s1 + 10^(n/2) * s3 + s2;
In addition to the above explanations, I will add: at first it was easier for me to deal with fast matrix multiplication (Strassen multiplication, https://ru.wikipedia.org/wiki/Strassen_Algorithm). This is one of the most visual (in the mathematical sense) fast divide-and-conquer algorithms. It's easier for me to think in terms of matrices than the constituent parts of numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question