Calculating Pi in TI Basic Using the Leibniz Formula

Got nothing to do during math class? Then let your calculator calculate Pi! The Leibniz formula states that:

Pi/4 = 1/1 - 1/3 + 1/5 - 1/7 + 1/9 …

This is how to do it on your TI calculator, nicely formated.

: 0 -> N
: 0 -> P
: ClrHome
: Output( 1, 1, "STEP " )
: Output( 2, 3, "PI= " )
: While 1
: 1 / ( (-1)^N(2N+1) ) + P -> P
: Output( 1, 6, N )
: Output( 2, 6, 4P )
: N + 1 -> N
: End

Note that this is a very poor way of calculating Pi, especially with a calculator, since it requires an extremely large amount of steps in order to obtain accurate values. 10,000,000,000 operations are required in order to get only ten correct decimals.

Maybe Related?

3 Comments »

  1. Programming Tutorials…

    I couldn’t understand some parts of this article, but it sounds interesting…

    Trackback by Programming Tutorials — October 25, 2007 @ 8:09 pm

  2. Thanks for this! It’s one of many examples which helped me understand and learn TI-BASIC. It’s very interesting to see my calculator calculating pi in real-time. Very cool.

    Comment by Daniel B. — December 5, 2007 @ 6:28 am

  3. There’s a faster way to do the summation:

    Dips 4*sum(seq((-1)^X/(2X-1), X, 0, i))

    Where ‘i’ is the number of iterations.

    …I find this sometimes yields negative pi…if that’s the case, simple make it ‘Disp -4*sum…’

    Comment by cy3 — May 5, 2008 @ 9:13 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

FireStats iconAnvänder FireStats