Finding Pi
As one does, I was generating random arithmetic expressions and scoring by minimum descriptive length and how many digits of it approximated. I don’t really like integer approximations of as a “shorthand”, as they often aren’t particularly short. I figured by exploring a larger space of expresssions I might find something useful. I mostly found noise like:
[ 21/32] best=6.05 digits sqrt(exp(-8) - ((-13) + sqrt(2 ** (-11) - ((-13) + cos(-11) + sqrt(exp(-1) - ((-13) + sqrt(10)))))))
[ 23/32] best=7.71 digits sqrt(10 - (3 - sqrt(sqrt(sqrt(3) ** (-15) - (sqrt(sqrt(11)) + (-13)))) + (-2)) - sin(-5))
[ 20/32] best=6.69 digits sqrt(sqrt((-15) / 10 + log(9)) / exp(10) + (3 / ((-13) + (-10)) + 10))
But I did spot one gem:
I could see this was most likely part of an infinite sum for , which I was glad to confirm! The summation can be expressed recursively as:
f 0 = 3
f n = f(n - 1) + sin(f(n - 1))
or iteratively as
x = x + sin(x)
Why does this compute ?
sin(x):
- is positive when is smaller than , so the sum grows in those cases
- is negative when is larger than , so the sum shrinks towards
- falls off to zero as , so the sum converges
So, the sum or fixed point of the function converges towards given a reasonable starting value, fairly rapidly: the number of accurate digits roughly triples each step.
| step | value | digits |
|---|---|---|
| 0 | 3.00000000000000000000 | 1 |
| 1 | 3.14112000805986735230 | 4 |
| 2 | 3.14159265357219563697 | 11 |
Is it useful?
Like most approximations of , not really. It converges quickly, but repeatedly computing sin (for which you need to know ) is a worse problem than we started with.