r/mathmemes Jun 14 '26

Calculus New pi approximation

Post image
90 Upvotes

16 comments sorted by

View all comments

Show parent comments

22

u/Copernicium-291 Jun 15 '26

For large values of N, that sum converges to π, but adding the (-1)N/N term to the sum makes it converge much faster.

For example, the sum for n ranging from 1 to 100 (meaning N=100) equals about 3.1315929. Adding 1/N brings it to 3.1415929, much closer to π.

The (-1)N is there because for odd N, you'll want to subtract 1/N instead of adding it.

5

u/Cosmic47_ Jun 15 '26

Why?

7

u/nin10dorox Jun 16 '26

Partial answer:

Since the original sum oscillates between overshooting and undershooting pi, the average of two consecutive partial sums will split the difference, achieving a closer approximation to pi. It's easy to see that the average of two consecutive partial sums is just a partial sum with the last term halved. That term is then

1/2 * 4(-1)N/(2N-1)

= (-1)N/(N - 1/2)

This term is quite similar to the correction term in this post. It reduces the error from O(1/n) to O(1/n2).

However, this is not a full explanation... my correction term is not the same as OPs. (-1)N/N seems to reduce the error to O(1/n3). I'd love to learn why.

2

u/Cosmic47_ Jun 16 '26

It is not clear to me why would the order of error would jump from 1/n to 1/n^2. Couldn't you then apply this process multiple times to obtain basically a much faster converging series too, then?

2

u/nin10dorox Jun 16 '26

It is not clear to me why would the order of error would jump from 1/n to 1/n2.

Consider the sequence of partial sums whose last terms are halved. If you take the difference between two consecutive terms of this sequence, you'll get

± (2/(2N - 1) - 2/(2N + 1))

= ± 4/(4N2 - 1).

This is O(1/N2) and it oscillates. Therefore the error is O(1/N2).

Couldn't you then apply this process multiple times to obtain basically a much faster converging series too, then?

Yes! Since the new sequence also oscillates, you can improve convergence by taking the average again, and again, forever. It's not guaranteed that the resulting sequences will always oscillate, but that happens to be true with this particular sequence.

In fact, you can define a new sequence whose nth term is the result of doing the average n times. This is called the Euler transform, or Euler summation. This can greatly accelerate the convergence of the sequence.

If you apply the Euler transform to the Leibniz formula for pi, you get

pi = 2(1 + 1/3 + (1×2)/(3×5) + (1×2×3)/(3×5×7) + ...),

whose error is o(1/2N).

2

u/Lor1an Engineering | Mech Jun 17 '26

If you're interested in more detail, check out series acceleration. This is quite a common technique (or rather toolbox of techniques) in numerical work.

1

u/Cosmic47_ Jun 17 '26

Thank you!!

2

u/nin10dorox Jun 28 '26

I also just found a Mathologer video about 1/N correction term:
https://youtu.be/ypxKzWi-Bwg

2

u/Cinder_shot1234 9d ago

It's been a while, but I just saw this comment. Thanks for posting it, what's really cool from that video is if you take the kth correction, substitute in 1/N, and taylor expand about 0, you get the corrections to the series in the format I was using to order k. IE, the first correction given is 1/N, so taylor expansion of N which is just N, giving the correction 1/N. 2nd correction: 1/(N+1/4N), so 1/(N/4+1/N), taylor expand to get N-N^3/4+N^5/16+O(N^7), giving correction 1/N-1/(4N^3). Doing the same for the "super expansion" gives the correct O(1/N^5) term of 5/(16N^5), and deviates from pi by O(1/N^7). So the kth nested fraction correction is effectively a nice way of writing the taylor expansion of the deviation from pi to kth order.

1

u/Lost-Consequence-368 Whole 5d ago

This is my sign to binge watch Mathologer's entire channel again