# PI aproximation with the ${x\over y^2 } \approx \pi$ pattern

there are commands in mathematica and maple for finding Rational integer forms that approximate a floating point or a decimal number ...

Mathematica function Rationalize

Maple function convert(float, rational, digits)

but i confused to make an algorithm that find the rationals with the pattern :

$${x\over y^2 } \approx \pi$$

for example i saw in a very very old manuscript that mentioned ${300000\over 309^2}$ is the ratio of circumference of a circle and its diameter !

300000/(309 * 309) = 300000/95481 = 3.14198636377


as you saw these integers contains many zeroes and the number 3 have the main role !

so i am very interested to know how they discovered such ration and i request to help us discover other beautiful integer rationals with such pattern please ?

Here is some Mathematica code you can execute. It finds the best x/(y^2) approximation for all y's from 1 to ymax, and it prints the best approximation it has seen so far. Set ymax as high as you like and have fun.

ymax = 1000000;
best = 1;
Do[
x = Floor[y*y*Pi + .5];
approx = x/(y^2);
err = Abs[Pi - approx];
If[err < best,
best = err;
Print[x, " / ", y, "^2 = ", approx // N, "  err = ", err // N]],
{y, 1, ymax}]

• i would like to use your code as a prototype for extension or generalization for finding any desired pattern that may approximate to pi . also translating of it to maple language too ... – Fereydoon Shekofte Sep 16 '15 at 10:50
• @FereydoonShekofte Hey, I appreciate the Accept. Let me know if any of the Mathematica code needs explaining. – Jerry Guern Sep 16 '15 at 11:02

When does a circle with integer radius have area that is nearly a round integer?

then here are the best approximations with at least three zeros and $y<10^4$, found with a program:

      x           y     x/y^2           error
300000        309    3.1419863637792 0.0003937102
600000        437    3.1418711937540 0.0002785402
830000        514    3.1416069887508 0.0000143352
2613000        912    3.1415916435826 0.0000010100
51352000       4043    3.1415927065030 0.0000000529
91236000       5389    3.1415926293435 0.0000000242
149138000       6890    3.1415926407300 0.0000000129
233380000       8619    3.1415926636367 0.0000000100
246113000       8851    3.1415926543257 0.0000000007

• What is the criterion here by which approximations make the list? In particular, can you explain the fairly big gap between $y=912$ and $y=4043$? – Barry Cipra Sep 14 '15 at 15:58
• @BarryCipra, an approximation appears in the list if $x$ has least three zeros and the error is less that the previous one. I have no further explanation for the gap. – lhf Sep 14 '15 at 16:03
• Ah, thank you. I see I didn't pay close enough attention to the "at least three zeros." So basically you're looking at rational approximations (with square denominator) to the number $\pi/1000$. – Barry Cipra Sep 14 '15 at 16:20
• @BarryCipra, no, not really, but perhaps what you say is equivalent. If you can read Lua, see ideone.com/tReTWf. – lhf Sep 14 '15 at 16:25