Upcoming SlideShare
×

# pi to a trillion digits : How and Why?

3,269 views

Published on

Describes the mathematical and programming concepts involved in the computation of the value of pi correct to a trillion or more decimal digits..

Published in: Education, Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

### pi to a trillion digits : How and Why?

1. 1. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Pi to a trillion digits: How and why V N Krishnachandran V N Krishnachandran Pi to a trillion digits: How and why
2. 2. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Outline 1 What is pi? 2 How to calculate the value of π? 3 Computing π in C 4 Why a trillion digits? V N Krishnachandran Pi to a trillion digits: How and why
3. 3. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? 1. What is pi? V N Krishnachandran Pi to a trillion digits: How and why
4. 4. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? What is pi? ‘pi ’ is the sixteenth letter of the Greek alphabet! V N Krishnachandran Pi to a trillion digits: How and why
5. 5. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? What is π? π denotes a very special number in mathematics. V N Krishnachandran Pi to a trillion digits: How and why
6. 6. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Deﬁnition of π Deﬁnition The ratio of the circumference of a circle to its diameter is denoted by π. (The symbol π was ﬁrst proposed by the Welsh mathematician William Jones in 1706.) V N Krishnachandran Pi to a trillion digits: How and why
7. 7. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Deﬁnition of π C d Circumference of a circle (C ) et e r π= dia m Diameter of the circle (d) V N Krishnachandran Pi to a trillion digits: How and why
8. 8. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? On the value of π Which of the following is true? π = 22/7 π = 3.14 √ π = 10 π = 335/113 None!! V N Krishnachandran Pi to a trillion digits: How and why
9. 9. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? On the value of π The numbers 22/7, 3.14, ... are only approximate values of π. V N Krishnachandran Pi to a trillion digits: How and why
10. 10. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? On the value of π π is not an integer. π is not a rational number, that is, not the ratio of one integer to another integer. π is not an algebraic number, that is, not a solution of a polynomial equation with integer coeﬃcients. V N Krishnachandran Pi to a trillion digits: How and why
11. 11. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? On the value of π The decimal representation of π has inﬁnite number of digits appearing apparently without any pattern. V N Krishnachandran Pi to a trillion digits: How and why
12. 12. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? On the value of π First 200 digits in the value of π: 3. 1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679 8214808651 3282306647 0938446095 5058223172 5359408128 4811174502 8410270193 8521105559 6446229489 5493038196 Fine! How can one obtain all these digits? V N Krishnachandran Pi to a trillion digits: How and why
13. 13. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? 2. How to calculate pi? V N Krishnachandran Pi to a trillion digits: How and why
14. 14. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to ﬁnd π Draw a circle. Measure the circumference of the circle. Measure the diameter of the circle. Divide the circumference by the diameter. The number obtained is the value of π. V N Krishnachandran Pi to a trillion digits: How and why
15. 15. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to ﬁnd π The geometrical procedure will not give the exact value of π. This is because of the limitations of the drawing instruments. For example, we cannot draw a line with thickness 0.0000000001 mm. V N Krishnachandran Pi to a trillion digits: How and why
16. 16. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to ﬁnd π Pi cannot be calculated by measuring circumferences and radii of circles! We need mathematical machinery!! V N Krishnachandran Pi to a trillion digits: How and why
17. 17. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Mathematical machinery to ﬁnd π Pieces of the machinery required: Radian measure of angle Arctangent function Gregory series Machin formula Or Ramanujan’s formula V N Krishnachandran Pi to a trillion digits: How and why
18. 18. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Radian measure of angle V N Krishnachandran Pi to a trillion digits: How and why
19. 19. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Radian measure of angle 180 degrees = π radians 1 degree = π/180 radians D degrees = (π/180) D radians Special case: 45 degrees = π/4 radians V N Krishnachandran Pi to a trillion digits: How and why
20. 20. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Arctangent function a arctan = Angle A. b V N Krishnachandran Pi to a trillion digits: How and why
21. 21. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Arctangent function Deﬁnition arctan(x) is an angle in radian measure whose trigonometric tangent is x. V N Krishnachandran Pi to a trillion digits: How and why
22. 22. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Arctangent function A formula for π arctan(1) = π/4 V N Krishnachandran Pi to a trillion digits: How and why
23. 23. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? James Gregory (1638 - 1675) James Gregory, a Scottish mathematician, developed a series expansion for arctan(x). V N Krishnachandran Pi to a trillion digits: How and why
24. 24. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Gregory series Gregory series x3 x5 x7 arctan(x) = x − + − + ··· 3 5 7 V N Krishnachandran Pi to a trillion digits: How and why
25. 25. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? John Machin (1686 - 1751) Machin, English astronomer, discovered a formula for faster computation of π. V N Krishnachandran Pi to a trillion digits: How and why
26. 26. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Machin’s formula Machin’s formula 1 1 4 arctan − arctan = arctan(1) 5 239 V N Krishnachandran Pi to a trillion digits: How and why
27. 27. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Numerical expression for π Numerical expression for π using Machin’s formula 1 1 1 1 1 π = 16 5 − 3 53 + 5 55 + ··· 1 1 1 1 1 −4 239 − 3 2393 + 5 2395 + ··· V N Krishnachandran Pi to a trillion digits: How and why
28. 28. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Srinivasa Ramanujan (1887 1920) A formula due to Srinivasa Ramanujan, Indian mathematical genius, is also used to compute π. V N Krishnachandran Pi to a trillion digits: How and why
29. 29. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Ramanujan’s formula Ramanujan’s formula √ ∞ 1 8 (4n)! 26390n + 1103 = × π 9801 n=0 (n!)4 3964n V N Krishnachandran Pi to a trillion digits: How and why
30. 30. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Some other methods Chudnovsky formula: The fastest converging series to compute π Iteration scheme due to Borwein and Borwein V N Krishnachandran Pi to a trillion digits: How and why
31. 31. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? 3. Computing π in C V N Krishnachandran Pi to a trillion digits: How and why
32. 32. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Basic idea Consider the ﬁrst 20 digits in the decimal representation of the proper fraction 4 : 7 4 7 = .57142857142857142857 We split this into blocks of two digits each: 57 14 28 57 14 28 57 14 28 57 V N Krishnachandran Pi to a trillion digits: How and why
33. 33. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Basic idea These blocks, treated as integers, are assigned to the cells in a one-dimensional array: x[0] = 57 x[1] = 14 x[2] = 28 x[3] = 57 x[4] = 14 x[5] = 28 x[6] = 57 x[7] = 14 x[8] = 28 x[9] = 57 V N Krishnachandran Pi to a trillion digits: How and why
34. 34. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Notations a, b positive proper fractions k positive integer a+b <1 a−b >0 ka < 1 V N Krishnachandran Pi to a trillion digits: How and why
35. 35. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Notations Digits of Stored in a x[i] b y[i] a+b s[i] a−b d[i] a/k q[i] V N Krishnachandran Pi to a trillion digits: How and why
36. 36. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Computation of x[i] Let a = N/D (N and D positive integers). Initialize: R = N; Repeat the following for i=0 to 20: x[i] = floor( ( R * 100 ) / D ) ; R = R - x[i] * D ; Computation of y[i] is similar. V N Krishnachandran Pi to a trillion digits: How and why
37. 37. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Computation of q[i] Initialize: R = 0; T = R * 100 + x[0] ; q[0] = floor (T/k) ; Repeat the following for i=1 to 20: R = x[i] - q[i] * k ; T = q[i] * 100 + x[i] ; q[i+1] = floor(T/k) ; V N Krishnachandran Pi to a trillion digits: How and why
38. 38. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Computation of s[i] Initialize: carry = 0 ; Repeat the following for i=20 to 0: t = x[i] + y[i] + carry ; if( t < 100 ) s[i] = t ; else { s [i] = x[i] + y[i] - 100; carry = 1 ; } V N Krishnachandran Pi to a trillion digits: How and why
39. 39. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program concepts: Computation of d[i] Initialize: borrow = 0 ; Repeat the following for i=20 to 0: x[i] = x[i] - borrow ; if( x[i] >= y[i] ) d[i] = x[i] - y[i] ; else { d[i] = 100 + x[i] - y[i]; borrow =1 ; } V N Krishnachandran Pi to a trillion digits: How and why
40. 40. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Program to compute π Put the pieces together to construct a program to compute π! V N Krishnachandran Pi to a trillion digits: How and why
41. 41. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Another program to compute π The following programme due to Dik T. Winter of Netherland, computes pi to 800 digits: long int a=10000,b,c=2800,d,e,f[2801],g; main(){ for(;b-c;)f[b++]=a/5; for(;d=0,g=c*2;c-=14, printf("%.4d",e+d/a),e=d%a) for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b); } Check the claim! V N Krishnachandran Pi to a trillion digits: How and why
42. 42. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? 4. Why a trillion digits? V N Krishnachandran Pi to a trillion digits: How and why
43. 43. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Why a trillion digits of π? To test hardware reliability To help develop eﬃcient algorithms To help generate random digits V N Krishnachandran Pi to a trillion digits: How and why
44. 44. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Known record T2K Open Supercomputer, at University of Tsukuba, Japan, calculated 2, 576, 980, 370, 000 decimal digits in the value of π (news dated 17 August 2009). V N Krishnachandran Pi to a trillion digits: How and why
45. 45. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? The hunt for the digits of π continues ... V N Krishnachandran Pi to a trillion digits: How and why
46. 46. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Department of Computer Applications Vidya Academy of Science and Technology Thrissur - 680501, Kerala (October 2009) V N Krishnachandran Pi to a trillion digits: How and why