I Prefer Pi Corey Sinnamon Febuary 3, 2015 Big Day 3/14/15 Big - - PowerPoint PPT Presentation

i prefer pi
SMART_READER_LITE
LIVE PREVIEW

I Prefer Pi Corey Sinnamon Febuary 3, 2015 Big Day 3/14/15 Big - - PowerPoint PPT Presentation

I Prefer Pi Corey Sinnamon Febuary 3, 2015 Big Day 3/14/15 Big Day 3/14/15 Themes Big Day 3/14/15 Themes History Big Day 3/14/15 Themes History Irrationality and Transcendence Big Day 3/14/15 Themes History


slide-1
SLIDE 1

I Prefer Pi

Corey Sinnamon Febuary 3, 2015

slide-2
SLIDE 2

Big π Day

3/14/15

slide-3
SLIDE 3

Big π Day

3/14/15

Themes

slide-4
SLIDE 4

Big π Day

3/14/15

Themes

◮ History

slide-5
SLIDE 5

Big π Day

3/14/15

Themes

◮ History ◮ Irrationality and Transcendence

slide-6
SLIDE 6

Big π Day

3/14/15

Themes

◮ History ◮ Irrationality and Transcendence ◮ ζ(2) = ∞ n=1 1 n2 = π2 6

slide-7
SLIDE 7

Big π Day

3/14/15

Themes

◮ History ◮ Irrationality and Transcendence ◮ ζ(2) = ∞ n=1 1 n2 = π2 6 ◮ Series and Products for π

slide-8
SLIDE 8

Big π Day

3/14/15

Themes

◮ History ◮ Irrationality and Transcendence ◮ ζ(2) = ∞ n=1 1 n2 = π2 6 ◮ Series and Products for π ◮ Computation

slide-9
SLIDE 9

Machin-like Formulae

In 1706, John Machin gave the following formula for π π 4 = 4 arctan 1 5 − arctan 1 239

slide-10
SLIDE 10

Machin-like Formulae

In 1706, John Machin gave the following formula for π π 4 = 4 arctan 1 5 − arctan 1 239 Machin used this to calculate 100 digits of π using Gregory’s series for arctan, arctan x = x − x3 3 + x5 5 − x7 7 + · · ·

slide-11
SLIDE 11

Machin-like Formulae

In 1706, John Machin gave the following formula for π π 4 = 4 arctan 1 5 − arctan 1 239 Machin used this to calculate 100 digits of π using Gregory’s series for arctan, arctan x = x − x3 3 + x5 5 − x7 7 + · · · There are countless variations on Machin’s Formula, e.g. π 4 = arctan 1 2 + arctan 1 5 + arctan 1 8 π 4 = 5 arctan 1 7 + 2 arctan 3 79 π 4 = 12 arctan 1 38 + 20 arctan 1 57 + 7 arctan 1 239 + 24 arctan 1 268

slide-12
SLIDE 12

Machin-like Formulae

In a 1938 paper, Lehmer gave a simple method for comparing the computational complexity of arctan relations.

slide-13
SLIDE 13

Machin-like Formulae

In a 1938 paper, Lehmer gave a simple method for comparing the computational complexity of arctan relations. Consider the Gregory series for 1

x,

arctan 1 x = 1 x − 1 3x3 + 1 5x5 − · · ·

slide-14
SLIDE 14

Machin-like Formulae

In a 1938 paper, Lehmer gave a simple method for comparing the computational complexity of arctan relations. Consider the Gregory series for 1

x,

arctan 1 x = 1 x − 1 3x3 + 1 5x5 − · · · Lehmer observed that the number of terms that must be calculated to acquire n digits of π is approximately

n log x, since

x−i < 10−n ⇐ ⇒ i > n log10 x.

slide-15
SLIDE 15

Machin-like Formulae

Thus, given a Machin-like formula of the form kπ 4 =

n

  • i=1

ai arctan 1 mi Lehmer defined its measure as

n

  • i=1

1 log mi

slide-16
SLIDE 16

Machin-like Formulae

Thus, given a Machin-like formula of the form kπ 4 =

n

  • i=1

ai arctan 1 mi Lehmer defined its measure as

n

  • i=1

1 log mi Using the shorthand [x] = arctan 1

x, Lehmer computed the

measures of most of the interesting Machin-like formulae of the time.

slide-17
SLIDE 17

Machin-like Formulae

slide-18
SLIDE 18

