Pi with bad calculator
|
|
Thread rating:  |
BioFreak - 19 Mar 2007 01:45 GMT While vacationing in the Ozarks you're stuck with a little piece of grocery store calculator whose extravagance doesn't go beyond a mere square root button. But you're doing a back of the envelope calculation of something that begs for a value for Pi way better than 3.1415 which you can remember for sure. Other than cursing yourself for not remembering the next few digits what else can you do to manage?
 Signature "khodAyA, marA az in fAje'eye palide _maslahat parasti_, ke chon hamegir shodeh vaghAhatash az yAd rafteh, va bimAri'i shodeh ke az farte omumiyyatash har ke az An sAlem mAndeh bimAr minamAyad, masun bedAr, tA be ra'Ayate maslahat haghighat rA zebhe shar'i nakonam."
- Ali Shari'ati
Eric Gisse - 19 Mar 2007 02:21 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? 355/113
> -- > [quoted text clipped - 8 lines] > > - Ali Shari'ati BioFreak - 19 Mar 2007 02:47 GMT >> While vacationing in the Ozarks you're stuck with a >> little piece of grocery store calculator whose [quoted text clipped - 6 lines] > > 355/113 That gives two more significant figures, which is great. This didn't happen of course in the ozarks but in my bed last week :-) Too lazy to get up and go to the other room. I did curse though.
 Signature "kolAhe kachal rA Ab bord goft barAye saram goshAd bud!"
Timo Nieminen - 19 Mar 2007 02:31 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? Of course, you mean 3.1416 as the 5 digit approximation.
There are the usual mnemonics such as "How I need a drink. Alcoholic, of course, after the heavy chapters involving quantum mechanics."
Or rational approximations such as 355/113, known for about 1.5 millenia, allowing you to get 7 digits of precision through memorisation of a mere 6!
 Signature Timo Nieminen - Home page: http://www.physics.uq.edu.au/people/nieminen/ E-prints: http://eprint.uq.edu.au/view/person/Nieminen,_Timo_A..html Shrine to Spirits: http://www.users.bigpond.com/timo_nieminen/spirits.html
mmeron@cars3.uchicago.edu - 19 Mar 2007 02:54 GMT >> While vacationing in the Ozarks you're stuck with a >> little piece of grocery store calculator whose [quoted text clipped - 13 lines] >allowing you to get 7 digits of precision through memorisation of a mere >6! If needed. Can't think of many back of the envelope calculations for which the rule "pi is 3, pi^2 is 10" is not good enough.
Mati Meron | "When you argue with a fool, meron@cars.uchicago.edu | chances are he is doing just the same"
BioFreak - 19 Mar 2007 03:52 GMT > If needed. Can't think of many back of the envelope calculations for > which the rule "pi is 3, pi^2 is 10" is not good enough. Not when both very large and very small numbers are simultaneously present.
Back of the envelope calculations compromise accuracy. But it sometimes needs high precision to attain even that.
> Mati Meron | "When you argue with a fool, > meron@cars.uchicago.edu | chances are he is doing just the same" "No Lord but Jehovah; no tax but that of the Temple; no friend but the Zealots."
 Signature
"yeduneh sar dAreh hezAr sodA "
BioFreak - 19 Mar 2007 19:09 GMT > Back of the envelope calculations compromise accuracy. > But it sometimes needs high precision to attain even > that. No it can easily be said the opposite way also. The first sentence I mean. It depends on where the absence of precision is applied. To the plan of solution or to the numbers involved. In what I said it applied to the plan.
 Signature "zertesh ghamsur shod."
BioFreak - 19 Mar 2007 03:23 GMT >> While vacationing in the Ozarks you're stuck with a >> little piece of grocery store calculator whose [quoted text clipped - 6 lines] > > Of course, you mean 3.1416 as the 5 digit approximation. No I had no clue what came after 5 in there.
> There are the usual mnemonics such as "How I need a drink. Alcoholic, of > course, after the heavy chapters involving quantum mechanics." > > Or rational approximations such as 355/113, known for about 1.5 millenia, > allowing you to get 7 digits of precision through memorisation of a mere > 6! Remembering 6 digits, I found out just now, can get you 9 significant figures if you use Ramanujan's approximation. It does need the square root button. Calculate 97.5-(1/11), then take the square root of the result two times :)
 Signature "hamAnA ke tA rastkhiz in sokhan miyAne bozorgAn nagardad kohan"
