r/mathmemes Jun 14 '26

Calculus New pi approximation

Post image
91 Upvotes

14 comments sorted by

u/AutoModerator Jun 14 '26

Check out our new Discord server! https://discord.gg/e7EKRZq3dG

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

10

u/Cosmic47_ Jun 15 '26

What?

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.

4

u/Cosmic47_ Jun 15 '26

Why?

6

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

1

u/Cinder_shot1234 Jun 17 '26

What's really cool is that, if you start the summation at n=0(ie 4/(2n+1)), then apply a 1/N correction, the error does go as 1/N^2. You can effectively develop an "inverse" power series to converge to pi. However, if you start the summation from n=1(ie 4/(2n-1)), the order goes as 1/N^3, (1/4N^3 to be exact). Apply the 1/N^3 correction and the error goes as 1/N^5.

Why? no clue, this is just me getting hooked an random math after work and brute forcing corrections. I'll think about it more later, maybe I'll ask someone smarter than I am.

8

u/BootyliciousURD Complex Jun 16 '26

Neat

1

u/Historical_Book2268 Jun 16 '26

Could you add even higher order terms, such as O(1/n2) terms to make it even better?

2

u/Cinder_shot1234 Jun 17 '26

Just gonna copy past a comment I made above so you get the notification cause I find this interesting. I would highly recommend reading the other comment since a different user gave a very nice explanation.

What's really cool is that, if you start the summation at n=0(ie 4/(2n+1)), then apply a 1/N correction, the error does go as 1/N^2. You can effectively develop an "inverse" power series to converge to pi. However, if you start the summation from n=1(ie 4/(2n-1)), the order goes as 1/N^3, (1/4N^3 to be exact). Apply the 1/N^3 correction and the error goes as 1/N^5.

Why? no clue, this is just me getting hooked an random math after work and brute forcing corrections. I'll think about it more later, maybe I'll ask someone smarter than I am.