Showing posts with label π. Show all posts
Showing posts with label π. Show all posts

Sunday, November 13, 2016

TI-89 and HP Prime: Approximation Digits of π to Lots of Digits

TI-89 and HP Prime:  Approximation Digits of π to Lots of Digits 

Ways to find digits of π. 

Four steps with a calculator with CAS, which allows computation with large integers:

1.  Take a series and multiply each term by 10^n, where n is the number of digits desired. The exact form of each calculation 
2. Take the integer portion of the sum. Make any adjustments when necessary. 
3. Convert the sum to a string.  Insert a decimal point when appropriate. 
4. Return the answer as a string. 

There are three methods that are demonstrated, one routine is presented for the TI-89 and the HP Prime.  All programs presented takes two arguments: n number of digits, m is the number of iterations. Remember that m must be sufficiently high to get an accurate computation of π. 

In the TI-89 programs, (C) marks a comment.  All HP Prime programs on this blog entry are to be run in CAS mode (make sure CAS is checked when creating the program).  

Keep in mind the HP Prime is significantly faster than the TI-89.  

Newton/Euler - newpi

π = 2 * Σ ( 2^k * (k!)^2 / (2*k + 1)!, k, 0, infinity)

TI-89 Program newpi
newpi(n,m)
(C) Newton/Euler π 
Local s,k,t
(C) initialize
0 → t
(C) loop
For k,0,m
t + exact( 10^n * 2^k * (k!)^2 / ( (2*k + 1)! ) ) → t
EndFor
iPart(2*t) → t
string(t) → s
left(s,1) & "." & right(s,n) → s
Disp s
EndPrgm

HP Prime CAS Program newpi
#cas
newpi(n,m):=
BEGIN
LOCAL t,k,s;
// Netwon/Euler π 
// 2016-11-13 EWS
t:=0;
FOR k FROM 0 TO m DO
t:= t + exact( 10^n * 2^k * (k!)^2 /  ( (2*k + 1)! ));
END;
t:= IP(2*t);
// string, left, right 
// must be in lower case
s:= string(t);
s:= left(s,1) + "." + right(s,n);
return s;
END;
#end

newpi(20, 175) returns "3.14159265358979323846"

Arctangent - arctanpi

π = Σ ( 2^(k+1) / ( COMB(2*k, k) * (2*k +1) ), k, 0, infinity)

TI-89 Program arctanpi
arctanpi(n,m)
(C) Arctan π 
Local s,k,t
(C) initialize
0 → t
(C) loop
For k,0,m
t + exact( 10^n * 2^(k + 1) / ( nCr(2*k,k) * (2*k+1) ) ) → t
EndFor
iPart(t) → t
string(t) → s
left(s,1) & "." & right(s,n) → s
Disp s
EndPrgm

HP Prime CAS Program arctanpi
#cas
arctanpi(n,m):=
BEGIN
LOCAL t,k,s;
// Arctan π 
// 2016-11-13 EWS
t:=0;
FOR k FROM 0 TO m DO
t:= t + exact( 10^n * 2^(k+1)/(COMB(2*k,k) * (2*k + 1)));
END;
t:= IP(t);
// string, left, right 
// must be in lower case
s:= string(t);
s:= left(s,1) + "." + right(s,n);
return s;
END;
#end

arctanpi(25, 200) returns "3.1415926535897932384626433"

Bailey-Borwein-Plouffe Formula (BBP) - bbppi

π = Σ ( 1/16^k * ( 4/(8*k +1) - 2/(8*k + 4) - 1/(8*k + 5) - 1/(8*k + 6) ), k, 0, infinity)

TI-89 Program bbppi
bbppi(n,m)
(C) BBP π 
Local s,k,t
(C) initialize
0 → t
(C) loop
For k,0,m
t + exact( 10^n/16^k * ( 4/(8*k + 1) - 2/(8*k + 4) - 1/(8*k + 5) - 1/(8*k + 6) ) ) → t
EndFor
iPart(t) → t
string(t) → s
left(s,1) & "." & right(s,n) → s
Disp s
EndPrgm

HP Prime CAS Program bbppi
#cas
bbppi(n,m):=
BEGIN
LOCAL t,k,s;
// Netwon/Euler π 
// 2016-11-13 EWS
t:=0;
FOR k FROM 0 TO m DO
t:= t + exact( 10^n/16^k * ( 4/(8*k + 1) - 2/(8*k + 4) - 1/(8*k + 5) 
- 1/(8*k + 6) ) );
END;
t:= IP(t);
// string, left, right 
// must be in lower case
s:= string(t);
s:= left(s,1) + "." + right(s,n);
return s;
END;
#end

