|
||||
Title: Is Pi different? Post by Benoit_Mandelbrot on Jan 19th, 2004, 10:24am Pi might be different than we thought, according to my math programs. Here is what I am doing. I want to find a fast algorithm for pi on my own. I'm using sin(x)=0, and thinking x=[pi]. So I used the newtonian method to calculate roots, and I got xn+1=xn-tan(xn) with x0=3.142. Since my math programs can do anything to arbitrary precision, I came up with 61 digits. But the thing is no matter how many iterations I did, the same result kept comming up. So now I thought to develop another algorithm, and I'm using tan(x)=0. Applying the newtonian method, I got xn+1=xn-sin(xn)*cos(xn) with x0=3.142. This method converged on [pi] to 60 decimals in three iterations. Why doesn't my x-tan(x) method work? Check the attachment pic for what was happening. By the way, the last argument specifies how many iterations are done. |
||||
Title: Re: Is Pi different? Post by towr on Jan 19th, 2004, 10:36am try using explicitly sin(x)/cos(x) iso tan(x).. I'm curious if there's a difference there.. |
||||
Title: Re: Is Pi different? Post by towr on Jan 19th, 2004, 10:54am heh.. if I insert the end value you get with tan(x) as the starting value in the one with sin(x)cos(x) I get a slightly different answer from the other two.. Also, if you take 3.141 as starting value with the tan(x) version, you do get all digits correct.. Somehow I don't think it's reasonable to expect more than half the digits to be correct. |
||||
Title: Re: Is Pi different? Post by Benoit_Mandelbrot on Jan 19th, 2004, 11:39am Is it possible that the Newtonian method doesn't work when the precision digits gets larger? Can the Newtonian method be wrong? I tried the same thing with Mathematica's Nest function, and got the same thing. Because the next result is closer to [pi] then the previous, it shouldn't matter if we start with 3.142 or 3.141. Perhaps x0 must always be less than [pi]. After I initially posted, I noticed that sin(x)cos(x)=sin(2x)/2. Will that make any difference? I can't test any of this stuff because Derive 5 is at home, and I'm at school during the day. There are security settings that prevent the installation of Derive at school. |
||||
Title: Re: Is Pi different? Post by lochnesshamster on Jan 19th, 2004, 12:28pm >Is it possible that the Newtonian method doesn't work when the precision digits gets larger? No, though there are certain circumstances when it doesn't converge. This doesn't appear to be one of them, though-- since it does converge, just to the wrong number. >I noticed that sin(x)cos(x)=sin(2x)/2. Will that make any difference? Well, it requires one less evaluation of a trig function, which will make your algorithm faster. But, like you said, they're equal, so it *shouldn't* make any difference. If it does make a difference, then I would begin to suspect that the program you are using is lying about the amount of precision it has. I'm not sure what advice to give you. Maybe tan() requires even more digits of internal precision to give you an answer with 60 real digits. You could try increasing the precision beyond 60 and see if it affects the answer at all. Sorry I can't help otherwise! |
||||
Title: Re: Is Pi different? Post by Sameer on Jan 19th, 2004, 12:46pm I would assume any formula conversions you do will affect your result. Why? Something called finite register effect. Every calculating machine has to store numbers in what we call registers (flip flops) and it defines finite amount of bits to do that. Ultimately your choice of formula will affect it. Ok so now concentrating on the original problem: I was looking at the graph of sin(x), cos(x) and tan(x) between pi/2 and 3*pi/2 with pi as the middle point. Obviously 3.142 falls on the right of the mid point whereby sin is decreasing and cos is trying to increase. I would say this is why that formula is failing. Have you tried with 3.140 ? I believe it should converge nicely in 3 iterations. Still thinking about other possible reasons. |
||||
Title: Re: Is Pi different? Post by towr on Jan 19th, 2004, 12:48pm The problem is quite simple, tan(x) is 0 in 61 digits precision for a whole range of x. And the same goes for sin(x)cos(x). Sometimes you're lucky and get the 'right' answer, and in other cases you get the 'wrong' answer. In both cases though it has converged as far as it can, since the answer doesn't change on the next iteration. And in both cases it's the _right answer_ (there's a range of right answers), you're just expected a higher precision in the end result than you ought to. |
||||
Title: Re: Is Pi different? Post by Rezyk on Jan 19th, 2004, 1:06pm Can someone try running these commands on the program (and comparing it to the theoretical answers given)? Code:
|
||||
Title: Re: Is Pi different? Post by towr on Jan 19th, 2004, 1:24pm I get tan(y)=0, not .000000000000000000000000000000003812326676728107990542802543.. (I also get sin(y)=0) |
||||
Title: Re: Is Pi different? Post by Rezyk on Jan 19th, 2004, 2:24pm I presume the program will also claim that TAN([pi])=0. Then the program's tangent function just isn't providing as much accuracy as expected in this case... The slope of tangent is >=1 throughout this interval, so the difference between TAN(y) and TAN([pi]) is at least (y-[pi]) and should be observeable with the given precision, instead of both showing as 0. |
||||
Title: Re: Is Pi different? Post by towr on Jan 19th, 2004, 2:35pm on 01/19/04 at 14:24:32, Rezyk wrote:
Quote:
|
||||
Title: Re: Is Pi different? Post by Rezyk on Jan 19th, 2004, 2:48pm I wonder what the program would draw for the graph of tangent between the 2 points... It would have to either give more accurate readings or obscenely distort tangent's shape. |
||||
Title: Re: Is Pi different? Post by Benoit_Mandelbrot on Jan 20th, 2004, 6:06am I found out how to get all digits correct up to how much you want. The thing is to get more decimal places for pi, you'd need to start with a more accurate approximation for pi, based on ceiling(n/25)=m where n is the number of decimals and m is the number needed to start with. Using this method, I was able to get 1000 digits correct with my algorithm. |
||||
Powered by YaBB 1 Gold - SP 1.4! Forum software copyright © 2000-2004 Yet another Bulletin Board |