Top Banner

Click here to load reader

46

pi to a trillion digits : How and Why?

Nov 07, 2014

Download

Education

PlusOrMinusZero

Describes the mathematical and programming concepts involved in the computation of the value of pi correct to a trillion or more decimal digits..
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: pi to a trillion digits : How and Why?

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

Page 2: 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

Page 3: 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

Page 4: 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

Page 5: 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 inmathematics.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 6: 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 itsdiameter is denoted by π. (The symbol π was firstproposed by the Welsh mathematician WilliamJones in 1706.)

V N Krishnachandran

Pi to a trillion digits: How and why

Page 7: 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

diameter π =

Circumference of a circle (C )

Diameter of the circle (d)

V N Krishnachandran

Pi to a trillion digits: How and why

Page 8: 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

Page 9: 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 onlyapproximate values of π.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 10: 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 theratio of one integer to another integer.

π is not an algebraic number, that is, not asolution of a polynomial equation with integercoefficients.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 11: 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 infinitenumber of digits appearing apparently withoutany pattern.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 12: 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 50288419716939937510 5820974944 5923078164 06286208998628034825 3421170679 8214808651 32823066470938446095 5058223172 5359408128 48111745028410270193 8521105559 6446229489 5493038196

Fine! How can one obtain all these digits?

V N Krishnachandran

Pi to a trillion digits: How and why

Page 13: 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

Page 14: 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

Page 15: 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 theexact value of π.

This is because of the limitations of thedrawing instruments.

For example, we cannot draw a line withthickness 0.0000000001 mm.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 16: 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 measuringcircumferences and radii of circles!

We need mathematical machinery!!

V N Krishnachandran

Pi to a trillion digits: How and why

Page 17: 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

Page 18: 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

Page 19: 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

Page 20: 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

arctan(a

b

)= Angle A.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 21: 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 whosetrigonometric tangent is x .

V N Krishnachandran

Pi to a trillion digits: How and why

Page 22: 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

Page 23: 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

Page 24: 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

arctan(x) = x − x3

3+

x5

5− x7

7+ · · ·

V N Krishnachandran

Pi to a trillion digits: How and why

Page 25: 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 formulafor faster computation of π.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 26: 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

4 arctan

(1

5

)− arctan

(1

239

)= arctan(1)

V N Krishnachandran

Pi to a trillion digits: How and why

Page 27: 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

π = 16[(

15

)− 1

3

(153

)+ 1

5

(155

)+ · · ·

]−4[(

1239

)− 1

3

(1

2393

)+ 1

5

(1

2395

)+ · · ·

]

V N Krishnachandran

Pi to a trillion digits: How and why

Page 28: 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, Indianmathematical genius, is also used to compute π.

V N Krishnachandran

Pi to a trillion digits: How and why

Page 29: 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

9801

∞∑n=0

(4n)!

(n!)4× 26390n + 1103

3964n

V N Krishnachandran

Pi to a trillion digits: How and why

Page 30: 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 convergingseries to compute π

Iteration scheme due to Borwein and Borwein

V N Krishnachandran

Pi to a trillion digits: How and why

Page 31: 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

Page 32: 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 decimalrepresentation of the proper fraction4

7 :

47 = .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

Page 33: 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 tothe 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

Page 34: 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

Page 35: 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 ina 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

Page 36: 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

Page 37: 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

Page 38: 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

Page 39: 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

Page 40: 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 tocompute π!

V N Krishnachandran

Pi to a trillion digits: How and why

Page 41: 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 ofNetherland, 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

Page 42: 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

Page 43: 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

Page 44: 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 ofTsukuba, 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

Page 45: 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

Page 46: 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 ApplicationsVidya Academy of Science and Technology

Thrissur - 680501, Kerala

(October 2009)

V N Krishnachandran

Pi to a trillion digits: How and why