Machin-like Formulae

Although they were not the lowest-measure relations, Lehmer recommended the following for practical computing, π 4 = 8 arctan 1 10 − arctan 1 239 − 4 arctan 1 515 π 4 = 12 arctan 1 18 + 8 arctan 1 57 − 5 arctan 1 239 Why?

slide-19
SLIDE 19

Machin-like Formulae

Lehmer recognized that this measure could be grossly inaccurate when a relation involves some repeated calculations. For example, in 1939 J. P. Ballantine observed that arctan 1 18 = 18( 1 325 + 2 3 · 3252 + 2 · 4 3 · 5 · 3253 + · · · ) arctan 1 57 = 57( 1 3250 + 2 3 · 32502 + 2 · 4 3 · 5 · 32503 + · · · )

slide-20
SLIDE 20

Machin-like Formulae

Lehmer recognized that this measure could be grossly inaccurate when a relation involves some repeated calculations. For example, in 1939 J. P. Ballantine observed that arctan 1 18 = 18( 1 325 + 2 3 · 3252 + 2 · 4 3 · 5 · 3253 + · · · ) arctan 1 57 = 57( 1 3250 + 2 3 · 32502 + 2 · 4 3 · 5 · 32503 + · · · ) This produces the lovely relation π = 864 18 arctan 1 18 + 1824 57 arctan 1 57 − 5 arctan 1 239, which (according to Ballantine) was the fastest known method for computing π to many digits.

slide-21
SLIDE 21

Monroe Calculator

slide-22
SLIDE 22

Infinite Products for πe and π

e

  • Z. A. Melzak (1961)
slide-23
SLIDE 23

Infinite Products for πe and π

e

  • Z. A. Melzak (1961)

lim

n→∞ V (Cn)/V (Sn) =

  • 2

πe

slide-24
SLIDE 24

Infinite Products for πe and π

e

Two simple products, π 2e =

  • n=1

(1 + 2 n)(−1)n+1n 6 πe =

  • n=2

(1 + 2 n)(−1)nn

slide-25
SLIDE 25

Infinite Products for πe and π

e

Two simple products, π 2e =

  • n=1

(1 + 2 n)(−1)n+1n 6 πe =

  • n=2

(1 + 2 n)(−1)nn But then π 6e =

  • n=2

(1 + 2 n)(−1)n+1n = πe 6

slide-26
SLIDE 26

Infinite Products for πe and π

e

Two simple products, π 2e =

  • n=1

(1 + 2 n)(−1)n+1n 6 πe =

  • n=2

(1 + 2 n)(−1)nn But then π 6e =

  • n=2

(1 + 2 n)(−1)n+1n = πe 6 What’s going on here?

slide-27
SLIDE 27

Infinite Products for πe and π

e

N

  • n=2

(1 + 2 n)(−1)n+1n

slide-28
SLIDE 28

Infinite Products for πe and π

e

N

  • n=2

(1 + 2 n)(−1)n+1n π 6e ≈ 0.1926212250 πe 6 ≈ 1.423289037

slide-29
SLIDE 29

Infinite Products for πe and π

e

Two not-as-simple products, π 2e = lim

N→∞ 2N

  • n=1

(1 + 2 n)(−1)n+1n 6 πe = lim

N→∞ 2N+1

  • n=2

(1 + 2 n)(−1)nn

slide-30
SLIDE 30

A Spigot Algorithm for π

Rabinowitz and Wagon (1995)

slide-31
SLIDE 31

A Spigot Algorithm for π

Rabinowitz and Wagon (1995) Presented an algorithm to compute digits of π that

◮ ”drips” digits of π one by one and does not use them

afterwards,

◮ is easy to implement, ◮ uses only integer arithmetic

slide-32
SLIDE 32

A Spigot Algorithm for π

Column Head ai

bi = i 2i+1

Column Number ci = 2.

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t- *s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s
slide-33
SLIDE 33

A Spigot Algorithm for π

Column Head ai

bi = i 2i+1

Column Number ci = 2.

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t- *s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s

Algorithm:

slide-34
SLIDE 34

A Spigot Algorithm for π

Column Head ai

bi = i 2i+1

Column Number ci = 2.

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t- *s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s

Algorithm:

◮ Multiply each ci by 10.

slide-35
SLIDE 35

A Spigot Algorithm for π

Column Head ai

bi = i 2i+1

Column Number ci = 2.

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t- *s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s