bbppi(25,200) returns "3.1415925635897932846"


Source:  Wikipeida.  "Approximations of π"  https://en.m.wikipedia.org/wiki/Approximations_of_π. Retrieved November 12, 2016

This blog is property of Edward Shore, 2016. 

Friday, March 14, 2014

Happy π Day! Happy Birthday Albert Einstein!


Today is a great day. We get to celebrate one of the best numbers in existence: π. π plays a role in many mathematical and scientific applications. Some examples include:

Area of a Circle = π * radius^2

Area of an Ellipse = π * length of semi-major axis * length of semi-minor axis

The functions sin x, cos x, and tan x each have a period of π.

Euler's Formula: e^(i*π) + 1 = 0

Definite integral involving π:
∫(e^(-a*x^2) dx, 0, infinity) = 0.5 * √(π/a)

1 + 1/3 + 1/5 + 1/7 + ... = sum of the fractions of 1/odd integers = π/4
(Convergence might be slow)

Γ(1/2) = √π. (Gamma of 1/2)

Probability: Area under the Normal Curve:
1/√(2 π) * ∫(e^(-x^2/2))

Angular Velocity, general: ω = 2 π f, where f is frequency

Conversion between radians and degrees:
Angle in Radians = Angle in Degrees * π/180

Optics: Double Split Interference - Intensity at an Angle:
I = 4 * I_0 * cos( π * d * sin θ / λ )^2

Also today is Albert Einstein's birthday (March 14). He is primarily responsible for the Theory of Relativity and E = mc^2. I am going to give myself a refresher course.

Here is some information about the Theory of Relativity:
http://en.wikipedia.org/wiki/Theory_of_relativity


This blog is property of Edward Shore. 2014

Thursday, March 14, 2013

Happy π Day! And some Mathematical Art

Happy π Day!

π = 3.14159 26535 89793 23846 26433 83279 50288...

Who would have known that the ratio of a circle's circumference to its diameter would generate interest though out human history? π never ends, and over 10 trillion digits have been calculate. I have memorized about 15 digits. The digit zero (0) does not appear until the 32nd digit.

Why is π such a "celebrity" number? Find out here:
http://www.youtube.com/watch?v=yJ-HwrOpIps

According to Dr. James Grime, we can calculate the size of the observable universe using π with only 39 digits.
http://www.youtube.com/watch?v=FpyrF_Ci2TQ

You can use the (very slow converging series) to get π:

π = 4 × (1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + 1/13 - 1/15 + 1/17...)

There are many songs about π. My favorite is "Pi" by Kate Bush (off the album "Aerial").

Tonight I plan to join desmos.com to participate in a π Day discussion.

To celebrate my birthday and π Day, I am going to share some mathematical artwork, which was created using the TI nSpire CX CAS iPad App.

Tuesday, October 2, 2012

Distribution of Digits for π, e, Euler's Constant, and √2

Here are four famous numerical constants, extended to 50 decimal places: π, e, γ, and √2. For each constant, the approximation will be listed and a histogram of each of the 50 decimal places and the integer part (51 digits in total) will be presented.

Pi
π ≈ 3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510

Digit Distribution: (digit: number of occurrences)
0: 2
1: 5
2: 5
3: 9
4: 4
5: 5
6: 4
7: 4
8: 5
9: 8

e

e ≈ 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 69995

Digit Distribution:
0: 3
1: 3
2: 8
3: 4
4: 5
5: 6
6: 4
7: 7
8: 5
9: 6

γ (Euler's Constant)

γ ≈ 0.57721 56649 01532 86060 65120 90082 40243 10421 59335 93992

Digit Distribution:
0: 9
1: 5
2: 7
3: 5
4: 4
5: 6
6: 5
7: 2
8: 2
9: 6

√2

√2 ≈ 1.41421 35623 73095 04880 16887 24209 69807 85696 71875 37694

Digit Distribution:
0: 5
1: 5
2: 4
3: 4
4: 5
5: 4
6: 6
7: 6
8: 7
9: 5

Of the four constants presented, √2 has the most even distribution, at far as the first 50 decimal points are concerned.

Fun Fact: 99/70 gives √2 accurate to four decimal places.
99/70 = 1.41428 571428...

Resources

π, e, γ

Zwillinger, Daniel. CRC - Standard Mathematical Tables and Formulae 32nd Edition. CRC Press, Boca Raton, FL. 2012

√2

√2 Wikipedia: Retrieved October 2, 2012.


Enjoy! This is something I wanted to do for a while, as I am fascinated by numerical constants.

Eddie


This blog is property of Edward Shore, 2012.

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...