Richard Tobin - 19 Mar 2007 03:27 GMT >There are the usual mnemonics such as "How I need a drink. Alcoholic, of >course, after the heavy chapters involving quantum mechanics." Now I, even I, would celebrate in rhymes unapt The great immortal Syracusan rivaled nevermore Who in his wondrous lore passed on before Gave men his guidance how to circles mensurate.
-- Richard
 Signature "Consideration shall be given to the need for as many as 32 characters in some alphabets" - X3.4, 1963.
Nomen Lapetos - 19 Mar 2007 02:39 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? you don't need any more precision than that.
What precision does a slide rule have ?
Phil Holman - 19 Mar 2007 05:12 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? Taylor Series ............Pi/4 = 1 - 1/3 + 1/5 - 1/7.........etc
Leibnitz Formula ........ Pi/8 = 1/(1*3) + 1(5*7) + 1(9*11).......etc
Nothing fast here; you have to generate many terms in the series to get even a moderate accuracy.
Phil H
Sam Wormley - 19 Mar 2007 05:21 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? http://en.wikipedia.org/wiki/Euler's_identity
Jim Black - 19 Mar 2007 05:58 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? Well, there are nice algorithms for doing this, but the only one I remember off the top of my head is
pi = 4/1 - 4/3 + 4/5 - 4/7 + ...
and that converges way to slow. And if I could look up an algorithm, I could look up pi.
So it's back to first principles. We can use the old trick of doubling the number of sides in a regular polygon repeatedly to approximate a circle. So in my head I draw a little diagram containing half of a side of an n-gon, and a side of a 2n-gon, and lines connecting everything to the center. I set the radius of the circle to one, and I'll call the length of the half-side of the n-gon y. By two applications of the Pythagorean theorem, the length of the 2n-gon side is:
sqrt( y^2 + (1 - sqrt(1-y^2))^2 )
Simplifying, we get:
sqrt( 2 - 2 sqrt(1-y^2) )
So what we need to iterate is
s' = sqrt( 2 - 2 sqrt(1 - s^2/4) ),
starting from s=1 in the case of the hexagon. But notice that we would be taking a square root and then immediately squaring it, which is clearly wasteful. So let's simplify the operations we have to do between two of the square roots that can't be eliminated:
1 - (sqrt(2-2x))^2 / 4
= (x + 1)/2
That isn't so painful, after all. First, we do the calculation up to the square root from s=1, getting
sqrt(3/4).
Then we iterate
x' = sqrt((x + 1)/2)
N times, where N is some large number. Then we finish off the calculation of the side length with
s = sqrt(2 - 2x).
Last, we multiply by 3 * 2^(N+1) to get pi.
I tried this for N = 20 on my PC's simulacrum of a stupid calculator.
I got: 3.1415926535897605995224090804006 pi = 3.1415926535897932384626433832795
On a real stupid calculator, though, I'd be a bit worried about loss of precision. Notice that at the end of the calculation,
sqrt(2 - 2x) ~ pi / 3 / 2^(N+1)
so
x ~ 1 - pi^2 / 9 / 2^(2N+3).
That's going to limit how far you can take the calculation out, unless you want to spend even more time thinking and come up with a clever way to get around the problem.
-- Jim E. Black
The Ghost In The Machine - 19 Mar 2007 07:18 GMT In sci.physics, Jim Black <tramspap@yahoo.com> wrote on 18 Mar 2007 21:58:45 -0700 <1174280325.623898.235740@o5g2000hsb.googlegroups.com>:
>> While vacationing in the Ozarks you're stuck with a >> little piece of grocery store calculator whose [quoted text clipped - 77 lines] > -- > Jim E. Black This isn't too bad. I might approach this from a slightly different perspective, by noting that the perimeter is N times the side, for some value of N, then taking that chord as an abstract value, and computing the perimeter directly.
So let's assume s is the side of a regular polygon inscribed in the circle, and p = N * s is our starting estimate for 2*pi. Therefore, s/2 is the side of a right triangle whose hypotenuse is 1 (the radius of a unit circle); the other side is therefore sqrt(1 - s^2/4). Another right triangle has 1 - sqrt(1 - s^2/4) as one side (this is the radius between chord and the unit circle), s/2 as the other side, and the new hypotenuse s'; this new hypotenuse is of course
s' = sqrt((1 - sqrt(1 - s^2/4))^2 + s^2/4) = sqrt((1 + 1 - s^2/4 - 2*sqrt(1 - s^2/4)) + s^2/4) = sqrt(2 - 2*sqrt(1 - s^2/4))
Since p = N * s and p' = 2 * N * s', we can multiply both sides by 2 * N and get:
p' = 2 * N * sqrt(2 - 2*sqrt(1 - s^2/4)) = 2 * sqrt(2*N^2 - 2*N^2*sqrt(1 - s^2/4)) = 2 * sqrt(2*N^2 - N*sqrt(4 * N^2 - N^2*s^2)) = 2 * sqrt(2*N^2 - N*sqrt(4 * N^2 - p^2))
Not the best of expressions -- I was hoping to simplify N out entirely -- but one can start with N = 6, p = 6 (a regular hexagon) and hope for the best. I get:
N p pp(N,p) 6 6.000 6.211657082460498296373572103 12 6.211657082460498296373572103 6.265257226562476394323498940 24 6.265257226562476394323498940 6.278700406093734414270293643 48 6.278700406093734414270293643 6.282063901781019276222705853 96 6.282063901781019276222705853 6.282904944570924150901218618 192 6.282904944570924150901218618 6.283115215823715291032926690 384 6.283115215823715291032926690 6.283167784296636817337939207 ... 6.283185307179586476925286767
I can't say I'm thrilled with this but at least it's converging about as fast, or faster than, 1/N. The main problem with my variant is the outer subtraction, which will lose precision for large N.
If one takes q = (4*N^2 - p^2), q' = (16*N^2 - p'^2), then
q' = 16*N^2 - (4 * (2*N^2 - N*sqrt(q))) = 8*N^2 + 4*N*sqrt(q)
This expression will not lose precision because of subtraction, except at the final step where we calculate p = sqrt(4*N^2 - q). However, q starts out rather large -- for N = 6, q = 108 -- and gets larger. A non-exponential calculator might have problems. :-)
 Signature #191, ewill3@earthlink.net Useless C++ Programming Idea #10239993: char * f(char *p) {char *q = malloc(strlen(p)); strcpy(q,p); return q; }
