The following results illustrate the author’s and Professor Emeritus Arjen K. Lenstra’s multiplication algorithms. The methods in alphabetical order are:
1. Bodrato’s modification of the Toom-Cook multiplication technique
2. Lenstra’s large integer package (lip) built-in multiple precision method
3. Long multiplication from pseudocode in Wikipedia
4. Toom-Cook method from Cook’s 1966 PhD thesis
References:
1. Papers by Marco Bodrato
2. Multiplication - Wikipedia
3. cr.yp.to/bib/1966/cook.html
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 2147483647
Enter M = 1234567890
Enter N = 1234567890
Number of repetitions = 1
M = 971334442946674600221231647138533765049334517138898208814432641876416006\
400115736571
N = 971334442946674600221231647138533765049334517138898208814432641876416006\
400115736571
Toom-Cook Multiplication
Average Runtime = 0.000074200
Over 1 Repetitions
MN = 943490600054526654019119035756125944918077526277676439897594263047388314\
836233229704805255157650098574056832103475286502442743200967269892687335\
748700513503753866838041
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 2147483647
Enter M = 1234567890
Enter N = 1234567890
Number of repetitions = 1
M = 971334442946674600221231647138533765049334517138898208814432641876416006\
400115736571
N = 971334442946674600221231647138533765049334517138898208814432641876416006\
400115736571
Lenstra lip Multiplication
Average Runtime = 0.000007400
Over 1 Repetitions
MN = 943490600054526654019119035756125944918077526277676439897594263047388314\
836233229704805255157650098574056832103475286502442743200967269892687335\
748700513503753866838041
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 2147483647
Enter M = 12345678901234567890
Enter N = 12345678901234567890
Number of repetitions = 1
M = 2026130632828332098161978694183179835926961551850814936441274855035774\
533901237908301792067190081080660611853406806309172584227706257836105490\
238900767068890331810595558979010550
N = 2026130632828332098161978694183179835926961551850814936441274855035774\
533901237908301792067190081080660611853406806309172584227706257836105490\
238900767068890331810595558979010550
Toom-Cook Multiplication
Average Runtime = 0.000098600
Over 1 Repetitions
MN = 41052053412853374997957659248772276766670464267610246450081646198672053\
134774107322853407211671548238594780193988795119754495077504801036773948\
450621659941905079488598768958918884281745778245753016460241195698241515\
318663783334584789872121452838087229440437832037084270117697010189272087\
88688141014237093579164596571668979636977920478671088735457011302500
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 2147483647
Enter M = 12345678901234567890
Enter N = 12345678901234567890
Number of repetitions = 1
M = 2026130632828332098161978694183179835926961551850814936441274855035774\
533901237908301792067190081080660611853406806309172584227706257836105490\
238900767068890331810595558979010550
N = 2026130632828332098161978694183179835926961551850814936441274855035774\
533901237908301792067190081080660611853406806309172584227706257836105490\
238900767068890331810595558979010550
Lenstra lip Multiplication
Average Runtime = 0.000009300
Over 1 Repetitions
MN = 41052053412853374997957659248772276766670464267610246450081646198672053\
134774107322853407211671548238594780193988795119754495077504801036773948\
450621659941905079488598768958918884281745778245753016460241195698241515\
318663783334584789872121452838087229440437832037084270117697010189272087\
88688141014237093579164596571668979636977920478671088735457011302500
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 5
D:\FLMultiplication\x64\Release\FLMultiplication.exe (process 20168) exited with code 0 (0x0).
Press any key to close this window . . .
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 2147483647
Enter M = 123456789012345678901234567890
Enter N = 123456789012345678901234567890
Number of repetitions = 1
M = 42263561959479590219289335715252528051946761885385061954793363463431018\
850749052611816045464227557359947957390833136631219765211655242009436305\
106409335048399270235917319942885139182317225885422762482775210395122870\
45968780928724406323190056412004806954312198921740353521
N = 42263561959479590219289335715252528051946761885385061954793363463431018\
850749052611816045464227557359947957390833136631219765211655242009436305\
106409335048399270235917319942885139182317225885422762482775210395122870\
45968780928724406323190056412004806954312198921740353521
Toom-Cook Multiplication
Average Runtime = 0.000183000
Over 1 Repetitions
MN = 1786208669502770299576960480677491594428843761318376718810830214483008\
522779876058101551852828273108216537734660930558577510542169332383202300\
806637802232078747108185518603023831159502647581878153273000030245312879\
938941795477296487228094659168732765010051027312450437648026306828037634\
862435594225658630177203603798218997466111668748532465924932822495598422\
823492688498989692318248236025719132743625324592268073825418742555965769\
253184917848571722561153588394570162730241248387724570796710835550233766\
6905434432429374209450377625018057097441
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 2147483647
Enter M = 123456789012345678901234567890
Enter N = 123456789012345678901234567890
Number of repetitions = 1
M = 42263561959479590219289335715252528051946761885385061954793363463431018\
850749052611816045464227557359947957390833136631219765211655242009436305\
106409335048399270235917319942885139182317225885422762482775210395122870\
45968780928724406323190056412004806954312198921740353521
N = 42263561959479590219289335715252528051946761885385061954793363463431018\
850749052611816045464227557359947957390833136631219765211655242009436305\
106409335048399270235917319942885139182317225885422762482775210395122870\
45968780928724406323190056412004806954312198921740353521
Lenstra lip Multiplication
Average Runtime = 0.000058300
Over 1 Repetitions
MN = 1786208669502770299576960480677491594428843761318376718810830214483008\
522779876058101551852828273108216537734660930558577510542169332383202300\
806637802232078747108185518603023831159502647581878153273000030245312879\
938941795477296487228094659168732765010051027312450437648026306828037634\
862435594225658630177203603798218997466111668748532465924932822495598422\
823492688498989692318248236025719132743625324592268073825418742555965769\
253184917848571722561153588394570162730241248387724570796710835550233766\
6905434432429374209450377625018057097441
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 5
D:\FLMultiplication\x64\Release\FLMultiplication.exe (process 25124) exited with code 0 (0x0).
Press any key to close this window . . .
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 1000000000000000000000000000000
Enter M = 123456789012345678901234567890
Enter N = 123456789012345678901234567890
Number of repetitions = 1
M = 10000000000000000000000000000020000000000000000000000000000030000000000\
000000000000000000040000000000000000000000000000050000000000000000000000\
000000060000000000000000000000000000070000000000000000000000000000080000\
000000000000000000000000090000000000000000000000000000000000000000000000\
000000000000010000000000000000000000000000020000000000000000000000000000\
030000000000000000000000000000040000000000000000000000000000050000000000\
000000000000000000060000000000000000000000000000070000000000000000000000\
000000080000000000000000000000000000090000000000000000000000000000000000\
000000000000000000000000010000000000000000000000000000020000000000000000\
000000000000030000000000000000000000000000040000000000000000000000000000\
050000000000000000000000000000060000000000000000000000000000070000000000\
000000000000000000080000000000000000000000000000090000000000000000000000\
00000000
N = 10000000000000000000000000000020000000000000000000000000000030000000000\
000000000000000000040000000000000000000000000000050000000000000000000000\
000000060000000000000000000000000000070000000000000000000000000000080000\
000000000000000000000000090000000000000000000000000000000000000000000000\
000000000000010000000000000000000000000000020000000000000000000000000000\
030000000000000000000000000000040000000000000000000000000000050000000000\
000000000000000000060000000000000000000000000000070000000000000000000000\
000000080000000000000000000000000000090000000000000000000000000000000000\
000000000000000000000000010000000000000000000000000000020000000000000000\
000000000000030000000000000000000000000000040000000000000000000000000000\
050000000000000000000000000000060000000000000000000000000000070000000000\
000000000000000000080000000000000000000000000000090000000000000000000000\
00000000
Toom-Cook Multiplication
Average Runtime = 0.000399800
Over 1 Repetitions
MN = 100000000000000000000000000000400000000000000000000000000001000000000\
000000000000000000002000000000000000000000000000003500000000000000000000\
000000005600000000000000000000000000008400000000000000000000000000012000\
000000000000000000000000016500000000000000000000000000020000000000000000\
000000000000022600000000000000000000000000024400000000000000000000000000\
025500000000000000000000000000026000000000000000000000000000026000000000\
000000000000000000025600000000000000000000000000024900000000000000000000\
000000024000000000000000000000000000033000000000000000000000000000040000\
000000000000000000000000045100000000000000000000000000048400000000000000\
000000000000050000000000000000000000000000050000000000000000000000000000\
048500000000000000000000000000045600000000000000000000000000041400000000\
000000000000000000036000000000000000000000000000049500000000000000000000\
000000060000000000000000000000000000067400000000000000000000000000071600\
000000000000000000000000072500000000000000000000000000070000000000000000\
000000000000064000000000000000000000000000054400000000000000000000000000\
041100000000000000000000000000024000000000000000000000000000033000000000\
000000000000000000040000000000000000000000000000044900000000000000000000\
000000047600000000000000000000000000048000000000000000000000000000046000\
000000000000000000000000041500000000000000000000000000034400000000000000\
000000000000024600000000000000000000000000012000000000000000000000000000\
016500000000000000000000000000020000000000000000000000000000022400000000\
000000000000000000023600000000000000000000000000023500000000000000000000\
000000022000000000000000000000000000019000000000000000000000000000014400\
000000000000000000000000008100000000000000000000000000000000000000000000\
0000000000000000
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 1000000000000000000000000000000
Enter M = 123456789012345678901234567890
Enter N = 123456789012345678901234567890
Number of repetitions = 1
M = 10000000000000000000000000000020000000000000000000000000000030000000000\
000000000000000000040000000000000000000000000000050000000000000000000000\
000000060000000000000000000000000000070000000000000000000000000000080000\
000000000000000000000000090000000000000000000000000000000000000000000000\
000000000000010000000000000000000000000000020000000000000000000000000000\
030000000000000000000000000000040000000000000000000000000000050000000000\
000000000000000000060000000000000000000000000000070000000000000000000000\
000000080000000000000000000000000000090000000000000000000000000000000000\
000000000000000000000000010000000000000000000000000000020000000000000000\
000000000000030000000000000000000000000000040000000000000000000000000000\
050000000000000000000000000000060000000000000000000000000000070000000000\
000000000000000000080000000000000000000000000000090000000000000000000000\
00000000
N = 10000000000000000000000000000020000000000000000000000000000030000000000\
000000000000000000040000000000000000000000000000050000000000000000000000\
000000060000000000000000000000000000070000000000000000000000000000080000\
000000000000000000000000090000000000000000000000000000000000000000000000\
000000000000010000000000000000000000000000020000000000000000000000000000\
030000000000000000000000000000040000000000000000000000000000050000000000\
000000000000000000060000000000000000000000000000070000000000000000000000\
000000080000000000000000000000000000090000000000000000000000000000000000\
000000000000000000000000010000000000000000000000000000020000000000000000\
000000000000030000000000000000000000000000040000000000000000000000000000\
050000000000000000000000000000060000000000000000000000000000070000000000\
000000000000000000080000000000000000000000000000090000000000000000000000\
00000000
Lenstra lip Multiplication
Average Runtime = 0.000076500
Over 1 Repetitions
MN = 100000000000000000000000000000400000000000000000000000000001000000000\
000000000000000000002000000000000000000000000000003500000000000000000000\
000000005600000000000000000000000000008400000000000000000000000000012000\
000000000000000000000000016500000000000000000000000000020000000000000000\
000000000000022600000000000000000000000000024400000000000000000000000000\
025500000000000000000000000000026000000000000000000000000000026000000000\
000000000000000000025600000000000000000000000000024900000000000000000000\
000000024000000000000000000000000000033000000000000000000000000000040000\
000000000000000000000000045100000000000000000000000000048400000000000000\
000000000000050000000000000000000000000000050000000000000000000000000000\
048500000000000000000000000000045600000000000000000000000000041400000000\
000000000000000000036000000000000000000000000000049500000000000000000000\
000000060000000000000000000000000000067400000000000000000000000000071600\
000000000000000000000000072500000000000000000000000000070000000000000000\
000000000000064000000000000000000000000000054400000000000000000000000000\
041100000000000000000000000000024000000000000000000000000000033000000000\
000000000000000000040000000000000000000000000000044900000000000000000000\
000000047600000000000000000000000000048000000000000000000000000000046000\
000000000000000000000000041500000000000000000000000000034400000000000000\
000000000000024600000000000000000000000000012000000000000000000000000000\
016500000000000000000000000000020000000000000000000000000000022400000000\
000000000000000000023600000000000000000000000000023500000000000000000000\
000000022000000000000000000000000000019000000000000000000000000000014400\
000000000000000000000000008100000000000000000000000000000000000000000000\
0000000000000000
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 5
D:\FLMultiplication\x64\Release\FLMultiplication.exe (process 22984) exited with code 0 (0x0).
Press any key to close this window . . .
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 1
Enter e in 10^e = 50
b = 100000000000000000000000000000000000000000000000000
Enter U = 12345678901234567890123456789012345678901234567890
Enter V = 12345678901234567890123456789012345678901234567890
Enter R = 1
Bodrato Multiplication
Average Runtime = 0.005534500
Over 1 Repetitions
W = 15241578753238836750495351562566681945008382873375704923650053345576253\
6198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 10
Enter M = 12345678901234567890123456789012345678901234567890
Enter N = 12345678901234567890123456789012345678901234567890
Number of repetitions = 1
M = 12345678901234567890123456789012345678901234567890
N = 12345678901234567890123456789012345678901234567890
Lenstra lip Multiplication
Average Runtime = 0.000005700
Over 1 Repetitions
MN = 15241578753238836750495351562566681945008382873375704923650053345576253\
6198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 3
Enter b = 100000000000000000000000000000000000000000000000000
Enter A = 12345678901234567890123456789012345678901234567890
Enter B = 12345678901234567890123456789012345678901234567890
Enter # = 1
Long Multiplication
Average Runtime = 0.000029500
Over 1 Repetitions
x = 15241578753238836750495351562566681945008382873375704923650053345576253\
6198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 10
Enter M = 12345678901234567890123456789012345678901234567890
Enter N = 12345678901234567890123456789012345678901234567890
Number of repetitions = 1
M = 12345678901234567890123456789012345678901234567890
N = 12345678901234567890123456789012345678901234567890
Toom-Cook Multiplication
Average Runtime = 0.000278200
Over 1 Repetitions
MN = 15241578753238836750495351562566681945008382873375704923650053345576253\
6198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 5
D:\FLMultiplication\x64\Release\FLMultiplication.exe (process 9856) exited with code 0 (0x0).
Press any key to close this window . . .
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 1
Enter e in 10^e = 100
b = 100000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000
Enter U = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter V = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter R = 1
Bodrato Multiplication
Average Runtime = 0.007581100
Over 1 Repetitions
W = 15241578753238836750495351562566681945008382873376009755225118122311263\
526910001524158887669562677515622630876390795200121932731260478594250876\
39153757049236500533455762536198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 2
Enter b = 10
Enter M = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter N = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Number of repetitions = 1
M = 123456789012345678901234567890123456789012345678901234567890123456789012\
3456789012345678901234567890
N = 123456789012345678901234567890123456789012345678901234567890123456789012\
3456789012345678901234567890
Lenstra lip Multiplication
Average Runtime = 0.000004300
Over 1 Repetitions
MN = 15241578753238836750495351562566681945008382873376009755225118122311263\
526910001524158887669562677515622630876390795200121932731260478594250876\
39153757049236500533455762536198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 3
Enter b = 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Enter A = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter B = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter # = 1
Long Multiplication
Average Runtime = 0.000070000
Over 1 Repetitions
x = 15241578753238836750495351562566681945008382873376009755225118122311263\
526910001524158887669562677515622630876390795200121932731260478594250876\
39153757049236500533455762536198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 4
Enter b = 10
Enter M = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Enter N = 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Number of repetitions = 1
M = 123456789012345678901234567890123456789012345678901234567890123456789012\
3456789012345678901234567890
N = 123456789012345678901234567890123456789012345678901234567890123456789012\
3456789012345678901234567890
Toom-Cook Multiplication
Average Runtime = 0.000396200
Over 1 Repetitions
MN = 15241578753238836750495351562566681945008382873376009755225118122311263\
526910001524158887669562677515622630876390795200121932731260478594250876\
39153757049236500533455762536198787501905199875019052100
== Menu ==
1 Bodrato Multiplication
2 Lenstra lip Multiplication
3 Long Multiplication
4 Toom-Cook Algorithm
5 Exit
Option (1 - 5) = 5
D:\FLMultiplication\x64\Release\FLMultiplication.exe (process 20640) exited with code 0 (0x0).
Press any key to close this window . . .
References: