Long multiplication

The most straight-forward way to do multiplication is by long multiplication as we learned in elementary school

Example

      23958233
×         5830
———————————————
      00000000 ( =  23,958,233 ×     0)
     71874699  ( =  23,958,233 ×    30)
   191665864   ( =  23,958,233 ×   800)
+ 119791165    ( =  23,958,233 × 5,000)
———————————————
  139676498390 ( = 139,676,498,390)

It's easy to conclude that multiplying two -digit numbers using long multiplication requires  single-digit operations (additions and multiplications)

Karatsuba multiplication

Karatsuba multiplication is an efficient algorithm for multiplying large numbers. The algorithm reduces the multiplication of two -digit numbers to at most single-digit multiplications in general

Procedure

Given two numbers and represented as:

where and are the lower halves, and and are the upper halves of the numbers, each of length .

The product can be computed as follows:

  1. Compute three products:
  1. Combine the results:

Example

If we need to multiply 1234 and 5678 using Karatsuba multiplication.

  1. Split the numbers:
  1. Compute the three products:
  1. Combine the results:

Thus, .

Schönhage–Strassen algorithm

(status:: todo)