Calculating PI with Different Methods - KMCB1234

  • Thread starter Thread starter KMCB1234
  • Start date Start date
  • Tags Tags
    Pi
Click For Summary

Discussion Overview

The discussion revolves around various methods for calculating the mathematical constant π (pi) and how to display the result on a screen. Participants explore different approaches, including the Monte Carlo method and series expansions, while also considering the context of use and output precision.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • KMCB1234 inquires about methods to calculate π and mentions the Monte Carlo method, seeking alternatives and information on output precision.
  • One participant questions the purpose of calculating π and the type of screen used for display, suggesting context may influence the method chosen.
  • Another participant proposes using the arctan series expansion as a method to calculate π, providing a formula and suggesting a loop for implementation.
  • A participant shares example code for a TI-83 calculator that implements a method to calculate π, although they note it may not be the fastest approach.
  • There is a mention that the provided code has not been tested, and the participant reflects on a similar program they wrote in the past, indicating uncertainty about its efficiency.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best method to calculate π, and multiple approaches are discussed without resolution on which is superior.

Contextual Notes

There are limitations regarding the assumptions about the context of use, such as the purpose of calculating π and the specifications of the display screen, which may affect the choice of method. Additionally, the efficiency of the proposed methods remains unresolved.

KMCB1234
Messages
18
Reaction score
0
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
 
Computer science news on Phys.org
Well for what purpose are you trying to calculate pi and what screen are you displaying it on??
 
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]...
 
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:
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.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
2K
Replies
3
Views
4K
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
4
Views
4K
Replies
14
Views
973
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
16
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K