Learning in Stereo: Math + Python
David C. Ullrich
ullrich at math.okstate.edu
Tue Apr 4 19:34:39 EDT 2000
David C. Ullrich <ullrich at math.okstate.edu> wrote in article
<38EA329F.4D407309 at math.okstate.edu>...
> Kirby Urner wrote:
>
> > [...]
> > And here's another fast converger [to pi] using every other
> > Fibonacci number:
> >
> > def pifib(n):
> > # return approximation for pi using
> > # arctan(1) = 4 * SIGMA [ arctan(1.0/Fib(2i+1))]
Or arctan(1) = SIGMA [ arctan(1.0/Fib(2i+1))] or something.
> > sum = 0
> > for i in range(1,n+1):
> > sum = sum + math.atan(1.0/fibo(2*i+1))
> > return 4*sum
>
> I didn't know that arctan(1) was equal to that sum,
But it is (heh-heh): you show by induction that the
difference between arctan(1) and the sum of the first n
terms is exactly arctan(1/fibo(2*n+2)) (or 2*n+1 or
something, the notation's different in my notes...)
(This is on-topic because Python got used in finding
the proof: You need to show that x_n -> 0, where the
error is arctan(x_n). A little trigonometry gives a purely
algebraic recurrence involving the numbers x_n. Now you
look at the first few using your favorite rational.py and they
look like 1/3, 1/8, ... then you know what to prove.)
DU
More information about the Python-list
mailing list