Click here to send us your inquires or call (852) 36130518

Saturday, January 24, 2009

Multiplying big numbers using Cosines

I came across a technique for multiplying big numbers recently, called prosthaphaeresis [1], that predates the use of logarithms.  It relied on the use of pre-calculated cosine tables, and made use of the trigonometric relation:


cos(A)*cos(B) = [ cos(A+B) + cos(A-B) ]/2

All you need to to is scale the two large numbers to between 0 and 1, look up the scaled numbers in your cosine table to find the angles they represent, add and subtract the angles, find the cosines of the new angles in your table, and average them.

This speeds up multiplication by reducing a series of single-digit multiplications and additions to some table lookups, three addition/subtractions, and a division by two.  Before calculators, computation was much more of a scarce resource; anything that could speed it up was useful.  Before logarithms were invented, this could speed up your multiplication a lot.

For example, let's say we wanted to multiply 45678 x 23456.   Convert them to (0.45678 x 10^5) x (0.23456 x 10^5).  Combine the two multiplied 10^5 base 10 exponents into 10^10 and save it for later.  Looking up 0.45678 and 0.23456 in the cosine table says the angles representing them are 62.820 and 76.434 degrees, respectively.  Adding and subtracting these angles gives new angles of 139.254 and -13.614.  The cosines of these angles are -0.75761 and 0.97190.  Averaging them gives 0.10715.  Multiply this by the base 10 exponent of 10^10, and you have 1071400000. 

By my calculator, 45678 x 23456 = 1071423168, which to the correct number of significant figures, is 1071400000, the same answer from the cosine method.  Pretty neat, for the days before calculators.

Burton MacKenZie www.burtonmackenzie.com

[1] Greek "prosth-" or "adding"  and  "-aphaeresis" or "subtracting"

0 comments:

 

Addmotor Electric Bike| Electric bike shop / electric bicycle shop Electric bike review| Electric trike| Fat tire electric bike| Best electric bike| Electric bicycle/E bike| Electric bikes for sale| Folding electric bike| Electric mountain bike| Electric tricycle Mid drive electric bike| Juiced Bikes Pedego Rad-Power

Tomtop| Online shop| Online Einkaufen

地產代理/物業投資| 租辦公室/租寫字樓| 地產新聞| 甲級寫字樓/頂手| Grade A Office| Commercial Building / Office building| Hong Kong Office Rental| Rent Office| Office for lease / office leasing| Office for sale| Office relocation

DecorCollection European design furniture| sofa hk| sofas| beds| coffee tables| dining tables| dining chairs| sideboards| furniture hk| Cattelan Italia| Koinor

International schools hong kong| Wycombe Abbey| private school hong kong| English primary school Hong Kong| primary education| boarding school Hong Kong| Wycombe Abbey School

邮件营销| 電郵推廣| 邮件群发软件| Email Marketing| 搜尋引擎優化 SEO