Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Is there a function for turning any number $x$ into a fraction with a denominator that has a maximum of $k$ digits? (I'm sure there is, since Excel has one built in, I just can't figure out what it is.)

For example, $f(0.1234) = $

  • $\frac{106}{859}$ where $k=3$;
  • $\frac{10}{81}$ where $k=2$;
  • $\frac{1}{8}$ where $k=1$.
share|improve this question
2  
A reasonably good answer can be found from the continued fraction expansion of $x$. –  André Nicolas Aug 9 '13 at 22:39
1  
I would call the continued fraction answer the best answer, in certain quantifiable ways. @AndréNicolas –  Thomas Andrews Aug 9 '13 at 22:43
    
One could complicate things by looking at secondary convergents, but there is probably no point. –  André Nicolas Aug 9 '13 at 22:48
    
For example, the continued fraction expansion for $0.1234$ yields convergents $0,1/8,9/73, 10/81, 19/154, 29/235, 106/859, 135/1094, 241/1953, 376/3047, 617/5000=0.1234$. –  Thomas Andrews Aug 9 '13 at 22:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.