doG Posted July 8, 2012 Posted July 8, 2012 [math]\arctan(z) = \sum_{n=0}^\infty \frac {(-1)^n z^{2n+1}} {2n+1} \; \qquad | z | \le 1 \qquad z \neq i,-i[/math] [math]4 \arctan(1) = 4 \cdot \sum_{n=0}^\infty \frac {(-1)^n 1^{2n+1}} {2n+1} = \pi[/math] Reference: Inverse trigonometric functions - infinite series - Wikipedia So it's really just a different series representation as post #71 above.....
Orion1 Posted July 8, 2012 Posted July 8, 2012 (edited) [math]4 \cdot \sum_{n=0}^\infty \frac {(-1)^n} {2n+1} = \pi[/math] This equation appears to be the most reduced, however the arctan identity is gone. Edited July 8, 2012 by Orion1
mathematic Posted July 8, 2012 Posted July 8, 2012 [math]4 \cdot \sum_{n=0}^\infty \frac {(-1)^n} {2n+1} = \pi[/math] This equation appears to be the most reduced, however the arctan identity is gone. This series converges very slowly.
IsaacAsimov Posted July 8, 2012 Author Posted July 8, 2012 (edited) This is the formula you gave us: [math] \pi=4\cdot arctan(1)=4\sum_{n=0}^{\infty}\frac{(-1)^n\cdot 1^{2n+1}}{2n+1}=4\sum_{n=0}^{\infty}\frac{(-1)^n}{2n+1} [/math] I wrote a small computer program on my C64 computer using this formula. It doesn't converge on pi fast enough. Even after 1000 runs through the loop, which took 57 seconds, the only correct part was 3.14 Edited July 8, 2012 by IsaacAsimov
doG Posted July 9, 2012 Posted July 9, 2012 This is the formula you gave us: [math] \pi=4\cdot arctan(1)=4\sum_{n=0}^{\infty}\frac{(-1)^n\cdot 1^{2n+1}}{2n+1}=4\sum_{n=0}^{\infty}\frac{(-1)^n}{2n+1} [/math] I wrote a small computer program on my C64 computer using this formula. It doesn't converge on pi fast enough. Even after 1000 runs through the loop, which took 57 seconds, the only correct part was 3.14 Go to WolframAlpha and just click on more digits to get the precision you want.
Orion1 Posted July 9, 2012 Posted July 9, 2012 I wrote a small computer program on my C64 computer using this formula.It doesn't converge on pi fast enough. Even after 1000 runs through the loop, which took 57 seconds, the only correct part was 3.14[/Quote] Why are you programming on a Commodore 64 computer? nostalgia reasons? Try this program, let me know how fast it converges. 10 PRINT 4*ATN(1)
mathematic Posted July 9, 2012 Posted July 9, 2012 (edited) This is the formula you gave us: [math] \pi=4\cdot arctan(1)=4\sum_{n=0}^{\infty}\frac{(-1)^n\cdot 1^{2n+1}}{2n+1}=4\sum_{n=0}^{\infty}\frac{(-1)^n}{2n+1} [/math] I wrote a small computer program on my C64 computer using this formula. It doesn't converge on pi fast enough. Even after 1000 runs through the loop, which took 57 seconds, the only correct part was 3.14 For estimating the speed of convergence, note that the series is ~ 1/n^2, so that the remainder after n terms is ~ 1/n. P.S. A more precise estimate of the remainder is 1/(4n+1). Edited July 9, 2012 by mathematic
Bignose Posted July 10, 2012 Posted July 10, 2012 (edited) Why are you programming on a Commodore 64 computer? nostalgia reasons? Try this program, let me know how fast it converges. 10 PRINT 4*ATN(1) Very good. You are also using a series. An optimized one for the language you've picked. You know how that series was found? Through a lot of ways similar to those presented in this thread. Or did you not know that behind 'ATN' is also a series calculator of some sort? The computer doesn't just know the answer. It calculates it in ways not unlike what this thread has presented. I really think you are a missing the point -- granted, the thread hasn't been terribly focused. But, the point isn't to just use a built-in optimized series. But to explore how the various series behave. Edited July 10, 2012 by Bignose
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) [math]\pi = 4 \sum_{n=0}^{\infty} \frac{(-1)^n}{2n+1}[/math] I calculated the integer sum steps required to complete each numerical place, note that these numbers are fundamental to this equation and are independent of any computer specifications. (i.e. CPU, RAM, Memory, OS, basic language, etc.) Integer sum: [math]n \; ( \text{2}, \text{18}, \text{118}, \text{1687}, \text{10793}, \text{136120}, \text{1530011}, \text{18660287}, \text{155974698})[/math] Numerical place: [math]n_l \; (3,1,4,1,5,9,2,6,5)[/math] Numerical length: [math]l \; (1,2,3,4,5,6,7,8,9)[/math] Example: [math]4 \sum_{n=0}^{1687} \frac{(-1)^n}{2n+1} = 3.141... \; \; \; l = 4[/math] Note that [math]l = 9[/math] required a compiler. Edited July 10, 2012 by Orion1
D H Posted July 10, 2012 Posted July 10, 2012 Example:[math]4 \sum_{n=0}^{1687} \frac{(-1)^n}{2n+1} = 3.141... \; \; \; l = 4[/math] To four places, pi is 3.142, not 3.141. This is the problem in a nutshell. You have three, not four, place accuracy after your 1687 elements. This series is incredibly, incredibly slow to converge, taking on the order of 10n iterations to acheive n place accuracy. Compare that to some techniques that yield over ten decimal places per iteration.
studiot Posted July 10, 2012 Posted July 10, 2012 (edited) I haven't looked at this thread for some time, but I see you did have a go at the Wallis formula I posted. However you did express some uncertainty in the algebra. With a computer, the easiest way to eliminate the square root is to square the equation. It is perfectly acceptable to square the infinite products term by term and the extra multiplications are no problem to the computer. The idea of breaking the multiplications into a sequence of fractions multiplied together is also good. On squaring the expression becomes [math]\frac{\pi }{2} = \frac{{2*2*4*4*6*6*8*8...........\left( {2m - 2} \right)\left( {2m - 2} \right)2m}}{{3*3*5*5*7*7*9*9.........\left( {2m - 1} \right)\left( {2m - 1} \right)}}[/math] Edited July 10, 2012 by studiot
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) To four places, pi is 3.142, not 3.141. [math]4 \sum_{n=0}^{1687} \frac{(-1)^n}{2n+1} = 3.141... \; \; \; l = 4[/math] According to my computer algorithm and Mathematica and Wolframalpha, the solution is 3.141. Can anyone else verify? Reference: Wolframalpha - sum formula Edited July 10, 2012 by Orion1
doG Posted July 10, 2012 Posted July 10, 2012 [math]4 \sum_{n=0}^{1687} \frac{(-1)^n}{2n+1} = 3.141... \; \; \; l = 4[/math] According to my computer algorithm and Mathematica and Wolframalpha, the solution is 3.141. Can anyone else verify? Reference: Wolframalpha - sum formula Yes, the output of your series is 3.141 but pi being 3.141592653589..... it rounds to 3.142 for 4 place accuracy so 3.141 is not accurate to 4 places, only 3. Just because you've computed it to 4 places does not mean your result is accurate to 4 places.
studiot Posted July 10, 2012 Posted July 10, 2012 (edited) According to my computer algorithm and Mathematica and Wolframalpha, the solution is 3.141. Can anyone else verify? But according to The Man, that is the wrong answer! That is it is not pi. Edited July 10, 2012 by studiot
IsaacAsimov Posted July 10, 2012 Author Posted July 10, 2012 Why are you programming on a Commodore 64 computer? nostalgia reasons? Try this program, let me know how fast it converges. 10 PRINT 4*ATN(1) Perfect Pi Formula: I am still programming on a Commodore 64 computer because it still works, I am familiar with it, it has a good programming language, namely BASIC, and I can program in Structured BASIC. I tried your short program, and I got a value of pi = 3.14159266 On my computer keyboard, there is a special character for pi, which I can get by pressing <shift> [math]\pi[/math] Here is the program: 10 PRINT [math]\pi[/math] I get a value for pi= 3.14159265 If I press the <shift> [math]\pi[/math] button on my calculator, I get a value of pi= 3.141592654 Here is the Perfect Pi Program: 10 REM PERFECT PI PROGRAM 14 REM FROM ATN PI AND SIMPLE PI 20 PRINT "ATN PI =" 30 PRINT 4*ATN(1) 34 PRINT 40 PRINT "SIMPLE PI =" 50 PRINT [math]\pi[/math] I think the ATN formula you gave me is the perfect pi formula. Congratulations!
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) Or did you not know that behind 'ATN' is also a series calculator of some sort? The computer doesn't just know the answer. It calculates it in ways not unlike what this thread has presented.[/Quote] Yes, the output of your series is 3.141 but pi being 3.141592653589..... it rounds to 3.142 for 4 place accuracy so 3.141 is not accurate to 4 places, only 3. Just because you've computed it to 4 places does not mean your result is accurate to 4 places. If the computer is evaluating pi from scratch, such as the case example for the Atn(x) and partial sum functions, then the computer does not know that the answer is pi, so how can it 'know' to round up to the nearest decimal point? and in the case where the solution is only 3.141 at that point in the sum, then there are no further decimal places to round up from!. I am still programming on a Commodore 64 computer because it still works, I am familiar with it, it has a good programming language, namely BASIC, and I can program in Structured BASIC.[/Quote]Excellent!, I used to program on an old Apple IIe myself, the basic languages are very similar. The C64 is really easy to program. Have you tried using a Commodore 64 emulator yet? Check out the WinVICE-2.2-x86 link listed in reference 1, and try out the 'warp' option!. Reference: WinVICE-2.2-x86 - a Commodore 64 emulator for Windows Edited July 10, 2012 by Orion1
doG Posted July 10, 2012 Posted July 10, 2012 If the computer is evaluating pi from scratch, such as the case example for the Atn(x) and partial sum functions, then the computer does not know that the answer is pi, so how can it 'know' to round up to the nearest decimal point? and in the case where the solution is only 3.141 at that point in the sum, then there are no further decimal places to round up from!. I never said the computer would know what to round up to but it has not calculated Pi accurately to 4 places, only 3, Pi to 4 places is 3.142, not 3.141.
studiot Posted July 10, 2012 Posted July 10, 2012 Actually, to be fair, the computer holds the value to quite a few more places than 3. The fault is in the user programming which does not include rounding. I can't remember if the C64 used truncation or rounding when asked to report to a specific no of figs.
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) I never said the computer would know what to round up to but it has not calculated Pi accurately to 4 places, only 3, Pi to 4 places is 3.142, not 3.141.[/Quote] Again, your assumption is that the computer 'knows' that the solution is pi, which it does not. Actually' date=' to be fair, the computer holds the value to quite a few more places than 3.The fault is in the user programming which does not include rounding.[/Quote'] Rounding a number during mid summation would produce an incorrect solution, not a correct solution. Edited July 10, 2012 by Orion1
studiot Posted July 10, 2012 Posted July 10, 2012 Rounding a number during mid summation would produce an incorrect solution, not a correct solution. What does this have to do with my comment?
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) What does this have to do with my comment?[/Quote]The point of contention was whether or not to round the solution from post#84 during mid summation at [math]n = 1687[/math] and [math]l = 4[/math]. [math]\pi = \sum_{n=0}^{\infty} \left(- \frac{1}{4} \right)^n \left( \frac{1}{1+2n} + \frac{2}{1+4n} + \frac{1}{3+4n} \right)[/math] Integer sum: [math]n \; (0,1,2,4,5,7,9,10,12)[/math] Reference: Wolframalpha - sum formulas Edited July 10, 2012 by Orion1
D H Posted July 10, 2012 Posted July 10, 2012 Again, your assumption is that the computer 'knows' that the solution is pi, which it does not. The same goes for your silly 1687 value. Just because the value isn't known doesn't mean the error isn't known. This is a monotonically decreasing alternating series. The first omitted term provides an upper bound on the error. This latest set of posts represents a massive sidetrack. Orion, you appear to have missed this post: Ok, but that Ramanujan series converges much faster than this one. That's kind of the point of this thread. The series under discussion in the last bunch of posts is a terrible way to estimate pi. It is very, very slow to converge. The series upon which this is based, the Maclaurin series for arctan(x), is also a terrible way to estimate arctan(x). It is not how your computer computes the inverse tangent.
studiot Posted July 10, 2012 Posted July 10, 2012 (edited) The point of contention was whether or not to round the solution from post#84 during mid summation at and . Not in the posted computer program I referred to it wasn't. Edit I apologise you were correct. Looking at posts#84 and #85 I see that this was for a different solution from the one I was looking at, which was your arctan solution. However my original point is still valid. some early computers used truncating not rounding and you always had to be aware which was which in those days. I have long since discarded all my Commodore paperwork so I can't look it up now. Edited July 10, 2012 by studiot
Orion1 Posted July 10, 2012 Posted July 10, 2012 (edited) The series under discussion in the last bunch of posts is a terrible way to estimate pi. It is very, very slow to converge. The series upon which this is based, the Maclaurin series for arctan(x), is also a terrible way to estimate arctan(x). It is not how your computer computes the inverse tangent.[/Quote]I agree, I think I managed to pick absolutely the worst series listed in that reference from Wikipedia for my initial evaluation. It seemed like such a simple harmless equation at the time! Is it possible to determine which series was used for the Commodore 64 arctan(x) function? I did manage to achieve [math]n = 12[/math] at [math]l = 9[/math] on post#96. However my original point is still valid. some early computers used truncating not rounding ...[/Quote]On the Commodore 64, [math]4 \arctan (1)[/math] at [math]n_9 = 6[/math] at [math]l = 9[/math], where [math]\pi[/math] at [math]n_9 = 5[/math], which means that the Commodore 64 rounds up only at [math]l = 9[/math]. Edited July 10, 2012 by Orion1
doG Posted July 10, 2012 Posted July 10, 2012 (edited) Again, your assumption is that the computer 'knows' that the solution is pi, which it does not. No, that's not my assumption. My statement is the same as DH's, that you stated that you calculated the integer sums required to complete each numerical place, i.e. [math]\pi = 4 \sum_{n=0}^{\infty} \frac{(-1)^n}{2n+1}[/math]I calculated the integer sum steps required to complete each numerical place, note that these numbers are fundamental to this equation and are independent of any computer specifications. (i.e. CPU, RAM, Memory, OS, basic language, etc.)Integer sum:[math]n \; ( \text{2}, \text{18}, \text{118}, \text{1687}, \text{10793}, \text{136120}, \text{1530011}, \text{18660287}, \text{155974698})[/math]Numerical place:[math]n_l \; (3,1,4,1,5,9,2,6,5)[/math]Numerical length:[math]l \; (1,2,3,4,5,6,7,8,9)[/math]Example:[math]4 \sum_{n=0}^{1687} \frac{(-1)^n}{2n+1} = 3.141... \; \; \; l = 4[/math]Note that [math]l = 9[/math] required a compiler. You stated the completed value of pi to the 4th numerical place is 3.141 when it is actually 3.142. The fault in this is not the computer's, it is yours. BTW, if you have a Windows machine you can download qbasic and run your program on there faster than your C64. The language is pretty much the same. Edited July 10, 2012 by doG
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now