Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculating Pi

  1. Mar 20, 2005 #1
    In what way can i calculate PI and output the result to the screen ?
    I heard from my friedn that MC method is good but is there any other ways to do that ? also, how many decimal digits am I able to output the result ?
    Thank you in advance

    -KMCB1234
     
  2. jcsd
  3. Mar 21, 2005 #2
    Well for what purpose are you trying to calculate pi and what screen are you displaying it on??
     
  4. Mar 21, 2005 #3
    If you are trying to write something to test the speed of computer or machine... or if you just want a basic way of calculating pi
    i might suggest

    since
    [tex] arctan(1)=\frac{\pi}{4} = 1 - \frac{1}{3}+\frac{1}{5}-\frac{1}{7}+\frac{1}{9}[/tex]...
    just multiply by 4 and have your program run a loop
    [tex] \pi= 4-\frac{4}{3}+\frac{4}{5}-\frac{4}{7}+\frac{4}{9}[/tex]...
     
  5. Mar 21, 2005 #4
    Example code for TI-83

    Pgrm Pi
    Clrhome
    4>p
    3>n
    0>s
    lbl AA
    Disp "Pi",p
    If s=0
    then
    p-(4/n)>p
    1>s
    n+2>n
    goto AA
    End
    If s=1
    then
    p+(4/n)>p
    0>s
    n+2>n
    End
    Goto AA
     
    Last edited: Mar 21, 2005
  6. Mar 21, 2005 #5
    That should work I haven't tested it I just wrote it... I wrote a similar program a long time ago and I think I did something similar. This isn't the quickest way to calculate pi but its a good one if you want to see digits slowly change into pi.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Calculating Pi
  1. C++ pi (Replies: 4)

  2. Excel + Calculations (Replies: 9)

Loading...