Forum

> > Off Topic > How to caculate Pi
Forums overviewOff Topic overviewLog in to reply

English How to caculate Pi

8 replies
To the start Previous 1 Next To the start

old Re: How to caculate Pi

Lee
Moderator Off Offline

Quote
You'll almost always have to re-express pi as the taylor expansion of some trig/complex function. The most primitive formulation of pi can come from the following 2 dimensional definition: r^2 = x^2 + y^2; by setting r = 1, we get the following y(x) = +/- sqrt(1-x^2)

Assuming that the unit circle within the first quadrant takes up 1/4 of the area, we can find the actual value of pi by finding the definite form of
1
4*int(sqrt(1-x^2)) from 0 to 1
If we switch sqrt(1-x^2) into triangular form with:
1
2
3
sin(t) = x
cos(t) = sqrt(1-x^2)
dx = cos(t)dt
We get
1
2
3
4
5
6
7
8
9
10
11
12
13
4*int(cos^2(t)dt)

-> 

sin(t)cos(t) + int(sin^2(t)) = int(cos^2(t))

Where cos^2(t) = 1- sin^2(t)

2int(sin^2) = t - sin(t)cos(t)

=>

2int(cos^2) = t + sin(t)cos(t) (From trig identity)
So the original integral in triangle-form is:
1
2
3
4
5
2(t+sin(2t)/2) -> (sintcost = sin(2t)/2)

Where t = arcsin(x)

[2arcsin(x) + xsqrt(1-x^2)/2]0=>1

For both ends, the second term becomes zero, hence:

pi = 2arcsin(1) (This makes sense, sin(pi/2) = 1)

The taylor expansion of arcsin at x0=0 is:
1
arcsin(x) = sum from 0 to infinity of (2n)!/(4^n (n!)^2 (2n+1)) * (x^(2n+1))

See http://en.wikipedia.org/wiki/Taylor_series for more information.

Alternatively, you can just bruteforce a more simplistic pragmatic discrete integral of sqrt(1-x^2) directly within the program.

old Re: How to caculate Pi

DannyDeth
User Off Offline

Quote
Lol, Lee you really know how to break out the trigonometry! Yes Lee is correct in every manner, but it depends on what you are going to use Pi for. So I'm going to have to ask you what you are using this for? ( *cough* Cheating on ur maths test *cough* )

And Pi has many different way to calculate it not just the usual circle / radius. As you can see by Lee's example. If you are using Python to program this or any other high-level language, google "mathematical module" + the name of your language to get the more complex commands ( like: cosine, tangent, etc ).

old Re: How to caculate Pi

Silent_Control
User Off Offline

Quote
There was also a formula like
1
pi=4/(1+(1^2/(2+3^2/(2+5^2/2+7^2/etc))))
You have to add more 2+(2k+1)^2 fractions for more decimals.

old Re: How to caculate Pi

Lee
Moderator Off Offline

Quote
Silent_Control has written
There was also a formula like
1
pi=4/(1+(1^2/(2+3^2/(2+5^2/2+7^2/etc))))
You have to add more 2+(2k+1)^2 fractions for more decimals.


This is the product expansion of the McClaurine series for either arcsin or arctan into a continuous fraction and is also a viable method for estimating pi. However the proof of this is very high level math, as are the techniques needed to test and solve for the convergence of this product series. (then again, we also have computers that can do dumb calculations)
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview