SlideShare a Scribd company logo
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
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
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
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
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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Definition of π


       Definition
       The ratio of the circumference of a circle to its
       diameter is denoted by π. (The symbol π was first
       proposed by the Welsh mathematician William
       Jones in 1706.)




V N Krishnachandran
Pi to a trillion digits: How and why
What is pi?                How to calculate the value of π?         Computing π in C   Why a trillion digits?




Definition 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
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
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
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
                  coefficients.



V N Krishnachandran
Pi to a trillion digits: How and why
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 infinite
                  number of digits appearing apparently without
                  any pattern.




V N Krishnachandran
Pi to a trillion digits: How and why
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
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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Geometrical procedure to find π


                  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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Geometrical procedure to find π


                  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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Geometrical procedure to find π



                  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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Mathematical machinery to find π

       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
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
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
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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Arctangent function


       Definition
       arctan(x) is an angle in radian measure whose
       trigonometric tangent is x.




V N Krishnachandran
Pi to a trillion digits: How and why
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
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
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
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
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
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
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
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
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
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
What is pi?                How to calculate the value of π?   Computing π in C   Why a trillion digits?




Basic idea

                  Consider the first 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
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
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
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
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
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
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
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
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
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
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
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 efficient algorithms
                  To help generate random digits




V N Krishnachandran
Pi to a trillion digits: How and why
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
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
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

More Related Content

PPS
Tso math sine cosine
PPT
Pi day
PPTX
Downloading
ODP
Pi middle ages
PPTX
Pi works
PPTX
Pi101
PPTX
Pi Day 2013
Tso math sine cosine
Pi day
Downloading
Pi middle ages
Pi works
Pi101
Pi Day 2013

Similar to pi to a trillion digits : How and Why? (20)

PPT
PPTX
PDF
PPTX
History of pie
PPT
History and Algorithm of pi
PPTX
A Project on Pi
PPT
Pi Ppt
PPTX
PI THE MATHEMATICAL CONSTANT
PPTX
MATH Project history of pi.pptxuhfoufhdoufhfuh
PPTX
ODP
Pi greco erasmus (2)
PPTX
Learn About Pi
PPTX
Pi tastic
PPTX
historyofpi-160123103530(1).pptx just for timepasss
PPTX
presentation on pi.pptx
PPT
The Origin And History Of Pi By Nikitha Reddy
PPT
Pi presentation jaspreet
PPT
Pi presentation jaspreet
PPTX
History of pie
History and Algorithm of pi
A Project on Pi
Pi Ppt
PI THE MATHEMATICAL CONSTANT
MATH Project history of pi.pptxuhfoufhdoufhfuh
Pi greco erasmus (2)
Learn About Pi
Pi tastic
historyofpi-160123103530(1).pptx just for timepasss
presentation on pi.pptx
The Origin And History Of Pi By Nikitha Reddy
Pi presentation jaspreet
Pi presentation jaspreet
Ad

More from PlusOrMinusZero (20)

PDF
Deep into to Deep Learning Starting from Basics
PDF
The Untold Story of Indian Origins of Claculus
PDF
World environment day 2019 celebration
PPSX
Preseenting Vidya Mobile (An Android app for VAST)
PDF
An introduction to TeX and LaTeX
PDF
Fractional calculus and applications
PDF
On Sangamagrama Madhava's (c.1350 - c.1425) Algorithms for the Computation of...
PDF
Linear algebra behind Google search
PDF
Technical writing: Some guidelines
PDF
Almost all about Google Drive
PDF
First Introduction to Fractals
PDF
Mobile Communications Sajay K R
PPT
Performance Tuning by Dijesh P
PDF
On finite differences, interpolation methods and power series expansions in i...
PPTX
First introduction to wireless sensor networks
PPSX
World environment day 2010 vidya academy mca renjith sankar
PPSX
World environment day 2010 vidya academy mca steffi lazar
PDF
An introduction to free software
PDF
Introduction to Computer Algebra Systems
PPT
A prize winning entry in a two-hour slide-show presentation contest on World ...
Deep into to Deep Learning Starting from Basics
The Untold Story of Indian Origins of Claculus
World environment day 2019 celebration
Preseenting Vidya Mobile (An Android app for VAST)
An introduction to TeX and LaTeX
Fractional calculus and applications
On Sangamagrama Madhava's (c.1350 - c.1425) Algorithms for the Computation of...
Linear algebra behind Google search
Technical writing: Some guidelines
Almost all about Google Drive
First Introduction to Fractals
Mobile Communications Sajay K R
Performance Tuning by Dijesh P
On finite differences, interpolation methods and power series expansions in i...
First introduction to wireless sensor networks
World environment day 2010 vidya academy mca renjith sankar
World environment day 2010 vidya academy mca steffi lazar
An introduction to free software
Introduction to Computer Algebra Systems
A prize winning entry in a two-hour slide-show presentation contest on World ...
Ad

Recently uploaded (20)

PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Trump Administration's workforce development strategy
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
IGGE1 Understanding the Self1234567891011
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
My India Quiz Book_20210205121199924.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
Computer Architecture Input Output Memory.pptx
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
TNA_Presentation-1-Final(SAVE)) (1).pptx
Introduction to pro and eukaryotes and differences.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Trump Administration's workforce development strategy
Chinmaya Tiranga quiz Grand Finale.pdf
What if we spent less time fighting change, and more time building what’s rig...
IGGE1 Understanding the Self1234567891011
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
My India Quiz Book_20210205121199924.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
Computer Architecture Input Output Memory.pptx
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
B.Sc. DS Unit 2 Software Engineering.pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Computing-Curriculum for Schools in Ghana
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf

pi to a trillion digits : How and Why?

  • 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. 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. 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. 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. 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Definition of π Definition The ratio of the circumference of a circle to its diameter is denoted by π. (The symbol π was first proposed by the Welsh mathematician William Jones in 1706.) V N Krishnachandran Pi to a trillion digits: How and why
  • 7. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Definition 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. 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. 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. 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 coefficients. V N Krishnachandran Pi to a trillion digits: How and why
  • 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 infinite number of digits appearing apparently without any pattern. V N Krishnachandran Pi to a trillion digits: How and why
  • 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. 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to find π 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to find π 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Geometrical procedure to find π 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Mathematical machinery to find π 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. 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. 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. 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Arctangent function Definition 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. What is pi? How to calculate the value of π? Computing π in C Why a trillion digits? Basic idea Consider the first 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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 efficient algorithms To help generate random digits V N Krishnachandran Pi to a trillion digits: How and why
  • 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. 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. 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