Algorithm:

◮ Multiply each ci by 10. ◮ Proceeding from the rightmost to the leftmost column, find

positive integers q and r such that q · bi + r = ci with 0 < r < bi, then assign ci ← r and carry q · ai left.

slide-36
SLIDE 36

A Spigot Algorithm for π

Column Head ai

bi = i 2i+1

Column Number ci = 2.

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t- *s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s

Algorithm:

◮ Multiply each ci by 10. ◮ Proceeding from the rightmost to the leftmost column, find

positive integers q and r such that q · bi + r = ci with 0 < r < bi, then assign ci ← r and carry q · ai left.

◮ On the leftmost column, output the first digit of the column

number c0. This is the next digit of π!

slide-37
SLIDE 37

A Spigot Algorithm for π

I I
  • Vll:
_ iS |

Stanley Rabinowitz and Stan Wagon

  • Dl
I DW
  • 1|
.11 1 _ . 111 | .. 1. . I 1 1 .. 11111111 __

Digits 1 2 3 4 5 6 7 8 9 10 11 12

  • f X

3 s 7 9 11 13 15 17 19 21 23 2s hitiMim 2 2 2 2 2 2 2 2 2 2 2 2 2 x 10 20 20 20 20 20 t20 20 20 20

N

20 20 20 Carry 3 F;s <

s *So i;2- s t-

*s +,at*'s .+>

H -s

¢* * . +9-

X

83 s .* i s e >*

=

*30>3 liS\>

t

gi iX8 ..MQ>.\\2RN42QN/320. Remainders

  • X
  • ,.2

4: < i lo Ni } S 1 x 10 2Q 20 40 30 100 10 130 120 10 200 200 2 Cawy 1x+12+20+33 +40+65+48 +98+ ;72+150+132.

  • )13

40 53 80 9S 148 108 218 192 160 332 296626.* Remainders 3 1 3 3

5

5 4 8 5 8 17 20 > (yt x 10 30 10 30 30 S0 S0 40 80 S0 80 170 200 Carry 4Fk +11 +24 +30 +40 +40 +4X +43 + 64 +0+12Q + 88 )41 34 60 70 90 92 103 144 140 2 258 200 ltemainders 81 1 4 12 9 4 10 6 16 x 10 10 10 40 120 90 40 100 60 160 Carry 1S+4 +2 +9 +24 +E +B4 +63 +48 +72 +60 +66 S _ 14 12 9 24 SS 124 183 138 1 12 160 126 16Q

  • It is remarkable

that the algorithm illustrated in Table 1, which uses no floating- point arithmetic, produces the digits of 77. The algorithm starts with some 2sS in columns headed by the fractions

  • shown. Each entry is multiplied

by 10. Then, starting from the rightS the entries are reduced modulo den, where the head of the column is num/den7 producing a quotient q and remainder

  • r. The remainder

is left in place and q X num is carried

  • ne column left. This reduce-and-carry

is continued all the way leX. The tens digit of the lehmost result is the next digit

  • f
  • 7r. The process continues with the multiplication
  • f the remainders

by 10 the reductions modulo the denominators, and the augmented carrying.

TABLE

  • 1. The workings of an algorithm that produces digits of Gr The dashed line indicates the key

stept starting from the rlght, elltries are reduced modulo the denominator of the column head (25, 23, 2l, . . . 1 resp.), with the quotients, aRer multiplication by the numerator (12, 11 > 10 . . .

)7 carried
  • left. For example, the 20 in the l99's

column yields a remainder of 1 and a left carry of 1 9 = 9. After the leftmost carriesS the tens digits are 3, 1, 4 1. To get more digits of v one must start with a longer string of 2s.

This algorithm is a 4spigot algorithm: it pumps

  • ut digits one at a time and

does not use the digits after they are computed. Moreover the digits are generated without any use of high-precision (or low-precision)

  • perations
  • n floating-point

real numbers; the entire algorithm uses only ordinary integer arithmetic on

lg95] 195 A SPIGOT ALGORITHM FOR THE DIGITS OF v

A Spigot Algorithm for the Digits

  • f s
slide-38
SLIDE 38

A Spigot Algorithm for π

Why does this work?

slide-39
SLIDE 39

A Spigot Algorithm for π

Why does this work? The algorithm is based on the following representation for π

2 ,

π 2 =

  • i=0

i! (2i + 1)!! = 1 + 1 3 + 1 · 2 3 · 5 + 1 · 2 · 3 3 · 5 · 7 + · · ·

