Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to high precision calculations of well-known mathematical constants by Kurt Calder Calculating Euler’s Number “e” using continued fractions.

Similar presentations


Presentation on theme: "An Introduction to high precision calculations of well-known mathematical constants by Kurt Calder Calculating Euler’s Number “e” using continued fractions."— Presentation transcript:

1 An Introduction to high precision calculations of well-known mathematical constants by Kurt Calder Calculating Euler’s Number “e” using continued fractions Calculating the Golden Ratio using continued fractions Calculating the square root of 2 using continued fractions Calculating pi using ArcTan series. Calculating pi to 10 trillion digits!!

2 Calculating Euler’s Number “e” using continued fractions A continued fraction is a representation of a fraction in the following form: It can be a finite continued fraction, where n is a non- negative integer, a 0 is an integer, and a i is a positive integer, for i=1,…,n. It can also be an infinite continued fraction. It is the latter that we will examine today.

3 Calculating Euler’s Number “e” using continued fractions

4

5

6 Now we know what we wish to calculate. The next question is how do we calculate it.

7 Calculating Euler’s Number “e” using continued fractions So our algorithm looks like the following N=1 ; Numerator is 1 D=4*n + 2 ; Denominator is the last term While n > 1 { n = n – 1 ; decrement current term m = 4 * n + 2 ; m is the current term multiplier A = m * D + N ; A is temporary placeholder N = D D = A } ‘ Calculate 2 / (1 + N/D) = 2D / (D + N) A = D + N N = 2 * D D = A ‘ Subtract out integer portion N = N – D ‘ Divide N / D

8 Calculating Euler’s Number “e” using continued fractions Dividing N / D A = q * D while A > N ‘ check for overestimate { q = q – 1 A = q * D } Save/print q ‘ Make sure to save leading zeroes (repeat to get next q until all the digits we have accumulated in q = “digits in N” + “digits in D” – 1)

9 Calculating Euler’s Number “e” using continued fractions 'e' Calculation using 2/1+1/6+1/10… TermsNumerator (N)Denominator (D)Value Significant Digits # digits in (N) + # digits in (D)Time (sec) 1572.71428571428571428571428571428571220 251712.71830985915492957746478873239437340 371910012.71828171828171828171828171828172670 412993180892.718281828735695726684725523798999100 52865653989592.7182818284585634112778506062026411120 67463683103910232.7182818284590458514046210849499615 0 72241970553121296492.7182818284590452347575606314797717180 87630163553106227990892.7182818284590452353607532301884821 0 92901704120694039784950312.7182818284590452353602871799000924 0 1012194787470451169777195903912.7182818284590452353602874715033627280 100220 digits 439440<.1 10003172 digits 634363440.438 1000041683 digits 83365833669.01 97001500002 digits500003 digits100000310000051513 100000516782 digits516783 digits103356410335651277 120000629640 digits 125927912592801588

10 Calculating Euler’s Number “e” using continued fractions Since the algorithm used here uses simple multiplication and division, both of which are known to be O(n 2 ), the overall efficiency is O(n 2 ). Note: The next improvement planned is an FFT multiplication method in “The Art of Computer Programming – Vol. 2” by Donald Knuth, which is O(N 1.63 ).

11 Calculating the Golden Ratio using continued fractions The Golden Ratio is the solution to the following quadratic equation: x 2 – x – 1 = 0. The values are approximately 0.618033988749894848… and 1.618033988749894848…

12 Calculating the Golden Ratio using continued fractions The continued fraction form for the Golden Ratio is the simplest of all continued fractions, and we will use this to improve the speed of our calculation.

13 Calculating the Golden Ratio using continued fractions phi Calculation using 1/1+1/1+1/1… Passes at 42 terms/ passNumerator (N)Denominator (D)Value Significant Digits # digits in (N) + # digits in (D)Time (sec) 14334944377014087330.6180339887498948491136052051407817180 22596954969111225854201961407274896730.6180339887498948482045868343656381202534360 56501 digits 100010020.062 5565004 digits 10006100080.464 555750006 digits 10001010001218.263 55556500001 digits 100000010000021162.959

14 Calculating the Square Root of 2 using continued fractions We will use the following continued fraction representation to calculate the square root of 2.

15 Calculating the Square Root of 2 using continued fractions Since the continued fraction form for the square root of 2 is similar to that for the Golden Ratio, we will use this to improve the speed of our calculation using the same method as before. This gives us the following relationship.

16 Calculating the Square Root of 2 using continued fractions Square Root of 2 Calculation using 1/2+1/2+1/2… Passes at 23 terms/p assNumerator (N)Denominator (D)Value Significant Digits # digits in (N) + # digits in (D)Time (sec) 13182810397683984010.4142135623730950476040878695165317180 22026056395738390434891332828724372790.4142135623730950488016887242096980815234360 56502 digits 100210040.064 5565001 digits 10000100020.462 555750006 digits 10001010001212.99 55557500006 digits 100001010000121060.94

17 Calculating pi using ArcTan series For calculating pi, we will use the following infinite series for the inverse tangent.

18 Calculating pi using ArcTan series We will use the following three different series to compare efficiency of the formulas. These formulas were used as recently as the 1970s to compute the world record number of digits of pi.

19 Calculating pi using ArcTan series Solving for n gives us the exponent that we must calculate to for the desired precision.

20 Calculating pi using ArcTan series Using p=1000 digits as an example in the previous equation for each of the three methods for calculating pi, we obtain the following efficiencies.

21 Calculating pi using ArcTan series How do we go about using this formula to calculate pi?

