View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Dana DeLouis
 
Posts: n/a
Default Higher precision: can one get it?

Hi. I find these math problems interesting also. Using the Math add-inn is
the way to go. However, I was just showing how one can get a little "higher
precision" when calculating Pi using Excel. It's not really obvious that it
can be done at all. (...that's why we all hang out here :)
Actually, I became interested in this a long time ago while studying Fourier
Analysis. I was studying Excel's Fourier function and learning how to do
large multiplications / divisions very fast via Excel's Fast Fourier
Transorm. A good test for speed was calculating Pi.

Not sure, but you may find this article interesting reading.
http://documents.wolfram.com/mathema...ulatingPi.html

Pi = (2^n) * S(2 - S(2+S(2+...))),


Although this in not the same equation, here's a very similar equation.
(Vieta's equation from above link)

Output is:
Real Pi= 3.1415926535897932384626433832795....
My Pi= 3.1415926535897932384626433827

Sub Pi_Vietas_Formula()
'// = = = = = = = = = = = = = = = = = = = = =
'// Vieta's Formula for Pi
'// 2/Pi = 0.5*Sqrt(2)* (0.5*Sqrt(2+Sqrt(2)))* (0.5*Sqrt(2+Sqrt(2+Sqrt(2))))
....

'// By: Dana DeLouis
'// Note: Pi = 3.1415926535897932384626433832795...
'// = = = = = = = = = = = = = = = = = = = = =

Dim n
Dim t
Dim x
Dim Pi
Dim j As Long

x = CDec(0)
Pi = x + 1
For j = 0 To 45
n = 2 + x
t = CDec(Sqr(n))
x = (t * t + n) / (2 * t)
Pi = Pi * x / 2
Next j
Pi = 2 / Pi

Debug.Print "Real Pi= " & "3.1415926535897932384626433832795...."
Debug.Print " My Pi= " & Pi
End Sub

--
Dana DeLouis
Win XP & Office 2003


"Richard Lionheart" wrote in message
...
Hi Dana,



Thank you very much for the worked-out example: an excellent result. I
presume that you are, like me, a mathematician. But if I were to use
inverse trig functions, I would have started with Pi = 8 * arctan(1).
But I suspect that will converge rather slowly compared to the expression
you constructed, whose correctness is not obvious to me. But no matter:
I'll pop it into Excel and appreciate the result. I'm using XP-Pro/SP2
and Office Pro 2003



Below, in detail, is what I wanted and what I got. I'm writing this
narrative mainly as a review for my grandson and forwarding it to you in
case you have an academic interest in the matter. The boy called me the
other day because he wanted to earn some money for Christmas and knows
that I pay him and his siblings whenever they're interested in studying
advanced (for their age) mathematics (or physics, etc.). We negotiated a
price of $2/hr, but in fact renegotiated after the first hour to $4.50/hr
for two additional hours: a king's ransom J



My purpose in seeking additional precision in Excel was to demonstrate to
my 12-yo grandson that determining Pi's value was accessible to even a
child with little more knowledge than elementary algebra and some
Geometry, like Pythagorean Theorem, and a "reasonable" computing tool for
the drudgery.



He had the requisite algebra.



So we spent a half-hour or so studying a beautiful proof of the P.T. at
http://www.cut-the-knot.org/pythagoras/index.shtml (Proof #2). We just
had to learn SAS congruence theorem, the Parallel Postulate and the
theorem that a transversal cutting two parallel lines leads to equality of
alternate interior angles. With a couple of reviews, I believe he'll
have internalized this result.



Then we worked out the first approximation of Pi from an inscribed square,
then from an inscribed octagon and so on. That led to recursive results:

Pi = (2^n) * S(2 - S(2+S(2+...))),

where S is "square root" and n is the number of two's in the right-hand
factor. He followed this derivation pretty well, and I expect in after a
couple of reviews, he'll be able to reproduce it on his own.



The I showed him the Excel version of that calculation using XNumbers that
Niek Otten put me on to. That produced good results
that the boy could take on faith. Finally, I backed it up with a
comparison with a published result from
http://www.uoguelph.ca/zoology/devob...isQuiz/pi.html. It
recomputed a table of 30 cycles with a precision of 60 place instantly on
my 2GHz Pentium with 500MB RAM. All in all, a very gratifying result.



In fact, we went further that afternoon. I guided him in computing the
slope at various points of y=x^2 using [f(x+?x) - f(x)] / ?x. I derived
a couple of identities for differentiating polynomials and gave him a few
more to accept on faith. He spent the final hour differentiating simple
polynomials. I was most pleased by the fact that he prove to himself
that Dx(2x2 * 3x3) could be computed as Dx(6x5) and thus 30x4, or as

2x2 * Dx(3x3) + Dx(2x2) * 3x3.



When I tell him that I think he's gifted in mathematics, he thinks my
opinions are based solely on my love for him. That's kids for you J.



Best wishes,

Richard Muller