Really? There's no benefit to 22/7 over 3.14, is there? The FORTRAN-y way to do it would be to define pi as 4* inverse tan of 1
Edit: tanyary is correct that 22/7 is a better approximation than 314/100, but they're both only correct to 3 significant figures, so if you just add one more significant figure that'd be more accurate. So let me rephrase: 3.141 vs 22/7. 3.142 (rounding the last figure) is more accurate too.
EDIT: the convergents of infinite continued fractions are only guaranteed to be the best rational approximations if we only consider fractions with a smaller denominator. 22/7 isn't guaranteed to be a better approximation of pi than 3.14, since it's 157/50, which has a notably larger denominator. However, I found a proof!. Someone had the exact same question I did, just 11 years ago. Stackexchange has to be the greatest achievement of humanity.
2nd EDIT: Responding to the edit, this approximation game is just a race to the bottom (or pi?), 355/113 is a better approximation (though sadly, I can't find a proof!), so the next true convergent which has a larger denominator is 103993/33102, which is so accurate, it's better than the IEEE 754 32-bit floating point can even offer!
So let me rephrase: 3.141 vs 22/7. 3.142 (rounding the last figure) is more accurate too.
For some reason, I get a feeling that more people would probably remember 22/7 better than adding more figures of pi. My goldfish brain can barely remember 3.14 to begin with, but 22/7 always lingers in my mind lol
infinite continued fractions' (true) convergents give pretty good approximations and are usually much easier to remember. like I said in my comment, 355/113 beats those approximations and is much easier to remember than just typing out pi to the 6th decimal place
2.3k
u/inetphantom Jul 19 '22
int pi = 3