-- Posted via a free Usenet account from http://www.teranews.com
Uncle Al - 19 Mar 2007 22:47 GMT > While vacationing in the Ozarks you're stuck with a > little piece of grocery store calculator whose [quoted text clipped - 4 lines] > Other than cursing yourself for not remembering the > next few digits what else can you do to manage? 355/113. Difference is 0.27 ppm absolute. Easy to remember... 113355, unless you are an idiot
> - Ali Shari'ati Idiot.
 Signature Uncle Al http://www.mazepath.com/uncleal/ (Toxic URL! Unsafe for children and most mammals) http://www.mazepath.com/uncleal/lajos.htm#a2
Thomas Johnson - 21 Mar 2007 02:07 GMT > > While vacationing in the Ozarks you're stuck with a > > little piece of grocery store calculator whose [quoted text clipped - 11 lines] > > Idiot. 3.14159--I haven't had any problem remembering that since I was a sophomore in high school. Why waste time with 113355 and divide this part by that part?
Who needs pi to anything beyond 3 on a desert island? If so, 3.14 should be good enough.
The Ghost In The Machine - 21 Mar 2007 08:45 GMT In sci.physics, Thomas Johnson <thomas_johnson00@hotmail.com> wrote on 20 Mar 2007 18:07:11 -0700 <1174439231.950267.51310@l77g2000hsb.googlegroups.com>:
>> > While vacationing in the Ozarks you're stuck with a >> > little piece of grocery store calculator whose [quoted text clipped - 18 lines] > Who needs pi to anything beyond 3 on a desert island? If so, 3.14 > should be good enough. The Earth's orbit is 1.501 * 10^11 m in radius, give or take (it's actually elliptical and slowly precesses). Pi to 25 decimal places would give one an accuracy of less than the classical radius of a proton.
Anything more than that is probably gravy. :-)
 Signature #191, ewill3@earthlink.net /dev/brain: Permission denied
