How do you determine the closest whole number ratio for a given real number? I've been messing around with formulas for musical notes (trying not to read anything that would help me unless I get stuck) and currently I'm at a point where I'm trying to get a function that describes each note's frequency in terms of it's surrounding notes and specifically to find if their respective frequencies are close to a whole number ratio.
I can use a computer to calculate a table of every whole number ratio that I expect to see but I'm wondering if there is any other approach to this?
 A: In general there is no closest whole number ratio.  For example, the ratio between C and the next lower F♯ is exactly $\sqrt 2$. (In an equal-tempered 12-tone system.) As was known to the Greeks, there are no integers $a$ and $b$ with $\frac ab = \sqrt 2$. But there are arbitrarily good approximations: $\frac 32$, $\frac75$, $\frac{17}{12}$, … . The sequence continues with each fraction $\frac ab$ followed by $\frac{a+2b}{a+b}$, and each one is closer than the ones before.
The general rule is that every irrational number $\alpha$ has a unique continued fraction representation, and that if one truncates this continued fraction at some point, one obtains a good rational approximation to $\alpha$ with relatively small numerator and denominator. The further along one truncates the continued fraction, the better the approximation, but the larger its numerator and denominator will be. One can show that these so-called "convergents" of the continued fraction are among the very best rational approximations to $\alpha$ that exist, in the sense that any closer rational approximation must have a larger denominator.
A: A standard way of getting approximations that involve "small" numbers is to use the continued fraction expansion.
Since you expressed a desire to work things out for yourself, I will leave it at that for now.  If calculations lead to a particular problem, please ping for elaboration.
