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. 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 } 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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)