Approximating fractions with fractions

by math_explorer, Nov 12, 2014, 3:03 AM

Let's suppose we have a fraction and we'd like to find a "nicer" fraction slightly smaller than it --- the smaller fraction should have a smaller denominator than the original one and, subject to these conditions, should be as large as possible.

Let's take the example 19/43.

import Data.Ratio
main :: IO ()
main = print . maximum . filter (< 19%43) $ [a % b | b <- [1..42], a <- [1..b]]

Tada! The answer is 15/34.

Okay, just kidding --- this is a math blog! Approximating fractions, you know, involves continued fractions, so let's look at that.

\[19/43 = 1/(2+1/(3+1/(1+1/4)))\]

Consider the function $f(x) = 1/(2+1/(3+1/(1+1/x)))$. It's easily seen to be monotonic by induction. Count the divisions and you'll find it's strictly increasing. As a consequence, if we decrease $x$ by one we get \[15/34 = 1/(2+1/(3+1/(1+1/3))).\]

This is the correct answer because it's the answer our program gave decreasing $x$ made the denominator smaller (if $x$ is a positive integer, one can verify by induction that the final numerator and denominator of the continued fraction are increasing linear functions of $x$) and because the continued fraction of any fraction between 15/34 and 19/43 has to start with the same coefficients:

\[1/(2+1/(3+1/(1+1/\cdots)))\]

Except what goes in the $\cdots$ would have to be between 3 and 4, so it would not be an integer, so it would have an even larger numerator and denominator and, for the same reasons as above, would lead to a final fraction with greater final numerators and denominators. So there's nothing nicer between 19/43 and 15/34.

Of course, this only works when there's an even number of divisions. Let's look at the symmetric problem, shall we? What's the closest fraction larger than 19/43 that has a smaller denominator?

import Data.Ratio
main :: IO ()
main = print . maximum . filter (> 19%43) $ [a % b | b <- [1..42], a <- [1..b]]


The answer to this is 4/9. You can't get here by increasing $x$ above; that would move the fraction in the right direction but end up increasing the denominator too. If you consider the function $g(y) = 1/(2+1/(3+1/(1+y)))$ instead, which is strictly decreasing in $y$, you see that you need to decrease $y$ but make it nicer. The problem is that initially $y = 1/4$ and there are no nicer fractions (with lower denominator) below $y$. So you just have go all the way to $y = 0$, which is lopping off the final term 1/4.

\begin{align*}4/9 &= 1/(2+1/(3+1/(1))) \\ &= 1/(2+1/4)\end{align*}
Depending on the parity of the length of the continued fraction, you lop off the last term to go one way and decrease the term to go the other.

These are the convergents and semiconvergents of the original fraction. You can also define them by recurrence relations involving the coefficients.

(This is an underwhelming piece of math compared to the other stuff on my blog, I know.)
This post has been edited 3 times. Last edited by math_explorer, Apr 26, 2015, 10:44 AM

Comment

1 Comment

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.

♪ i just hope you understand / sometimes the clothes do not make the man ♫ // https://beta.vero.site/

avatar

math_explorer
Archives
+ September 2019
+ February 2018
+ December 2017
+ September 2017
+ July 2017
+ March 2017
+ January 2017
+ November 2016
+ October 2016
+ August 2016
+ February 2016
+ January 2016
+ September 2015
+ July 2015
+ June 2015
+ January 2015
+ July 2014
+ June 2014
inv
+ April 2014
+ December 2013
+ November 2013
+ September 2013
+ February 2013
+ April 2012
Shouts
Submit
  • how do you have so many posts

    by krithikrokcs, Jul 14, 2023, 6:20 PM

  • lol⠀⠀⠀⠀⠀

    by math_explorer, Jan 20, 2021, 8:43 AM

  • woah ancient blog

    by suvamkonar, Jan 20, 2021, 4:14 AM

  • https://artofproblemsolving.com/community/c47h361466

    by math_explorer, Jun 10, 2020, 1:20 AM

  • when did the first greed control game start?

    by piphi, May 30, 2020, 1:08 AM

  • ok..........

    by asdf334, Sep 10, 2019, 3:48 PM

  • There is one existing way to obtain contributorship documented on this blog. See if you can find it.

    by math_explorer, Sep 10, 2019, 2:03 PM

  • SO MANY VIEWS!!!
    PLEASE CONTRIB
    :)

    by asdf334, Sep 10, 2019, 1:58 PM

  • Hullo bye

    by AnArtist, Jan 15, 2019, 8:59 AM

  • Hullo bye

    by tastymath75025, Nov 22, 2018, 9:08 PM

  • Hullo bye

    by Kayak, Jul 22, 2018, 1:29 PM

  • It's sad; the blog is still active but not really ;-;

    by GeneralCobra19, Sep 21, 2017, 1:09 AM

  • dope css

    by zxcv1337, Mar 27, 2017, 4:44 AM

  • nice blog ^_^

    by chezbgone, Mar 28, 2016, 5:18 AM

  • shouts make blogs happier

    by briantix, Mar 18, 2016, 9:58 PM

91 shouts
Contributors
Tags
About Owner
  • Posts: 583
  • Joined: Dec 16, 2006
Blog Stats
  • Blog created: May 17, 2010
  • Total entries: 327
  • Total visits: 354189
  • Total comments: 368
Search Blog