0
$\begingroup$

It's easy for us to tell that 0.49999 is only 0.00001 away from being expressed as a simple ratio: 1/2.

However, it may not be as obvious that 0.142858 is also at most only 0.00001 away from being expressed as a simple ratio. 1/7 in this case.

For our purpose a simple ratio will be defined as a fraction where both the numerator and the denominator consist of a single digit.

Is there a way to calculate the closest simple ratio to a number other than comparing the difference between every ratio and the number in question?

How would you generalize this to approximating simple ratios using integers up to n for the numerator and denominator?

$\endgroup$
1
3
$\begingroup$

An algorithm for finding the best rational approximation with a given range of denominator in Wikipedia. Basically you find the continued fraction expansion of the number, then massage the last entry a bit. If you ask Alpha for the continued fraction for $0.142858$ you get $[0; 6, 1, 23808, 1, 2]$ which represents $0+\frac 1{6+\frac 1{1+\frac 1{23808+\ldots}}}$ That huge entry $23808$ says that stopping just before it gives a very good approximation, which here is $\frac 17$

$\endgroup$
2
0
$\begingroup$

However, it may not be as obvious that 0.142858 is also only 0.00001 away from being expressed as a simple ratio. 1/7 in this case.

Not only may it not be obvious, but it also is not true either :).
0.142858 is only 0.00001 from 0.142857 (or 0.142859) which is 142857/1000000 (or 142857/1000000). Neither is equal to 1/7 (nor are they simple fractions).

$\endgroup$
4
  • 2
    $\begingroup$ I think they meant "at most $0.00001$ away" $\endgroup$
    – Isaac Ren
    May 12 '20 at 13:19
  • 1
    $\begingroup$ You should Google "continued fractions". $\endgroup$
    – saulspatz
    May 12 '20 at 13:20
  • $\begingroup$ @saulspatz this seems like exactly what I needed! Much thanks! $\endgroup$ May 12 '20 at 13:24
  • $\begingroup$ @Aryaman Maithani, thanks for pointing it out. I corrected the typo. $\endgroup$ May 12 '20 at 13:25
0
$\begingroup$

I'll answer the more general question. Your first question is just the case $n=9$.

Let $x$ be a real number. Then $x$ can be written as a simple ratio if, and only if, there exists $b\in\{1,\ldots,n\}$ such that writing $x$ in base $b$ has at most one digit after the dot. This is because "has at most one digit after the dot" is equivalent to "is a multiple of $\frac 1b$".

Checking that a number is close to a simple ratio is then a matter of checking if there are a lot of $0$ or $b-1$ at the end of its expression in base $b$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.