slide-40
SLIDE 40

A Spigot Algorithm for π

Why does this work? The algorithm is based on the following representation for π

2 ,

π 2 =

  • i=0

i! (2i + 1)!! = 1 + 1 3 + 1 · 2 3 · 5 + 1 · 2 · 3 3 · 5 · 7 + · · · Observe that we can rewrite this as π 2 = 1 + 1 3

  • 1 + 2

5

  • 1 + 3

7

  • 1 + · · ·
slide-41
SLIDE 41

A Spigot Algorithm for π

Why does this work? The algorithm is based on the following representation for π

2 ,

π 2 =

  • i=0

i! (2i + 1)!! = 1 + 1 3 + 1 · 2 3 · 5 + 1 · 2 · 3 3 · 5 · 7 + · · · Observe that we can rewrite this as π 2 = 1 + 1 3

  • 1 + 2

5

  • 1 + 3

7

  • 1 + · · ·
  • r equivalently,

π = 2 + 1 3

  • 2 + 2

5

  • 2 + 3

7

  • 2 + · · ·
slide-42
SLIDE 42

A Spigot Algorithm for π

In some ways, this mixed-radix form is similar to having a closed form for the digits of π in some base b, except the base changes with every term.

slide-43
SLIDE 43

A Spigot Algorithm for π

In some ways, this mixed-radix form is similar to having a closed form for the digits of π in some base b, except the base changes with every term. π = a0 + 1 b

  • a1 + 1

b2

  • a2 + 1

b3

  • a3 + · · ·
slide-44
SLIDE 44

A Spigot Algorithm for π

In some ways, this mixed-radix form is similar to having a closed form for the digits of π in some base b, except the base changes with every term. π = a0 + 1 b

  • a1 + 1

b2

  • a2 + 1

b3

  • a3 + · · ·
  • π = a0.a1a2a3 . . .b
slide-45
SLIDE 45

A Spigot Algorithm for π

In some ways, this mixed-radix form is similar to having a closed form for the digits of π in some base b, except the base changes with every term. π = a0 + 1 b

  • a1 + 1

b2

  • a2 + 1

b3

  • a3 + · · ·
  • π = a0.a1a2a3 . . .b

π = 2 + 1 3

  • 2 + 2

5

  • 2 + 3

7

  • 2 + · · ·
  • π = 2.222 . . .[1, 1

3 , 2 5 ,...]

slide-46
SLIDE 46

A Spigot Algorithm for π

In some ways, this mixed-radix form is similar to having a closed form for the digits of π in some base b, except the base changes with every term. π = a0 + 1 b

  • a1 + 1

b2

  • a2 + 1

b3

  • a3 + · · ·
  • π = a0.a1a2a3 . . .b

π = 2 + 1 3

  • 2 + 2

5

  • 2 + 3

7

  • 2 + · · ·
  • π = 2.222 . . .[1, 1

3 , 2 5 ,...]

In this sense, the algorithm is simply changing the base of the representation.

slide-47
SLIDE 47

Unbounded Spigot Algorithms for the Digits of π

Jeremy Gibbons (2006) Developed an algorithm using the same principle, but much cleaner in the details. Particularly, it is unbounded - no need to decide on the number of digits before starting.

slide-48
SLIDE 48

Assorted Series

slide-49
SLIDE 49

Assorted Series

Wallis π 2 = 2 · 2 · 4 · 4 · 6 · 6 · · · 1 · 3 · 3 · 5 · 5 · 7 · · ·

slide-50
SLIDE 50

Assorted Series

Wallis π 2 = 2 · 2 · 4 · 4 · 6 · 6 · · · 1 · 3 · 3 · 5 · 5 · 7 · · · Ramanujan 1 π = √ 8 9801

  • n=0

(4n)! (n!)4 [1103 + 26390n] 3964n

slide-51
SLIDE 51

Assorted Series

Wallis π 2 = 2 · 2 · 4 · 4 · 6 · 6 · · · 1 · 3 · 3 · 5 · 5 · 7 · · · Ramanujan 1 π = √ 8 9801

  • n=0

(4n)! (n!)4 [1103 + 26390n] 3964n

  • D. H. Bailey, P. Borwein, S. Plouffe

π =

  • k=0

1 16k

  • 4

8k + 1 − 2 8k + 4 − 1 8k + 5 − 1 8k + 6