# Approximating Pi with Power series

1. Apr 29, 2010

### mickellowery

How can I go about using a power series representation of arctan(x) to approximate Pi to five digits?

2. Apr 29, 2010

### CompuChip

What is 4 arctan(1)?

3. Apr 29, 2010

### mickellowery

Yea that's the route I was thinking I should go because 4arctan(1) would be Pi, but it seems like there should be more to it than that.

4. Apr 29, 2010

### CompuChip

I don't think there is.
The only problem would be, probably, that when you develop arctan(x) around x0 = 0 with x - x0 = 1, the series converges very slowly.

For example, I let Mathematica evaluate the series around x = 0 for the first 10 000 terms, and got 3.14139, still .00020 off.
For the first 50 000 terms, I got 3.14155, correct to 4 decimal places, but that already took 12 seconds to compute.

5. Apr 29, 2010

### mickellowery

Thanks so much Chip I appreciate the help. I think I've got it, but if not I'll be back. Thanks again.

6. Apr 29, 2010

### Martin Rattigan

7. Apr 30, 2010

### CompuChip

Right... I don't feel guilty for not coming up with that immediately. How the *** did people ever find that :P

8. May 3, 2010

### Count Iblis

You can still use that:

pi =4 arctan(1)

as Compuchip suggested but still obtain a fast converging series. So, we start with the slowly converging series

pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ...

and manipulate it as follows. Let's keep the terms up to 1/21 only, to make clear I'm not cheating here. Consider the function:

1 - x/3 + x^2/5 - x^3/7 + x^4/9 - x^5/11 +...+x^10/21

Then for x = 1 this would be a very crude approximation to pi/4. The reason why this approximaton is not so good is because for x = -1 the infinite series diverges. The radius of convergence is 1 and we are thus exactly on the edge of the region where the series converges.

We can do something about that using the following trick. Let's invent a mapping that will send the singularity at x = -1 far away while leaving the point a x = 1 where it is. This mapping, z(x), has to be such that for x to zero z tends to zero, otherwise we won't be able to compute the coefficients of the series in powers of z.

If we choose the mapping:

x = z/(2-z)

Then clearly x = -1 corresponds to the point at infinity in the z-plane. The point x = 1 is now at z = 1, so we can just work out the series in powers of z and insert z = 1. Note that there is now a new singularity at z = 2, so we are well inside the radius of convergence. But this is still not optimal. We can do better by not sending the singularity at x = -1 all the way to infinity. The mapping:

x = 2z/(3-z)

sends the singularity at x = -1 to z = -3 and we also have a singlarity at z = 3. The point x = 1 still corresponds to z = 1. So, we are deeper inside the region where the series converges. If we insert x = 2z/(3-z) in

1 - x/3 + x^2/5 - x^3/7 + x^4/9 - x^5/11 +...+x^10/21

and expand to order z^10, we obtain:

1 - 2 z/9 + 2 z^2/135 - 22 z^3/2835 + 26 z^4/25515 - 422 z^5/841995 +
542 z^6/6567561 - 3838 z^7/98513415 + 5194 z^8/717740595
- 135686 z^9/40911213915 + 63506 z^10/95459499135

For z = 1 this multiplied by 4 is:

3.1415936

You would have needed to sum about a million terms of the original series to obtain such an accurate result. Yet, we obtained this result by manipulating only the first 11 terms of the series. Also you could argue that we used even less terms. We inserted x = 2z/(3-z) and expanded only to order z^10 and then inserted z = 1. This means that in the summation

1 - 1/3 + 1/5 - 1/7 + ... +1/21

we ended up replaced the 1/3 by 1/3 times the 9th order approximation of 2/(3-z) at z = 1 which is 1/3 * (1-3^10). So, we're removing a small part of the second term. From the third term we're removing a bit more, it becomes 1/5 * (1 - 7/3^9), etc. etc. while from the last term we take almost nothing, it get's replaced by 1/21 (2/3)^10.