So, you want to find a rational number approximation for a given positive real number?

I’m not sure what you mean by saying that “the angle goes off course”.
Clearly the n vs. d curve should converge to a slope n/d equal to the
number being approximated. Can you post an image of the graph to help
explain?

@paul0n0n

Now I remember hearing that 6 or 7 digits of pi was enough to calculate the circumference of the known universe to within the accuracy of an atom

Actually, no…an atom is about 10\^-11 meters across, while the observable universe is about 10\^27 meters across. So you’d need something like 38 digits of pi to calculate the circumference that accurately. :) However, when doing single-precision arithmetic on a computer, only about 6 or 7 decimal digits can be stored; with double-precision, 15 or 16 digits. To work with longer numbers you need a special arbitrary-precision arithmetic library.

How would that be done?

first off this is just a hobby exercise. but say you have an infinite series of random numbers i.e. “0.42014928858192.. etcetera”.

Here is an example of my first shot at doing such a thing.

were n = 1 and d = 1 , and a = the random number

iterating {

n/d = c

if c < a then n = n + 1

if c > a then d = d + 1

}

this approximates the number perfectly, but is very slow.

I output n and d to a file every iteration, then plot them, to which i find a very nice little pattern, that seems to have a very particular angle. I get the angle by averaging n and d which seems to work out pretty well up until the point n and d stop, then the angle goes off course.

Now I remember hearing that 6 or 7 digits of pi was enough to calculate the circumference of the known universe to within the accuracy of an atom (don’t quote me on this). so then if i have an angle that is accurate to say 20 decimals then how does the angle go off course so quickly. And is there any way to correct it?