-- Posted via a free Usenet account from http://www.teranews.com
Ben Newsam - 21 Mar 2007 12:02 GMT >3.14159--I haven't had any problem remembering that since I was a >sophomore in high school. Why waste time with 113355 and divide this >part by that part? Indeed. If anyone still has trouble remembering pi, the following might help, attributed to Harvey L. Carter, professor of History at Colorado College:
'Tis a favorite project of mine A new value of pi to assign I would fix it at 3 For it's simpler, you see, Than 3.14159
Geert-Jan Uytdewilligen - 22 Mar 2007 17:10 GMT > > > While vacationing in the Ozarks you're stuck with a > > > little piece of grocery store calculator whose [quoted text clipped - 18 lines] > Who needs pi to anything beyond 3 on a desert island? If so, 3.14 > should be good enough. In old egypt they said Pi=3 In the Netherlands we have a poem, and from every word we count the characters. "Ook u kunt u zeker vergissen, uw zwakke brein kan altijd verkeerd beslissen." Wich results in Pi=3,141592653589 My favourite way of calculating pi is this: take a circle with radius one. Divide it in n segments. Make triangles of the segments. Calculate the area of the triangles. Let n go to infinity. A=Pi=lim (n->infinity) n* tan (180/n) Does your calculator at least have "tan"?
Mitchell Jones - 31 Mar 2007 04:05 GMT > > > > While vacationing in the Ozarks you're stuck with a > > > > little piece of grocery store calculator whose [quoted text clipped - 29 lines] > Calculate the area of the triangles. Let n go to infinity. A=Pi=lim > (n->infinity) n* tan (180/n) ***{Pi is not merely the ratio of the circumference of a circle to its diameter, but also the ratio of half the circumference to the radius. Your method uses a semicircle of radius 1, divides it into n/2 polygon segments, drops a perpendicular from the center of the semicircle to the midpoint of each segment, and takes the tangent of the resulting central half-angle. (I am assuming the polygon segments are inscribed within the semicircle, rather than being outside it, since that gives the most accurate approximation.) Since the side opposite the angle is half the length of a polygon segment, there are n of them in the semicircle, and the angle is therefore 180/n degrees. Unfortunately, the side adjacent to the angle is shorter than the radius, hence less than 1. Fortunately, however, the adjacent side approaches 1 as the central half-angle approaches zero, and so the method works when the tangent is used. But the reason it works is that tan x approaches sin x as x approaches zero. Thus a better approximation is:
n sin (180/n)
It is closer to the actual value of pi at all values of n than is n tan (180/n), though at large values of n (above 10^5 on my calculator) the differences cease to matter.
For example, if n = 6, then n tan (180/n) = 6 tan (180/6) = 3.464..., whereas n sin (180/n) = 6 sin (180/6) = 3. Note that 3 is closer to 3.14159... than is 3.464...
Why does the sine work better than the tangent? Because the sine is the ratio of the opposite side to the hypotenuse, and the hypotenuse is always exactly equal to 1. The tangent is the opposite side divided by the adjacent side, and, as noted earlier, the adjacent side is always less than 1, though it converges on 1 as the central half-angle approaches 0.
Result: the tangent works, but the sine works better.
This is a great way to get pi on a calculator that has no pi key, but has trig functions. For example, 10^20 sin (180/10^20) = 3.14159265359, which is all the significant digits my pocket calculator allows. It has a pi function but it is no better, giving exactly the same number. (On my calculator the smallest value of n that gives that result to 12 significant digits is 10^7.)
There are lots of examples where it is useful to be aware that as the angle approaches zero, the sine and the tangent converge. In many of them, the tangent may be used when the angle is very small, but the sine must be used when it is large. Stellar aberration, for example, can just as well be calculated using the tangent as the sine, in most cases, because the angles tend to be very small. The aberration of downward falling raindrops caused by the forward motion of an automobile, on the other hand, is going to be a large angle, and calculating such things requires use of the sine.
Very interesting stuff.
--Mitchell Jones}***
> Does your calculator at least have "tan"? ***************************************************************** If I seem to be ignoring you, consider the possibility that you are in my killfile. --MJ
BioFreak - 26 Mar 2007 03:29 GMT >> - Ali Shari'ati > > Idiot. Listen Chosen, first time you mistook him for an idiot it cost you your Island of Stability. Next time it may cost you your Hellhole of Yitzrael :)
 Signature "degar ze manzele jAnAn safar makon darvish ke seyre ma'naviyo konje khAnghAhat bass
falak be mardome nAdAn dahad zemAme morAd to ahle fazliyo dAnesh hamin gonAhat bass
be hich verd degar nist hAjatat hAfez do'Aye nimshabo darse sobhgAhat bass"
- Hafez
|
|
|