22 Calculating pi using ArcTan series Comparison of computations ValueTermsNumerator (N)Denominator (D) Significant DigitsTime (sec)CPU (sec)CPU Cycles e (cont. frac)97001500002 digits500003 digits100000315131405.428 4,629,760,711,679 e (inf. Series)205024n/a 10000081794.4151792.435 5,897,854,585,415 Golden Ratio55556500001 digits 10000001162.9591101.819 3,626,101,120,763 Sqrt(2)55557500006 digits 10000101060.941024.739 3,374,822,480,565 Pi-algorithm 11786606n/a 100000899379835 32,286,114,285,355 Pi-algorithm 21851127n/a 100000896269528 31,289,100,638,649 Pi-algorithm 32097277n/a 10000081090810886 35,788,904,940,877

23 Calculating pi to 10 trillion digits!! The current world record for the number of digits of pi calculated is 10 trillion digits announced October 17 th, 2011, by Alexander Yee and Shigeru Kondo after ten months of computations on a home computer. Alexander Yee is currently a graduate student at the University of Illinois studying Computer Science.

24 Calculating pi to 10 trillion digits!! How was this feat accomplished?

25 Calculating pi to 10 trillion digits!! First, the formulas used are much more efficient. For the main computation, the following formula was used: – Chudnovsky Formula:

26 Calculating pi to 10 trillion digits!! Verification was done using the following two formulas: – Plouffe's Formula: – Bellard's Formula:

27 Calculating pi to 10 trillion digits!! Next, the multiplication algorithms used are much more efficient than the standard method we are taught in grade school. – The efficiency of the algorithm we are all familiar with for calculating the product of two n-digit numbers is O(n 2 ). – The efficiency of the algorithm used here is currently unpublished, however, it is faster than the Fast Fourier Transform, which has efficiency of O(n log(n)). It uses Hybridized Number-Theoretic Transforms.

28 Calculating pi to 10 trillion digits!! Next, the code (written in C++) was optimized for Intel processors, using multi-threading and multi-core capabilities, which allow many computations to be done in parallel. Error-detection and correction is implemented. Errors that were observed in about 1 in 10 17 calculations had to be detected and corrected.

29 Calculating pi to 10 trillion digits!! Next, even though off-the-shelf hardware was used, the configuration of the home PC is more than almost any hardcore PC gamer/enthusiast.

30 Calculating pi to 10 trillion digits!! The computer had the following specifications: – Processor: 2 x Intel Xeon X5680 @ 3.33 GHz - (12 physical cores, 24 hyperthreaded) – Memory:96 GB DDR3 @ 1066 MHz - (12 x 8 GB - 6 channels) - Samsung (M393B1K70BH1) – Motherboard:Asus Z8PE-D12 – Hard Drives:1 TB SATA II (Boot drive) - Hitachi (HDS721010CLA332) 3 x 2 TB SATA II (Store Pi Output) - Seagate (ST32000542AS) 16 x 2 TB SATA II (Computation) - Seagate (ST32000641AS) – Raid Controller:2 x LSI MegaRaid SAS 9260-8i – Operating System:Windows Server 2008 R2 Enterprise x64 – Built By:Shigeru Kondo

31 Calculating pi to 10 trillion digits!! Comparison of computations ValueTermsNumerator (N)Denominator (D) Significant DigitsTime (sec)CPU (sec)CPU Cycles e (cont. frac)97001500002 digits500003 digits100000315131405.428 4,629,760,711,679 e (inf. Series)205024n/a 10000081794.4151792.435 5,897,854,585,415 Golden Ratio55556500001 digits 10000001162.9591101.819 3,626,101,120,763 Sqrt(2)55557500006 digits 10000101060.941024.739 3,374,822,480,565 Pi-algorithm 11786606n/a 100000899379835 32,286,114,285,355 Pi-algorithm 21851127n/a 100000896269528 31,289,100,638,649 Pi-algorithm 32097277n/a 10000081090810886 35,788,904,940,877 y-cruncher73942n/a 1048576???

32 Calculating pi to 10 trillion digits!! The world record pi program is over 10,000 times faster than the program demonstrated today!!! Comparison of computations ValueTermsNumerator (N)Denominator (D) Significant DigitsTime (sec)CPU (sec)CPU Cycles e (cont. frac)97001500002 digits500003 digits100000315131405.428 4,629,760,711,679 e (inf. Series)205024n/a 10000081794.4151792.435 5,897,854,585,415 Golden Ratio55556500001 digits 10000001162.9591101.819 3,626,101,120,763 Sqrt(2)55557500006 digits 10000101060.941024.739 3,374,822,480,565 Pi-algorithm 11786606n/a 100000899379835 32,286,114,285,355 Pi-algorithm 21851127n/a 100000896269528 31,289,100,638,649 Pi-algorithm 32097277n/a 10000081090810886 35,788,904,940,877 y-cruncher73942n/a 10485760.352 3,011,376,940

33 References “A trillion digits of pi” http://www.numberworld.org/misc_runs/pi- 10t/details.html http://www.numberworld.org/misc_runs/pi- 10t/details.html FFT algorithm http://numbers.computation.free.fr/Constant s/Algorithms/fft.html http://numbers.computation.free.fr/Constant s/Algorithms/fft.html D.E. Knuth, The Art of Computer Programming, Vol. II, Seminumerical Algorithms, Addison Wesley, (1998)


Download ppt "An Introduction to high precision calculations of well-known mathematical constants by Kurt Calder Calculating Euler’s Number “e” using continued fractions."

Similar presentations


Ads by Google