Slices of PI Richmond U3A Maths Group 5 November 2021 Donald Bell donald@marchland.org Lots of slices of π to sample! Definition of π Some nice books on π Archimedes Approximation (250 BC) Vieti's exact formula for π based on √2 The arctan technique Machin's formula and other arctan formulas Finding our own formula a trillion digits of π Extending the accuracy of π Buffon's Needle and other statistical curiosities (part 2 later) proof that π is irrational Euler's Harmonic Series Using the Zeta Function with even arguments Gauss and the Arithmetic Geometric Mean The (wrong) proofs that PI is rational Definition of π π is the perimeter of the circle divided by its diameter (d), or twice its radius (2r). So the perimeter = 2 π r A circle can be approximated by a polygon and the segments of the polygon can be rearranged to make an approximation to a parallelogram of height r and length πr In the limit the area is πr2 How many digits do we need for π? In precision mechanical engineering, like boring the cylinder of a car, the smallest unit of measurement is 0.0001 inch, so 4 or 5 significant digits will do. The definition of the metre is the distance travelled by light in 1/ 299 792 458 of a second, so 9 or 10 significant digits will do. In numerical analysis, there is always the problem of "rounding errors" so modern computers are usually "64-bit". The IEEE 754 double-precision binary floatingpoint format uses 11 bits for the exponent and 53 for the mantissa (including the sign bit) so the precision is about 16 significant decimal digits the largest 64-bit integer is 9,223,372,036,854,775,807 ie 19 significant digits The Scientific Calculator, built in to Windows 10, has 32 significant digits But π has been calculated to 31,415,926,535,897 digits (Amanda Kooser of Google on March 14, 2019) why did Amanda choose that day and that number of digits? PI Unleashed by Jorg Arndt and Christoph Haenel Translated from the German by Catriona and David Lischka published by Springer (2001) Title of the original German edition: Pi. Algorithmen, Computer, Arithmetik A delightful collection of short articles about π "The Joy of π" by David Blatner A collection of miscellaneous stories and equations all about π, from ancient times to the present day. And in the margins one million digits of π. The millionth digit, by the way, is a 1. PI: a source book by Lennart Berggren, Jonathan Borwein and Peter Borwein Published by Springer (2004) Many interesting facts and figures, including many original papers. Alas, this book is now an (expensive) collector's item. An important "tool of the trade" the 32-digit Windows Scientific Calculator Another important "tool of the trade" the "Ink Equation Editor" in Microsoft Word Another important "tool of the trade" the Python programming language • • • • • • • • • • • Widely available Versions for Windows, Linux etc Free "Object Oriented" Language Suitable for both small and large programs Well supported Easy to learn and use Good documentation Lots of specialist libraries Integers can be of any size (in Python 3.0 onwards) Floating point libraries permit high precision Example Using Python to search for things, like: a3 + b3 + c3 = d3 #!/usr/bin/python # cube_triplet.py - find integers a,b,c,d # so that: a³ + b³ + c³ = d³ def is_cube(n): root = round(n**(1/3)) if n == root*root*root: return True return False Just try every def main(): combination of limit = 20 numbers a, b, c up to print ("cube triplets up to", limit) a given limit such for a in range(3, limit+1): that: for b in range (2, a): limit ≥ a > b > c for c in range(1, b): sum = a*a*a + b*b*b + c*c*c if is_cube(sum): print (a,b,c,round(sum**(1/3))) the function called: is_cube tests a number to see if __name__ == "__main__": if it is a perfect cube main() Console output from the cube_triplet Python program #!/usr/bin/python # cube_triplet.py - find integers a,b,c,d # so that: a³ + b³ + c³ = d³ def is_cube(n): root = round(n**(1/3)) if n == root*root*root: return True return False def main(): limit = 20 print ("cube triplets up to", limit) for a in range(3, limit+1): for b in range (2, a): for c in range(1, b): sum = a*a*a + b*b*b + c*c*c if is_cube(sum): print (a,b,c,round(sum**(1/3))) if __name__ == "__main__": main() cube triplets up to 20 5 4 3 6 8 6 1 9 10 8 6 12 15 12 9 18 16 12 2 18 17 14 7 20 18 10 3 19 20 16 12 24 750 Digits of π Early estimates of π The true value of π is about 3.141592653 √10 is 3.1622777 π/4 was thought to be (8/9)2 or 0.7901234 giving a value of 3.1604938 Archimedes inequalities (about 250 BC) Archimedes showed that : or 3.142857 > π > 3.140845 He considered a polygon of 96 sides inside a circle and another of 96 sides outside the circle. The proof is quite long, but it is completely described in the "Archimedes" chapter of: "God Created the Integers" by Stephen Hawking π and the Great Pyramid of Giza The Great Pyramid stands on a square base. When it was built, the base was 440 royal cubits on one side, so the perimeter was 1760 cubits. The height was 280 cubits, so the ratio of perimeter to height was: 1760/280 = 6.2 But 2π is 6.28 (and many books have been written on this coincidence!) Fractional Approximation of π The value of π to 15 decimal digits is : 3.141592653589793 A reasonable approximation is given by the fraction 22/7 (= 3.14285) and a much better one by 355/113 (= 3.14159292) How can these fractions be arrived at? And is there a still better approximation? Write π as 3.0 + 0.141592653589793 then 0.141592653589793 can be re-written as 1/7.06251330593105766 so π is approximately 3 + 1/7 or 22/7 Fractional Approximation of π (2) π is approximately 3.0 + 1.0 / 7.06251330593105766 but 7.06251330593105766 can be written as 7.0 + 0.06251330593105766 and 0.06251330593105766 can be written as 1/15.996594406682676 so π is approximately 3 + 1/(7 + 1/16) or 3 + 1/(113/16) or 355/113 π = 3.0 + 1/(7.0 + 1/15.996594406682676) 0.996594406682676 = 1/1.003417231016437 so that the next approximations are: 103993 / 33102, 104348/33215, 208341 / 66317, etc Improvements on Archimedes' Methods Archimedes began with the hexagon, and considered the inscribed circle and the hexagon inside that again. He then repeatedly doubled the number of sides until he got to 96. He showed that 3.142857 > π > 3.140845 and the average of these numbers is 3.141851 In about 1600, Ludolf van Ceulen repeatedly doubled the number of sides until he had about 32,000,000,000 of them. Eventually he determined π to 35 decimal places. In 2003, Gopal Chakrabarti and Richard Hudson re-examined Archimedes technique and showed that the true vale of π was 2/3 of the way between Archimedes' limits, so that (to 6 decimal places): π = (3.142857 + 2 * 3.140845) / 3 = 3.141516 Viète's Method of calculating π (around 1596) Starting with a square, François Viète repeatedly doubled the number of sides of the polygon. The perimeter of a polygon with n sides is written as P(n) Then if n is a power of 2, P(n) / P(2n) = cos (π/2n) and P(n) gets closer to π So P(4) = 2√2 = 2.828427 (rather a long way from π) Then P(8) = P(4) / cos(22.5°) = 2.828427 / 0.9238795 = 3.061467 And P(16) = P(8) / cos(11.25°) = 3.061467 / 0.980785 = 3.121445 And P(32) = p(16) / cos(5.625°) = 3.121445 / 0.99518 = 3.136548 Calculating cos(π/2N) - Viète's Method cos 2θ = cos2 θ – sin2 θ, cos2 θ = (cos 2θ + 1)/2, cos 2θ = 2 cos2 θ – 1 cos θ = √((cos 2θ + 1)/2) so if θ = π/8, then cos 2θ = cos π/4 = √2/2 cos(π/8) = √((√2/2 + 1)/2) cos(π/16) = √((√((√2/2 + 1)/2)+ 1)/2) and so on Viète actually calculated 2/π, about 0.63662, since it was simpler: 2/π = √2/2 * cos(π/8) * cos(π/16) * cos(π/32) * . . . He had discovered the first exact method of calculating π. But it was a lot of work for just a few digits. Viète's Method of calculating PI Suppose we have reached the stage where AB is one of the edges of our 2N sided polygon. We now replace AB (= AC + CB) with AD and DB. Thus increasing the perimeter by a ratio of (DB/CB) or 1/cos(θ/2) Viète actually calculated 2 / π, which is: 0.63661977 It can be written as: 2 / π = √2/2 * cos(π/8) * cos(π/16) * cos(π/32) . . . = 0.707107 * 0.923879 * 0.980785 * 0.995185 = 0.6376434 Further applications of cos(π/64), cos(π/128), etc would get nearer to the true value Viète's Method of calculating PI (summary) The square is the first approximation to π So π = (AB + BF + FG + GA)/AF = 2√2 or about 2.828 Replace AB with AD+DB and this will multiply by 1/cos(DBA) Angle DBA is ¼ AOB or π/8, so a better approximation is: π = (2√2)/ cos(π/8) = 2.828 / 0.9239 = 3.061467 or 2/π = √2/2 * cos(π/8) then 2/π = √2/2 * cos(π/8) * cos(π/16) * cos(π/32) * . . . Archimedes' Method (in modern notation) Archimedes started with a hexagon, of side 1, so its perimeter was 6 units long. He repeatedly doubled the number of sides. What is the formula for the (increased) length of the perimeter? In the diagram, AB is one of the sides of the polygon and we want to replace it with the two sides AC and CB. The radius of the circumscribing circle, OB, is r, the length of the original side, AB, is x, and the length of the new sides, AC and CB is z. We need a formula for z in terms of r and x Archimedes' Method In the right angled (green) triangle ODB w2 = r2 – (x/2)2 = (4r2 – x2)/4 w = ½ √(4r2 – x2) Then since OC = r, y = (r-w) In the right angled (pink) triangle BCD, z2 = y2 + (x/2)2 = (r-w)2 + (x/2)2 z2 = r2 – 2rw + w2 + (x2/4) expanding, and substituting for w and w2 z2 = r2 – 2r(½ √(4r2 – x2)) + (4r2 – x2)/4 + (x2/4) z2 = 2r2 – r√(4r2 – x2) finally: z = √( 2r2 – r√(4r2 – x2) ) and if r = 1 z = √( 2 – √(4 – x2) ) Calculating π by repeated doubling of sides Begin with a regular hexagon, of side, s0 = 1. Its half-perimeter is therefore 3, an approximation, p0, to a semicircle, whose length is π. When the number of sides is doubled to 12, the length of each side, s1, becomes 0.5176, and so the approximation, p1 becomes 6 * 0.5176 or 3.1058 in general, pn = 3*2n * sn We derived the equation: z = √( 2 – √(4 – x2) ) and this can be re-written as a recurrence relation s(n+1) = √( 2 – √(4 – sn2) ) for calculating the lengths of the sides #!/usr/bin/python # pi_polygon.py - calculate pi by # repeatedly dividing polygon sides import math def main(): sides = 6 x = 1.0 cycles = 10 for n in range (cycles): pi = (sides//2) * x print (n, sides, x, pi) sides = sides * 2 x = math.sqrt(2 - math.sqrt(4-x*x)) if __name__ == "__main__": main() Results of running the Python program, repeatedly doubling the number of sides of a polygon each cycle, on average, adds one more useful digit to the value of π Calculate π by doubling edges of a polygon Instead of measuring the perimeter of a polygon when we double its sides, we will look at what happens to the area Suppose we have a polygon with N sides. Call its area AN . What is A2N AB is one side of the N-polygon. The angle θ is π/N. O is the centre of the circle. The area of the N-polygon is N times the area of OAB or 2N times the area of OAC. The area of OAC is ½ AC * OC = ½ sin θ cos θ = ¼ sin 2θ So the area of the N-polygon is (N/2) sin (2π/N) And the area of a 2N-polygon, A2N , will then be N sin (π/N) But sin (2π/N) = 2 sin (π/N) * cos (π/N), so 𝐴2𝑁 1 = 𝜋 𝐴𝑁 cos 𝑁 Calculate π by doubling edges of a polygon We derived the formula 𝐴2𝑁 1 = 𝜋 𝐴𝑁 cos 𝑁 Suppose we start with a hexagon, N = 6 The area A6 will be (3/2)√3 = 2.5981 If we double the sides to make a 12-polygon, then A12 will be A6 / cos(π/6) or 2.5981 / 0.8660 = 3.0000 Doubling again gives A24 = A12 / cos(π/12) or 3.0000 / 0.9659 = 3.1058 Doubling again gives A48 = A24 / cos(π/24) or 3.1058 / 0.9914 = 3.1326 getting closer to π Calculate π by doubling the edges of a polygon (putting all the bits together) The area of a circle is πr2 or, if the radius is unity, then just π. Start with a regular polygon, inscribed in this unit circle: hexagon, square, pentagon or even a triangle whose area, AN , we can calculate exactly. For a square A4 is 2, for a hexagon A6 is (3/2)√3 = 2.5981 Choose a number N, which is of the form s*2n so that we can determine AN For example, if N = 48, then s = 6 and n = 3, since 48 = 6 * 23 . Then: 𝐴12 𝐴24 𝐴48 𝐴48 = 𝐴6 ∗ ∗ 𝐴6 𝐴12 𝐴24 𝐴2𝑁 1 We derived the formula = 𝜋 𝐴𝑁 cos 𝑁 We just need to be able to calculate all those cosines Calculate π by doubling the edges of a polygon (putting all the bits together) We know that A6 is (3/2)√3 = 2.5981, and 𝐴12 𝐴24 𝐴48 𝐴48 = 𝐴6 ∗ ∗ 𝐴6 𝐴12 𝐴24 𝐴2𝑁 1 Also = 𝜋 𝐴𝑁 cos 𝑁 so 𝐴12 1 = 𝜋 𝐴6 cos etc 6 And the half-cosine rule is cos θ/2 = √((cos θ + 1)/2) Since cos(π/6) is ½√3, we can calculate cos(π/12), cos(π/24) etc So A48 = 2.598076 / (0.8660254 * 0.9659258 * 0.9914449) = 2.598076 / 0.8293597 = 3.1326285 Similarly, we can calculate A40 (starting with a pentagon) Calculating π from Pythagorean Triangles The quadrant BCDE is drawn with a radius of 5 inside a 5x5 grid of unit squares as shown. The grey triangles ADF and ACJ are both Pythagorean triangles with sides 3, 4, 5. The length of the quadrant BCDE is (5/2)π which is about 7.8540 Note that the triangles EFD, DKC and CJB (shown in colour) are all right-angled with integer sides. We can calculate the lengths of the three edges BC, CD and DE They are √10 + √2 + √10 = 3.1623 + 1.4142 + 3.1623 = 7.7388 giving a value of π of (2/5)*7.7388 = 3.0955, about 1.5% too low. But that is just the start – we can do better. Calculating π from Pythagorean Triangles We observe that it is always possible to make a Pythagorean triangle, with sides a, b, c where the longest side, c, is a power of 5. And if the length of c is 5N then the number of different Pythagorean triangles is also N. 35² + 120² = 15,625 = 125² 44² + 117² = 15,625 = 125² 75² + 100² = 15,625 = 125² 3² + 4² = 5² 175² + 600² = 390,625 = 625² 220² + 585² = 390,625 = 625² 336² + 527² = 390,625 = 625² 375² + 500² = 390,625 = 625² 7² + 24² = 625 = 25² 15² + 20² = 625 = 25² So we can get better and better values for π by using grids of size: 25x25, 125x125, 625x625 and so on Calculating π from Pythagorean Triangles A quarter circle in a 25x25 grid. The points on the circle with integer coordinates are: (25,0), (24,7), (20, 15), (15, 20), (7, 24) and (0, 25) The shorter sides of the red, green and yellow triangles are: (1, 7), (4, 8) and (5, 5) So all five of the long edges are: √50, √80, √50, √80, √50 The total length of the five edges is 3 * 7.071068 + 2 * 8.944272 = 39.101747 Giving a value for π of (2/25) * 39.101747 or 3.12814 About 99.6% of the accepted value Pythagorean Triangles with side 5N A recurrence relation can be used to calculate the various triangle sides: Begin with x0 = 0 and y0 = 1 The odd and even members of the sequences are calculated slightly differently. So, for k = 0, 1, 2, . . . x2k+1 = 3y2k – 4x2k x2k+2 = 4y2k+1 – 3x2k+1 y2k+1 = 4y2k + 3x2k y2k+2 = 3y2k+1 + 4x2k+1 This gives: x1 = 3*1 – 4*0 = 3, y1 = 4*1 + 3*0 = 4 x2 = 4*4 – 3*3 = 7, y2 = 3*4 + 4*3 = 24 x3 = 3*24 – 4*7 = 44, y3 = 4*24 + 3*7 = 117 x4 = 4*117 – 3*44 = 336, y4 = 3*117 + 4*44 = 527 and we can easily verify that 3362 + 5272 = 11896 + 277,729 = 390,625 = 6252 Pythagorean Triangles with side 5N The Pythagorean triangles so far discovered are: [ 3, 4, 5 ], [ 7, 24, 25 ], [ 44, 17, 125 ], [ 336, 527, 625 ] Multiply them by 125, 25 and 5 to get: [ 375, 500, 625 ], [ 175, 600, 625 ], [ 220, 585, 625 ], [ 336, 527, 625 ] If we have a quarter circle with radius 625, then the points on it with integer coefficients are (in descending x order) ( 625, 0 ), ( 600, 175 ), ( 585, 220 ), ( 527, 336 ), ( 500, 375 ), ( 375, 500 ), ( 336, 527 ), ( 220, 585 ), ( 175, 600 ), ( 0, 625 ) The x-difference and y-difference numbers are: ( 25, 175 ), ( 15, 45 ), ( 58, 116 ), ( 27, 39 ) – all twice, and (125, 125) So the lengths of the sides are 2 * (√31250 + √2250 + √13456 + √2250 ) + √31250 = 2 * (176.777 + 47.434 + 129.692 + 47.434) + 176.777 = 979.451 So the approximation to π is (2/625) * 979.451 = 3.1342432 Shanks' Method for Improving Accuracy of π Suppose that we know π to n significant digits. Then Daniel Shanks (1961) showed how to calculate π to 3n significant digits. Suppose p0 is our best estimate of π and the error is ε so that p0 = π + ε Recall that sin (π + ε) = - sin ε Calculate p1 = p0 + sin p0 Then p1 = π + ε + sin (π + ε) = π + ε – sin ε = π + ε – (ε – ε3/3! + ε5/5! – ε7/7! + . . .) = π + ε3/6 - . . . So if ε, the error in p0, is less than 10-n , then ε3/6, the error in p1 will be less than 10-3n. sin x = x – x3/3! + x5/5! – x7/7! + . . . Where x = 3, the first few terms will be quite large and the value will fluctuate wildly, but quite soon it will settle down close to its final value of 0.1411200 (bottom right corner) N xN N! xN/N! sum 1 3 1 3.0 3.00 3 27 6 -4.5 -1.5 5 243 120 7 2187 5040 -0.4339286 0.0910714 9 19683 11 177147 362880 2.025 0.525 0.0542411 0.1453125 39916800 -0.0044379 0.1408745 13 1594323 6227020800 0.0002560 0.1411306 15 14348907 1307674368000 -0.0000110 0.1411196 17 129140163 355687428096000 0.0000004 0.1411200 Shanks' Method for Improving Accuracy of π If p0 , our best estimate for π, is 3.0, then we can calculate p1 p1 = p0 + sin p0 = 3.0 + sin 3.0 = 3.0 + 0.14112000805986722210074480280811 = 3.14112000805986722210074480280811 now calculate p2 = p1 + sin p1 sin p1 = 0.00047264551232833663414376533276947 p2 = 3.1415926535721955587348885681409 now calculate p3 = p2 + sin p2 sin p2 = 0.000000000017597679727754815138622229 p3 = 3.1415926535897932384626433832795 compare with the accepted value π = 3.1415926535897932384626433832795 All about arctan (x) and calculating π Defined as the inverse of the trigonometric function tan( ) So, if x = tan (θ), then θ = arctan(x) And π/4 = 45° = arctan (1) Angles can be combined like this: arctan(x) + arctan(y) = arctan( (x + y)/(1 – xy) ) and so: 𝑎 𝑐 𝑎𝑑 + 𝑏𝑐 𝑎𝑟𝑐𝑡𝑎𝑛 + 𝑎𝑟𝑐𝑡𝑎𝑛 = 𝑎𝑟𝑐𝑡𝑎𝑛 𝑏 𝑑 𝑏𝑑 − 𝑎𝑐 Series expansion for arctan (x) arctan (x) = x – x3/3 + x5/5 – x7/7 + . . . The series converges rapidly if x is small, and a lot less than 1. There are many formulas for π/4 in terms of arctan, eg π/4 = arctan(1/2) + arctan(1/3) 𝒙𝟑 𝒙𝟓 𝒙𝟕 𝐏𝐫𝐨𝐨𝐟 𝐨𝐟 𝒂𝒓𝒄𝒕𝒂𝒏 𝒙 = 𝒙 − + − … 𝟑 𝟓 𝟕 Start with the derivative of a quotient: 𝑑 𝑢 𝑣 𝑣 𝑑𝑢 𝑑𝑣 −𝑢 𝑑𝑥 𝑑𝑥 𝑣2 𝑢 𝑑𝑦 if 𝑦 = then = = 𝑣 𝑑𝑥 𝑑𝑥 set u = sin x and v = cos x 𝑠𝑖𝑛 𝑥 2 𝑥 + 𝑠𝑖𝑛2 𝑥 𝑑 𝑑(𝑡𝑎𝑛 𝑥) 𝑐𝑜𝑠 1 𝑐𝑜𝑠 𝑥 2 𝑥 = 1 + 𝑡𝑎𝑛2 𝑥 = = = = 𝑠𝑒𝑐 𝑑𝑥 𝑑𝑥 𝑐𝑜𝑠 2 𝑥 𝑐𝑜𝑠 2 𝑥 ---------------------------------------------------------------------------- now if y = arctan(x), then x = tan y and or integrating, 𝑑𝑥 = 1 + 𝑡𝑎𝑛2 𝑦 = 1 + 𝑥 2 𝑑𝑦 𝑑𝑦 1 2 + 𝑥4 − 𝑥6 + ⋯ = = 1 − 𝑥 𝑑𝑥 1+𝑥 2 𝑦 = 𝑎𝑟𝑐𝑡𝑎𝑛 𝑥 𝑥3 𝑥5 𝑥7 =𝑥− + − +⋯ 3 5 7 Showing how π/4 = arctan(1/2) + arctan(1/3) A 3 x 2 grid of unit squares. Triangle ABC has angles of 45° and 90° and 45° = π/4 So angle CAB is π/4 and CAD = φ and DAE = θ and so π/4= θ + φ tan θ = DE/AE = 1/3 and tan φ = CD/AC = 1/2 so arctan(1/3) = θ and arctan(1/2) = φ hence π/4 = arctan(1/2) + arctan(1/3) π/4 = arctan(1/2) + arctan(1/5) + arctan(1/8) Using this 16x10 grid, Carl Frederick Gauss (1777-1855) used a similar technique to show that π/4 = arctan(1/2) + arctan(1/5) + arctan(1/8) With the help of Zacharias Dahse, a lightning fast calculator, he used this formula to compute π to 200 decimal places. π/4 = 2 arctan(1/3) + arctan(1/7) Grid is 21 units wide by 15 high. Pink and green triangles have sides in the ratio 1:3. Cyan one is 1:7 π/4 = 2 arctan(1/2) - arctan(1/7) Grid is 30 units wide by 24 high. Pink and green triangles have sides in the ratio 1:2. Cyan one is 1:7 Finding a good arctan formula for 𝝅 The two best-known arctan formulas for π are: π 1 1 = arctan + arctan 4 2 3 π 1 1 = 4 arctan − arctan 4 5 239 For quicker convergence, we would like to have the arctan arguments as small as possible. Can we find a better formula? Assume that the formula will be something like this: π 𝑏 𝑒 = 𝑎 arctan ± 𝑑 arctan 4 𝑐 𝑓 where a, b, c, d, e, f are integers and b/c and e/f are both small numbers. This implies that a, c, d and f are large integers and b and e are small integers. What is the best strategy for finding a suitable set of numbers? Finding a good arctan formula for 𝝅 We are looking for suitable integer values of a, b, c, d, e, f in: π 𝑏 𝑒 = 𝑎 𝑎𝑟𝑐𝑡𝑎𝑛 ± 𝑑 𝑎𝑟𝑐𝑡𝑎𝑛 4 𝑐 𝑓 Assuming that a large, fast computer is available, here is one way of finding a set of integers. if θ = a arctan(b/c) generate a large number of sets of numbers of the form [a, b, c, θ] and sort these sets into ascending values of θ. Take one of the sets [a1, b1, c1, θ1] and look for a suitable matching set [a2, b2, c2, θ2] so that θ2 = π/4 - θ1 If a suitable value exists, it can be quickly found because all the θ values are in ascending order. It turns out that there are very few suitable sets of a, b, c, d, e, f The best one for numbers under 1000 is 5, 29, 278, 7, 3, 79 Finding a good arctan formula for 𝝅 π 𝑏 𝑒 = 𝑎 arctan ± 𝑑 arctan 4 𝑐 𝑓 The best set of values of a, b, c, d, e, f is 5, 29, 278, 7, 3, 79 so: π 29 3 = 5 arctan + 7 arctan 4 278 79 The arguments 29/278 and 3/79 are small, just 0.1043 and 0.0380 So we can expect rapid convergence. A quick check (using the Windows 32 digit Scientific Calculator): 5 arctan(29/278) = 0.51970304707924787518575118474499 7 arctan(3/79) = 0.26569511631820043442990966107489 making π/4 = 0.78539816339744830961566084581988 multiply by 4, so π = 3.1415926535897932384626433832795 correct to 32 digits. some arctan formulas for calculating π π/4 = arctan(1) (very slow to converge) π/4 = arctan(1/2) + arctan(1/3) (easy to explain but also quite slow to converge) π/4 = 4 * arctan(1/5) - arctan(1/239) (Machin's formula, the first of the "practical" ones) π/4 = 12 * arctan(1/38) + 20 * arctan(1/57) + 7 * arctan(1/239) + 24 * arctan(1/268) (a formula with small values for the arctan arguments, giving fast convergence) Devising new arctan formulas for π/4 The formulas that we already know about are these: 𝜋 1 1 = arctan + arctan 4 2 3 𝜋 1 1 = 2 arctan + arctan 4 3 7 𝜋 1 1 = 4 arctan − arctan 4 5 239 They all seem to have the general form: 𝜋 1 𝑐 = 𝑛 − 1 arctan + arctan 4 𝑛 𝑑 What would they look like for other values of n? Devising new arctan formulas for π/4 Investigating the formula 𝜋 1 𝑐 = 𝑛 − 1 𝑎𝑟𝑐𝑡𝑎𝑛 + 𝑎𝑟𝑐𝑡𝑎𝑛 4 𝑛 𝑑 An obvious question - How did John Machin (1686 – 1751) derive his famous formula? 𝜋 1 1 = 4 𝑎𝑟𝑐𝑡𝑎𝑛 − 𝑎𝑟𝑐𝑡𝑎𝑛 4 5 239 Probably by repeatedly subtracting arctan(1/5) from arctan(1/1) Recall that 𝑎 𝑐 𝑎𝑑 + 𝑏𝑐 arctan + arctan = arctan 𝑏 𝑑 𝑏𝑑 − 𝑎𝑐 Then: arctan( 1 / 1 ) - arctan( 1 / 5 ) = arctan( 2 / 3 ) arctan( 2 / 3 ) - arctan( 1 / 5 ) = arctan( 7 / 17 ) arctan( 7 / 17 ) - arctan( 1 / 5 ) = arctan( 9 / 46 ) arctan( 9 / 46 ) - arctan( 1 / 5 ) = arctan( -1 / 239 ) 𝜋 1 𝑐 = 𝑛 − 1 𝑎𝑟𝑐𝑡𝑎𝑛 + 𝑎𝑟𝑐𝑡𝑎𝑛 4 𝑛 𝑑 What about other values of n, such as 4, 6, 7 etc arctan( 1 / 1 ) - arctan( 1 / 4 ) = arctan( 3 / 5 ) arctan( 3 / 5 ) - arctan( 1 / 4 ) = arctan( 7 / 23 ) arctan( 7 / 23 ) - arctan( 1 / 4 ) = arctan( 5 / 99 ) arctan( 1 / 1 ) - arctan( 1 / 6 ) = arctan( 5 / 7 ) arctan( 5 / 7 ) - arctan( 1 / 6 ) = arctan( 23 / 47 ) arctan( 23 / 47 ) - arctan( 1 / 6 ) = arctan( 91 / 305 ) arctan( 91 / 305 ) - arctan( 1 / 6 ) = arctan( 241 / 1921 ) arctan( 241 / 1921 ) - arctan( 1 / 6 ) = arctan( -475 / 11767 ) So 𝜋 1 475 = 5 arctan − arctan 4 6 11767 Or, using the last but one line: 𝜋 1 241 = 4 arctan + arctan 4 6 1921 𝜋 1 𝑐 = 𝑚 𝑎𝑟𝑐𝑡𝑎𝑛 + 𝑎𝑟𝑐𝑡𝑎𝑛 4 𝑛 𝑑 The original concept of m = (n - 1) works for some values of n 𝜋 1 5 = 3 𝑎𝑟𝑐𝑡𝑎𝑛 + 𝑎𝑟𝑐𝑡𝑎𝑛 4 4 99 But it is best modified to m = (n-2) or (n-3) or even more to get the smallest value for c/d (a computer was used to derive these big numbers) π/4 = 5 arctan ( 1 / 7 ) + arctan ( 237 / 3116 ) π/4 = 6 arctan ( 1 / 8 ) + arctan ( 15247 / 388079 ) π/4 = 7 arctan ( 1 / 9 ) + arctan ( 4765 / 441284 ) π/4 = 8 arctan ( 1 / 10 ) – arctan ( 1758719 / 147153121 ) or even the monster: π/4 = 16 arctan( 1 / 20 ) - arctan (13176476709447727679 / 945426570789006031681) Evaluating the monster formula π/4 = 16 arctan ( 1 / 20 ) - arctan (13176476709447727679/ 945426570789006031681) derived by repeatedly subtracting arctan (1/20) from arctan (1/1) 13176476709447727679/ 945426570789006031681 = 0.01393707043631246268103774635514 whose arctan is 0.01393616815363587294443974673764 arctan(1/20) is 0.04995839572194276141000628703484 times 16 0.79933433155108418256010059255752 minus 0.01393616815363587294443974673764 0.78539816339744830961566084581988 times 4 to get π 3.1415926535897932384626433832795 Summary of the arctan formulas that are commonly used for π/4 (1) the ones with 2 terms π/4 = arctan(1/2) + arctan (1/3) 2 arctan(1/3) + arctan (1/7) 2 arctan(1/2) - arctan (1/7) 4 arctan(1/5) - arctan (1/239) 5 arctan(1/7) + 2 arctan (3/79) 5 arctan(29/278) + 7 arctan (3/79) (2) arctan formulas for π/4 with 3 terms π/4 = arctan(1/2) + arctan (1/5) + arctan (1/8) = 5 arctan(1/6) - arctan (1/43) - 2 arctan (1/117) = 5 arctan(1/7) + 4 arctan(1/53) + 2 arctan(1/4443) = 6 arctan(1/8) + 2 arctan (1/57) + arctan (1/239) = 8 arctan(1/10) - arctan(1/239) - 4 arctan(1/515) 16 arctan(1/21) + 3 arctan(1/239) + 4 arctan(3/1042) for some reason, arctan(1/57) and arctan(1/239) appear frequently in the arctan formulas (3) arctan formulas for π/4 with four terms π/4 = 22 arctan(1/28) + 2 arctan (1/443) - 5 arctan (1/1393) - 10 arctan(1/11018) π/4 = 24 arctan(1/36) + 8 arctan (1/57) - 5 arctan (1/239) - 12 arctan(1/23382) π/4 = 12 arctan(1/38) + 20 arctan (1/57) + 7 arctan (1/239) + 24 arctan(1/268) π/4 = 24 arctan(1/43) + 20 arctan (1/57) - 12 arctan (1/117) - 5 arctan(1/239) π/4 = 12 arctan(1/49) + 32 arctan (1/57) - 5 arctan (1/239) + 12 arctan(1/110443) π/4 = 44 arctan(1/57) + 7 arctan (1/239) - 12 arctan (1/682) + 24 arctan(1/12943) (4) an arctan formula for π/4 with five terms π/4 = 88 arctan (1/172) + 51 arctan (1/239) + 32 arctan (1/682) + 44 arctan (1/5357) + 68 arctan (1/12943) Note that the arguments in brackets are all very small numbers so they should converge rapidly. However it is necessary to do five calculations The trillion digit calculation of π In 2002, Yasumasa Kanada calculated π to 1.2 trillion digits. There was only one way to check the accuracy of the calculation. Do it twice, using different formulas, and compare the two results. He used the two arctan identities: The repeated use of 1/57 and 1/239 means that their values can be used twice, thereby saving a lot of computing time. Using the (32 digit) Windows calculator, we can check the sums. Checking the (32 digit) calculation of π = 0.24486396823845703731274008015512 + 0.56134592183687960900789657403783 - 0.02092038001037361932269107479643 + 0.00010865333248528261771526642336 = 0.78539816339744830961566084581988 = 0.77185064252570946238585778930201 + 0.02928853201452306705176750471500 - 0.01759529530814347689864424032988 + 0.00185428416535925707667979213274 = 0.78539816339744830961566084581987 Summary of the arctan formulas • they are usually used for calculating π/4 since π/4 = arctan(1) • there are many formulas that can be used, with 2, 3, or more arctan terms. • The first practical one was Machin's formula π/4 = 4 arctan(1/5) – arctan(1/239) • Gregory's sequence is used to calculate each of the angles arctan (x) = x – x3/3 + x5/5 – x7/7 + . . . • The formulas are suitable for calculating π to enormous numbers of digits • calculations can be checked by using two different formulas Buffon's Needle Suppose some needles of unit length are scattered at random on a grid of lines spaced one unit apart. What proportion of the needles will cross a grid line? Theoretically it is 2/π or 0.637 The problem can be analyzed by considering one needle and two lines, at x-coordinates 0 and 1. One end of the needle is at the point (x1, y1) and it is at an angle θ. The numbers x1, y1 and θ are chosen at random, with: 0 < x1 < 1, 0 < y1 < 1, 0 < θ < 2π Then the other end is at (x2, y2), where: x2 = x1 + cos θ y2 = y2 + sin θ Then the needle crosses a grid line if x2 < 0 or x2 > 1 The Buffon Needle experimental calculation of π using a parallel line grid or a square grid The spacing between the lines is the same as the length of the needle. For the line grid, the probability of a needle crossing a line is: 2/π, or about 0.6366 For the square grid, it is 3/π, or about 0.9549 A simple Python program can show this #!/usr/bin/python # buffon_demo.py calculate pi using Buffon import math import random def main(): needles = 1000000 count = 0 two_pi = 2 * math.pi for j in range (needles): x1 = random.random() theta = two_pi * random.random() x2 = x1 + math.cos(theta) if x2 < 0 or x2 > 1: count = count + 1 ratio = count/needles print (count, "of", needles, "needles crossing lines") print ("estimate of pi, (2/ratio)", 2/ratio) if __name__ == "__main__": main() Result of running the Buffon Needle program with 1000000 needles (six times) Console output: 637049 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.1394759272834585 636887 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.140274491393293 636459 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.1423862338343866 636760 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.140900810352409 636022 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.144545314470254 637219 of 1000000 needles crossing lines estimate of pi, (2/ratio) 3.138638364518321 Python program for the Buffon experiment using a square grid As well as calculating x2 = x1 + cos θ, we also need y2 = y1 + sin θ The needle crosses a grid line if x2 < 0 or x2 > 1 or y2 < 0 or y2 > 1 Probability is 3/π, so π = 3/(ratio of crossings to total needles) needles = 1000000 count = 0 two_pi = 2 * math.pi for j in range (needles): x1 = random.random() y1 = random.random() theta = two_pi * random.random() x2 = x1 + math.cos(theta) y2 = y1 + math.sin(theta) if x2 < 0 or x2 > 1 or y2 < 0 or y2 > 1: count = count + 1 ratio = count/needles print ("count, needles, ratio =", count, needles, count/needles) print ("estimate of pi, (3/ratio)", 3/ratio) Result of running the Buffon Grid program with 1000000 needles (six times) Console output: count, needles, ratio = 955091 1000000 0.955091 estimate of pi, (3/ratio) 3.1410619511648625 count, needles, ratio = 954705 1000000 0.954705 estimate of pi, (3/ratio) 3.142331924521187 count, needles, ratio = 954879 1000000 0.954879 estimate of pi, (3/ratio) 3.141759322385349 count, needles, ratio = 954812 1000000 0.954812 estimate of pi, (3/ratio) 3.141979782407427 count, needles, ratio = 954760 1000000 0.95476 estimate of pi, (3/ratio) 3.142150907034228 count, needles, ratio = 955198 1000000 0.955198 estimate of pi, (3/ratio) 3.140710093614099 Calculate π from random points in a square Scatter a large number of points (x, y) at random in a unit square. Count the proportion of them where x² + y² < 1 This will equal π/4. A suitable Python program looks like this: p = 10000000 print ("Calculate PI from", p, "random points") count = 0 for jj in range(p): x = random.random() y = random.random() if x*x + y*y < 1: count = count + 1 print ("count =", count, "\nPI =", 4*count/p) Calculate π from random points in a square or cube The computer program finds that the ratio of points in the quadrant to those in the unit square is: 0.7854 We know (from school geometry) that this is π/4, so π = 0.7854 * 4 = 3.1416 Likewise, in three dimensions, the computer can calculate the ratio of points in an eighth of a cube to those in a unit cube. It is 0.5236. We know (also from school geometry) that the volume of a sphere is (4/3)πr3 So (1/8)*(4/3)π = 0.5236 and therefore π = 0.5236 * 6 = 3.1416 The Volumes of Hyperspheres We know (from school geometry), that the area of a circle is πr2 And the volume of a sphere is (4/3)πr3 By plotting 100,000,000 random points in a unit square or unit cube and using these formulas, we estimated π to be about 3.1416. Knowing the value of π can we use the same techniques to derive plausible FORMULAS for hyperspheres? If Vn is the volume of a hypersphere in n dimensions, with unit radius (and writing the "area" in two dimensions as V2), we have V2 = π and V3 = (4/3)π So it is reasonable to assume that Vn = (a/b)π and we just have to find (a/b) for each dimension n. The Volumes of Hyperspheres If Rn is the ratio of an n-dimensional slice to an n-dimensional cube (as calculated by the computer), we had R2 = 0.7854 and R3 = 0.5236. Each of these needs to be multiplied by 2n where n is the dimension: So 22 * R2 = 4 * 0.7854 = 3.1416 = π and 23 * R3 = 8 * 0.5236 = 4.1888 = (4/3)π The computer calculates R4 to be 0.30845 so we expect 24 * R4 = (a/b)π or a/b = 16 * 0.30845 / 3.1416 = 1.5709 So what is the nearest rational fraction to 1.5709? (11/7) is 1.5714, but we believe our fraction to be 1.5709 ± 0.0001 Not good enough. Our expectation is wrong, maybe we need a π2 factor The Volumes of Hyperspheres The expectation that V4 = (a/b) π has turned out to be wrong. Lets try V4 = (a/b) π2 , so 24 * R4 = (a/b)π2 or a/b = 16 * 0.30845 / 3.14162 = 0.50000 Which shows immediately that: V4 = (1/2)π2 The computer calculates R5 to be 0. 16449 So let's try V5 = (a/b) π2 , so 25 * R5 = (a/b)π2 or a/b = 32 * 0.16449 / 3.14162 = 0.5333 very close to 8/15, so V5 = (8/15)π2 Calculating volumes of n-dimensional hyperspheres By scattering random points in unit hypercubes of up to 10 dimensions, we get the following ratios: R2 = 0.7853970874 R3 = 0.5235924897 R4 = 0.3084200631 R5 = 0.1644924921 R6 = 0.0807471966 R7 = 0.0369103398 R8 = 0.0158542389 R9 = 0.0064431922 R10 = 0.0024908857 (a laptop computer can find these numbers in a few minutes) So it should be possible to derive formulas for the volumes of the hyperspheres Calculating volumes of n-dimensional hyperspheres So far, we have: V2 = π, V3 = (4/3π, V4 = (1/2)π2, V5 = (8/15)π2 What about V6 – will it have a factor based on π, or π2 or even π3 ? R6 = 0.0807435 Try using just π. Then 26 * R6 = (a/b)π or a/b = 64 * 0.0807435 / 3.1416 = 1.64489 closest fraction is 51/31 = 1.6452 (not quite close enough) Try using just π2. Then 26 * R6 = (a/b)π2 or a/b = 64 * 0.0807435 / 3.14162 = 0.52359 Closest fraction is 11/21 = 0.52381 (not quite close enough) Try using just π3. Then 26 * R6 = (a/b)π3 or a/b = 64 * 0.0807435 / 3.14163 = 0.16666 = 1/6 V6 = (1/6)π3 Calculating volumes of n-dimensional hyperspheres So far, we have: V2 = π, V3 = (4/3)π, V4 = (1/2)π2, V5 = (8/15)π2, V6 = (1/6)π3 The computer has calculated R7 as 0.036912774 It looks like V7 will be based on π3. Then 27 * R7 = (a/b)π3 or a/b = 128 * 0.036912774 / 3.14163 = 0.152383 = 16/105 Giving V7 = (16/105)π3 Having got to this point, it ought to be fairly easy to derive the formulas for V8, V9 and V10 formulas for V8, V9 and V10 Recall that: R8 = 0.015858087, R9 = 0.006442008 R10 = 0.002490457 Assume that V8 will be based on π4. Then 28 * R8 = (a/b)π4 or a/b = 256 * 0.0158581 / 3.14164 = 0.0416765 = 1/24 V8 = (1/24)π4 Assume that V10 will be based on π5. Then 210 * R8 = (a/b)π5 or a/b = 1024 *0.002490457/ 3.14165 = 0.0083335 = 1/120 V10 = (1/120)π5 V9 is more difficult. Assume that it will be based on π4. Then 29 * R9 = (a/b)π4 or a/b = 512 * 0.0064420 / 3.14164 = 0.0338498 Best fraction (in this example) is 11/235, but true value is 32/945 so V9 = (32/945)π4 Summarizing the results for V2 to V10 A pattern begins to emerge for the volumes of the hyper spheres: V2 = π r2 V4 = (1/2) π2 r4 V6 = (1/6) π3 r6 V8 = (1/24) π4 r8 V10 = (1/120) π5 r10 = ( 1/6! ) π5 r10 V3 = (4/3) π r3 V5 = (8/15) π2 r5 V7 = (16/105) π3 r7 V9 = (32/945) π4 r9 = (25/3 * 5 * 7 * 9) π4 r9 = ( 29 * 4! / 9! ) π4 r9 For even numbered dimensions, 2n: V(2n) = (1/!n) πn r2n For odd numbered dimensions 2n+1 V(2n+1) = (2(2n+1) * n!/(2n+1)!) πn r(2n+1) Proofs that π is irrational The approximation 22/7 is a useful one for most practical purposes And 355/113 is even better (being 3.14159292 while the true value is 3.14159265). But π cannot be accurately expressed as a rational fraction A/B. • The first proof came from Lambert in 1761 using the properties of continued fractions • In 1873, Hermite proved that π2 is irrational. • And in about 1960, Ivan Niven published a one-page article with the title "A simple proof that π is irrational" • Subsequently Presh Talwalkar published a (rather longer) explanation of the Ivan Niven paper (recognizing that "simple" may not be the most appropriate description!) Outline of Niven's Proof that π is irrational (as explained by Presh Talwalkar) First, let's assume that π is a rational fraction a/b Then, using the numbers a and b, create a function f(x), of degree 2n (where n is a number yet to be defined) The function is defined so that f(0) = 0 and also f(a/b) = 0, so that f(π) = 0, since we are assuming π = a/b Now create all the derivatives of f(x), which we can call f'(x), f''(x) etc, up to f(2n) (x). Anything beyond f(2n)(x) will be zero. From this set of derivatives, form another function g(x) We can then demonstrate that g is an integer greater that 0 and also less than 1. This is obviously a contradiction. So π is not a rational fraction. Willebrord Snell and Christiaan Huygens Willebrord Snell is best known for his contribution to optics in Snell's Law of Refraction But he also developed a very accurate method of calculating π He drew two very similar diagrams. In each one there is a circle, radius r, a line BO, extended to X or Y, a point F and a tangent at B going to G or H. Snell suspected, and Huygens proved, that the length of the arc BF lies between BH and BG. This gave them a quick way to calculate π to a large number of digits. Euler's equation for π2 (slide 1 of 3) Euler solved the "Basel problem" which had defeated many and showed that 𝟏 𝟏 𝟏 𝟏 𝝅𝟐 + 𝟐+ 𝟐+ 𝟐+⋯= 𝟐 𝟏 𝟐 𝟑 𝟒 𝟔 Here is a simplified (ie not very rigorous) version of his proof If f(x) is a polynomial in x, suppose roots of the equation f(x) = 0 are: r0, r1, r2, . . . etc suppose also that r0 = 0 and all the other roots are non-zero. Then: f(x) = Cx(x – r1)(x – r2) . . . where C is some constant 𝒙 we can re-write each factor (x – r) as −𝒓(𝟏 − ) and so 𝒓 𝒙 𝒙 𝒙 𝒇 𝒙 = 𝑲𝒙 𝟏 − 𝟏− 𝟏− … 𝒓𝟏 𝒓𝟐 𝒓𝟑 where K is a suitable constant, incorporating all the (-r) constants Euler's equation for π2 (slide 2 of 3) recall that f(x) can be written as: 𝒙 𝒇 𝒙 = 𝑲𝒙 𝟏 − 𝒓𝟏 𝒙 𝟏− 𝒓𝟐 𝒙 𝟏− … 𝒓𝟑 the function sin(x) is zero where x = 0, π, -π, 2π, -2π, 3π, -3π, etc. So if it is expressed as a polynomial, these will be its roots and it can be written as: 𝑥 x 𝑥 x 𝑥 x sin 𝑥 = 𝐾𝑥 1 − 1+ 1− 1+ 1− 1+ … π π 2π 2π 3π 3π combining pairs of factors, we get: 𝑥2 sin 𝑥 = 𝐾𝑥 1 − 2 2 1 π 𝑥2 1− 2 2 2 π 𝑥2 1− 2 2 … 3 π Euler's equation for π2 (slide 3 of 3) We have shown that: 𝒙𝟐 𝒔𝒊𝒏 𝒙 = 𝑲𝒙 𝟏 − 𝟐 𝟐 𝟏 𝝅 𝒙𝟐 𝟏− 𝟐 𝟐 𝟐 𝝅 𝒙𝟐 𝟏− 𝟐 𝟐 … 𝟑 𝝅 but we know that 𝒙𝟑 𝒙𝟓 𝒙𝟕 𝒔𝒊𝒏 𝒙 = 𝒙 − + − +⋯ 𝟑! 𝟓! 𝟕! equating the coefficients of x shows that K = 1 then, equating the coefficients of x3 shows that 𝟏 𝟏 𝟏 𝟏 𝟏 − = − 𝟐 𝟐− 𝟐 𝟐− 𝟐 𝟐− 𝟐 𝟐+⋯ 𝟔 𝟏 𝝅 𝟐 𝝅 𝟑 𝝅 𝟒 𝝅 or 𝝅𝟐 𝟏 𝟏 𝟏 𝟏 = 𝟐+ 𝟐+ 𝟐+ 𝟐+⋯ 𝟔 𝟏 𝟐 𝟑 𝟒 Euler's Calculation of π2 (on one slide) suppose f(x) is an infinite polynomial representing sin(x) Then when f(x) = 0, x = 0, ±π, ±2π, ±3π, etc So f(x) can be written as: f(x) = x (x – π)(x + π) (x – 2π)(x + 2π) (x – 3π)(x + 3π) . . . or f(x) = x (x2 – π2) (x2 – 22π2) (x2 – 32π2) . . . Introducing a constant K, this can be re-written as: f(x) = Kx (1 – x2/12π2) (1 – x2/22π2) (1 – x2/32π2) . . . Now f(x) / x = K + terms in x2 and above but f(x) / x = sin(x) / x and this tends to 1 as x tends to 0, so K = 1 Extract the coefficient of x3 from f(x), it is - 1/12π2 - 1/22π2 - 1/32π2 - 1/42π2 - 1/52π2 - . . . but the expansion of sin(x) is x – x3/3! + x5/5! – x7/7! + . . . So the coefficient of x3 from sin(x) is -1/6, so: π2 /6 = 1/12 + 1/22 + 1/32 + 1/42 + 1/52 + 1/62 + . . . Demonstration of Euler's Calculation of π2 The formula is: π2 /6 = 1/12 + 1/22 + 1/32 + 1/42 + . . . Unfortunately, this series converges rather slowly. It is easy to program a computer to calculate these terms. Using just the first 10 terms, here is what we get: π2/6 = 1.00000 + 0.25000 + 0.111111 + 0.062500 + 0.04000 + 0.027778 + 0.020408 + 0.015625 + 0.012346 + 0.010000 = 1.549768 so π2 = 9.298606 and π = 3.049362 The values of π for different numbers of terms: 100 terms gives 3.1320765318 1000 terms gives 3.1406380562 10000 terms gives 3.1414971639 100000 terms gives 3.1415831043 1000000 terms gives 3.1415916987 10000000 terms gives 3.1415925581 actual value of π is 3.1415926536 Euler's calculations of π using the Zeta function The general definition of the Zeta function is We are interested in the Zeta function for positive integer values, usually even ones, and especially powers of 2: Zeta(1) = 1/1 + 1/2 + 1/3 + . . . (it does not converge) Zeta(2) = 1/12 + 1/22 + 1/32 + 1/42 + . . . ( = π2 / 6 ) Zeta(3) = 1/13 + 1/23 + 1/33 + 1/43 + . . . ( no easy formula ) Zeta(4) = 1/14 + 1/24 + 1/34 + 1/44 + . . . ( = π4 / 90 ) Zeta(6) = 1/16 + 1/26 + 1/36 + 1/46 + . . . ( = π6 / 945 ) Zeta(8) = 1/18 + 1/18 + 1/18 + 1/18 + . . . ( = π8 / 9450 ) Zeta(16) = 1/116 + 1/216 + 1/316 + 1/416 + . . . = 3617 π16/ 325 641 566 250 Zeta(32) = 1/132 + 1/232 + 1/332 + 1/432 + . . . = 7709321041217 π32 / 62490220571022341207266406250 Recall that Zeta(32) = 1/132 + 1/232 + 1/332 + 1/432 + . . . = 7709321041217 π32 / 62490220571022341207266406250 1/132 = 1.0 1/232 = 0.00000000023283064365386962890625 1/332 = 0.00000000000000053965952773542901 1/432 = 0.00000000000000000005421010862427 1/532 = 0.00000000000000000000004294967296 1/632 = 0.00000000000000000000000012564927 sum = 1.00000000023283118336765054828182 62490220571022341207266406250 / 7709321041217 = 8,105,800,788,023,426.4635374292628855 multiply by 1.000000000232831183367650548282 8,105,800,789,910,709.6531553579820859 sqrt is 90,032,220.842933279567130768186585 sqrt is 9,488.5310160705740071285755017288 sqrt is 97.409091034002437236440332677526 sqrt is 9.8696044010893586188344909993098 sqrt is 3.1415926535897932384626433831894 Euler's Prime Number Series for π 𝝅𝟐 𝟏 𝟏 𝟏 𝟏 we recall that = 𝟐+ 𝟐+ 𝟐+ 𝟐+⋯ 𝟔 𝟏 𝟐 𝟑 𝟒 the equations are going to get complicated, so we write 1/N2 simply as gN and note that g1 = 1 and that gX * gY = gXY so π2/6 = g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10 + g11 + multiply by the second term, g2, and spread out g2* π2/6 = g2*g1 + g2*g2 + g2*g3 + g2*g4 + g2*g5 + or g2* π2/6 = g2 + g4 + g6 + g8 + g10 + subtract this second equation from the first equation (1-g2) * π2/6 = g1 + g3 + g5 + g7 + g9 + g11 + g13 + g15 + g17 + again, multiply by the second term, this time g3, and spread out g3*(1-g2) * π2/6 = g3*g1 + g3*g3 + g3* g5 + g3*(1-g2) * π2/6 = g3 + g9 + g15 + subtract this equation from the previous one: (1-g3)(1-g2) π2/6 = g1 + g5 + g7 + g11 + g13 + g17 + Euler's Prime Number Series for π 𝝅𝟐 𝟏 𝟏 𝟏 𝟏 we recall that starting with = 𝟐+ 𝟐+ 𝟐+ 𝟐+⋯ 𝟔 𝟏 𝟐 𝟑 𝟒 or π2/6 = g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10 + g11 + we first removed multiples of g2, then g3 to get: (1-g3)(1-g2) π2/6 = g1+g5+g7+ g11+ g13+ g17+ g19 + g23 + g25 each operation multiplies the left side by (1 – gN) and removes all the multiples of gN from the right. And N is always a prime number (otherwise it would already have been removed) so (1-g2)(1-g3)(1-g5)(1-g7)(1-g11)(1-g13)(1-g17) … π2/6 = g1 = 1 giving (for p = prime) ∞ 𝒑=𝟐 𝟏 𝟔 𝟏− 𝟐 = 𝟐 𝒑 𝝅 Euler's Prime Number Series for π ∞ 𝒑=𝟐 𝟏 𝟔 𝟏− 𝟐 = 𝟐 𝒑 𝝅 where p = prime Not a rapidly converging product, so 6 significant figures is enough: For the first 11 primes (ie 2 to 31), (1 – 1/p2) is: [2, 0.75], [3, 0.888889], [5, 0.96 ], [ 7, 0.979592], [11, 0.991736 ], [ 13, 0.994082], [ 17, 0.996540], [ 19, 0.997230], [23, 0.998110], [ 29, 0.998811], [ 31, 0.998959] product is 0.611706, then 6/product is 9.808634, so π= 3.131874 Using all the primes up to 997 (168 of them) we get a value for π of: 3.141393 only 4 or 5 significant digits Not very satisfactory for a lot of work! Euler's Prime Number Series for π Recall that Zeta(2) = π2/6 =1/12 + 1/22 + 1/32 + 1/42 + 1/52 + 1/62 + 1/72 + 1/82 + 1/92 + make a copy, multiply it by ( 1/22 ) and subtract from the original. This removes all the terms divisible by ( 1/22 ) so (1 – 1/22) π2/6 = 1/12 + 1/32 + 1/52 + 1/72 + 1/92 +1/112 + 1/132 + Same again, but with ( 1/32 ) This removes all the terms divisible by ( 1/32 ) so (1 – 1/22) (1 – 1/32) π2/6 = 1/12 + 1/52 + 1/72 +1/112 + 1/132 + Then ( 1/52 ) (1 – 1/22) (1 – 1/32) (1 – 1/52) π2/6 =1/12 + 1/72 +1/112 + 1/132 + Then ( 1/72 ), then (1/112 ), then ( 1/132 ) all through the primes So, in the end, all the terms on the right, except 1/12 , are gone (1 – 1/22) (1 – 1/32) (1 – 1/52) . . . (1 – 1/p2) . . . π2/6 = 1/12 or (1 – 1/22) (1 – 1/32) (1 – 1/52) . . . (1 – 1/p2) . . . = 6/π2 an infinite product of terms of the form (1 – 1/p2) where p is prime. Defining π without a circle It is possible to define π without a circle. if y = cos x, then π/2 is the first root where y = 0 and cos x can be defined by an infinite series and cos can also be defined as the solution of a differential equation: 𝑑2𝑦 2 = -y 𝑑𝑥 Clawson's Limit Equation for π In his book of "Mathematical Mysteries", Clawson gives, without proof, the following amazing equation for π Although the numbers involved may grow to be quite large, it should be possible to investigate the limit with a relatively simple computer program. The value of √(2π) is about: 2.506628274631000502415765284811 Clawson's Limit Equation for π The computer program to calculate these numbers is quite straightforward, but for n > 700, the factorial and power terms become very large and the computer is not able to handle them without special "large number" programming. The results are these: n = 50, π = 3.1520819617264695 n = 100, π = 3.1468329896120797 n = 200, π = 3.144211736418174 n = 400, π = 3.142901923001544 n = 700, π = 3.1423407408442308 (very slow convergence – and a lot of calculation!) Deriving π using Euler's Gamma Constant (not to be confused with Euler's number e, the logarithm base) Gamma is defined like this: the difference between a logarithm and a harmonic series. There is a long and complex Wikipedia entry: https://en.wikipedia.org/wiki/Euler%27s_constant and near the end of it, there is this curious equation: where N1(n) is the number of ones in the binary expression of the number n. And N0(n) is the number of zeroes. Since the number 87 in binary is 1010111, then N0(87) = 2 and N1(87) = 5. Not a difficult Python program to write! #!/usr/bin/python import math def bit_diff(number): n, n0, n1 = number, 0, 0 while n > 0: digit = n & 1 # rightmost bit n1 = n1 + digit n0 = n0 + (1-digit) n = n>>1 return n1-n0 def main(): sum, limit = 0, 2000 for n in range(1, limit+1): sum = sum + bit_diff(n)/(2*n*(2*n+1)) pi = 4/math.exp(sum) print ("value of pi with", limit, "terms =", pi) if __name__ == "__main__": main() Results of the Gamma calculation of π The convergence of the function is not particularly fast, even for very large values of n. Calculating π from the frequency of relatively prime numbers If two integers are chosen at random, the probability that they are relatively prime is 6/π². A Python program generated 10 000 000 pairs of numbers of size up to 100 000 000 and calculated their Greatest Common Divisor. This shows the result of running the program five times and counting the relatively prime pairs. #!/usr/bin/python # pi_relative_prime.py import math import random def main(): scope = 100000000 attempts = 10000000 count = 0 for jj in range(attempts): a = int(scope*random.random()) b = int(scope*random.random()) if math.gcd(a, b) == 1: count = count + 1 ratio = count/attempts pi_squared = 6/ratio pi = math.sqrt(pi_squared) print ("count, π², π", count, pi_squared, pi) if __name__ == "__main__": main()
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )