Saturday, May 27, 2023

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?

TI-Nspire CX II (CAS): How Many Terms Are Needed to Calculate π?



Every One Wants a Slice of π


There are many ways of calculating the π, usually apply a formula or a sequence many, many, many times to get as many digits as possible.  The file pitests.tns tests (see below) five algorithms:



Test 1:  Zeta Formula


π^2 / 6 = Σ( 1 / n^2, n=1 to ∞ )


Test 2:  Pi Squared Over Eight Sum


π^2 / 8 = Σ( (2 * n + 1)^(-2), n = 0 to ∞)


Test 3:  Half of Pi Product


π / 2 = Π( (2 * k)^2 / ((2 * k - 1) * (2 * k + 1)), k = 1 to ∞)


Test 4:  Fibonacci Number Sum


π / 2 = Σ( arctan((F_[2*k+1])^(-1)), k = 0 to ∞ )


The angle is radians.  F_[2*k+1] is the [2*k+1]th Fibonacci number.


Test 5:  Limit Sequence


π = lim (n → ∞) [ a^2 / n ]


where 

a0 = 1

a_[n+1] = a_[n] * (1 + (2 * n + 1)^(-1))


The goal is to determine how many terms are needed to obtain a certain amount of digits.  






Certain algorithms take longer than others.     Here are some results:


2 places:  3.14

3 places:  3.141



Test 1:  

2 decimal places:  600 terms

3 decimal places:  1611 terms 


The zeta function converges super slowly for small arguments.


Test 2:

2 decimal places:  199 terms

3 decimal places:  537 terms


Test 3:

2 decimal places:  493 terms

3 decimal places:  1325 terms


Test 4:

2 decimal places:  9 terms

3 decimal places: 10 terms


The Fibonacci method is the fastest and probably is the quickest way to build the expansion of π.


Test 5:

2 decimal places:  94 places

3 decimal places:  1929 places



Download the file pitests.tns here:  https://drive.google.com/file/d/1XqHtPnoKvqfmFLNWHQ-IayFz_lM5zZyT/view?usp=share_link



Source


"List of formulae involving π"  Wikipedia.   Edited on February 11, 2023.   Accessed on March 12, 2023.  https://en.wikipedia.org/wiki/List_of_formulae_involving_%CF%80



Note:   On June and July 2023, regular posts will be on Saturdays only, which will include the next Carnival of Math.


Eddie



All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Spotlight: Sharp EL-5200

  Spotlight: Sharp EL-5200 As we come on the 13 th (April 16) anniversary of this blog, I want to thank you. Blogging about mathematic...