Post Reply 
Pi Approximation Day
07-24-2022, 03:52 PM
Post: #24
RE: Pi Approximation Day
(07-24-2022 11:59 AM)Steve Simpkin Wrote:  Using that equation with a summation of 1-10 approximates Pi to 7 digits.
Using it with a summation of 1-87 approximates Pi to 12 digits.

Looking at the table in this previous post we can see that we gain about 5 digits if n is multiplied by 10.
Which is really bad.

Compare it with this program to calculate the Taylor series of the \(\arctan(x)\) function:

\(
\begin{align}
\arctan(x)=x-\frac{x^{3}}{3}+\frac{x^{5}}{5}-\frac{x^{7}}{7}+\cdots =\sum _{n=0}^{\infty}\frac {(-1)^{n}x^{2n+1}}{2n+1}
\end{align}
\)

And then use:

\(
\begin{align}
\frac{\pi}{4}=\arctan \frac{1}{2} + \arctan \frac{1}{3}
\end{align}
\)

Code:
00 { 23-Byte Prgm }
01 STO 00
02 R↓
03 ENTER
04 ENTER
05 ENTER
06 CLX
07▸LBL 00
08 ×
09 RCL 00
10 2
11 ×
12 1
13 -
14 1/X
15 X<>Y
16 -
17 ×
18 DSE 00
19 GTO 00
20 END

Example

Make sure we're at the beginning of the program:

RTN

Calculate \(\arctan \frac{1}{2}\):

2
1/X
53
R/S
STO 01

4.636476090008061162142562314612144e-1

Calculate \(\arctan \frac{1}{3}\):

3
1/X
33
R/S

3.217505543966421934014046143586614e-1

Calculate \(\pi=4\left(\arctan \frac{1}{2} + \arctan \frac{1}{3}\right)\):

RCL 01
+
4
×

3.141592653589793238462643383279503

Which is correct to all places.

(07-23-2022 11:31 PM)Valentin Albillo Wrote:  it converges very fast (order 6), the general term is extremely simple to program needing just 6 steps, and this makes for speedy looping and very short running times

The code in the loop of this program isn't much more complicated but instead of using 1000000 terms to get 33 correct digits we only need 53 + 33 = 86 terms to get 34 correct digits of \(\pi\).

And there are ways to even reduce this further e.g. by using Machin's formula:

\(
\begin{align}
\frac{\pi}{4}=4 \arctan \frac{1}{5} - \arctan \frac{1}{239}
\end{align}
\)

References
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Pi Approximation Day - Gerson W. Barbosa - 07-22-2022, 11:47 PM
RE: Pi Approximation Day - J-F Garnier - 07-23-2022, 11:44 AM
RE: Pi Approximation Day - C.Ret - 07-23-2022, 03:18 PM
RE: Pi Approximation Day - C.Ret - 07-23-2022, 05:18 PM
RE: Pi Approximation Day - Steve Simpkin - 07-24-2022, 11:59 AM
RE: Pi Approximation Day - Thomas Klemm - 07-23-2022, 02:20 AM
RE: Pi Approximation Day - J-F Garnier - 07-23-2022, 07:00 AM
RE: Pi Approximation Day - Albert Chan - 07-23-2022, 10:56 AM
RE: Pi Approximation Day - vaklaff - 07-23-2022, 11:26 AM
RE: Pi Approximation Day - Thomas Klemm - 07-23-2022, 06:46 PM
RE: Pi Approximation Day - Didier Lachieze - 07-23-2022, 09:09 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 07:03 AM
RE: Pi Approximation Day - Dan C - 07-24-2022, 09:37 AM
RE: Pi Approximation Day - Dan C - 07-24-2022, 11:29 AM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 11:30 AM
RE: Pi Approximation Day - Ajaja - 07-24-2022, 01:28 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022 03:52 PM
RE: Pi Approximation Day - Albert Chan - 07-24-2022, 07:13 PM
RE: Pi Approximation Day - pauln - 07-24-2022, 06:39 PM
RE: Pi Approximation Day - EdS2 - 07-24-2022, 09:10 PM
RE: Pi Approximation Day - pauln - 07-24-2022, 11:27 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 10:16 PM
RE: Pi Approximation Day - Albert Chan - 07-25-2022, 12:03 AM
RE: Pi Approximation Day - Thomas Klemm - 07-25-2022, 06:38 AM
RE: Pi Approximation Day - Thomas Klemm - 07-25-2022, 09:28 PM
RE: Pi Approximation Day - Albert Chan - 07-26-2022, 12:51 AM
RE: Pi Approximation Day - pauln - 07-26-2022, 01:27 AM
RE: Pi Approximation Day - Albert Chan - 07-26-2022, 12:27 PM
RE: Pi Approximation Day - Thomas Klemm - 07-26-2022, 05:24 AM
RE: Pi Approximation Day - Thomas Klemm - 07-26-2022, 01:38 PM
RE: Pi Approximation Day - EdS2 - 08-03-2022, 04:53 PM
RE: Pi Approximation Day - Thomas Klemm - 08-07-2022, 11:42 AM



User(s) browsing this thread: 2 Guest(s)