1 / 33

Calculating Euler’s Number “e” using continued fractions

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

dallon
Télécharger la présentation

Calculating Euler’s Number “e” using continued fractions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to high precision calculationsof well-known mathematical constantsbyKurt 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, a0 is an integer, and ai 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 • We will use the following formula to calculate e. • To evaluate an infinite continued fraction, select a point in the c.f. and omit everything after it. You are left with a finite c.f. which can then be evaluated.

  4. Calculating Euler’s Number “e” using continued fractions • We will use the following formula to calculate e. An example above. If we omit everything after the 6, we are left with which evaluates to 19/7.

  5. Calculating Euler’s Number “e” using continued fractions • We will use the following formula to calculate e. An example above. If we omit everything after the 10, we are left with which evaluates to 1 + 122/71.

  6. Calculating Euler’s Number “e” using continued fractions • 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

  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(n2), the overall efficiency is O(n2). • Note: The next improvement planned is an FFT multiplication method in “The Art of Computer Programming – Vol. 2” by Donald Knuth, which is O(N1.63).

  11. Calculating the Golden Ratio using continued fractions • We will use the following continued fraction representation to calculate The Golden Ratio is the solution to the following quadratic equation: x2 – 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

  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

  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 If we wish to calculate p digits of pi, then when calculating then we must calculate each term until . 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. For -> 797 + 570 + 421 = 1787 terms. For -> 1431 + 421 = 1852 terms. For -> 1108 + 570 + 421 = 2098 terms.

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

  22. Calculating pi using ArcTan series

  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 17th, 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'sFormula:

  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(n2). • 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 1017 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!!

  32. Calculating pi to 10 trillion digits!! The world record pi program is over 10,000 times faster than the program demonstrated today!!!

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

More Related