Close to the root

Find the denominator n n of the rational number k n \frac{k}{n} ( k , n (k, n are both positive integers) such that 2 k n \left|\sqrt{2}-\frac{k}{n} \right| is the smallest possible, out of all rational numbers with denominators less than 120. 120.


The answer is 99.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Calvin Lin Staff
Aug 21, 2013

Almost all other solutions that were presented used the theory of Continued Fractions. There is slight mystery in it, for those who have not seen it before. In this solution, I present another method, using the idea of a Farey sequence:

A Farey sequence of order n n refers to an increasing sequence of reduced rational numbers between 0 and 1, whose denominator is a positive integer that is at most n n . For example, the Farey sequence of order 5 is:

0 1 , 1 5 , 1 4 , 1 3 , 2 5 , 1 2 3 5 2 3 3 4 4 5 1 1 . \frac{0}{1}, \frac{1}{5}, \frac{1}{4}, \frac{1}{3}, \frac{ 2}{5} , \frac 1 2 \frac 3 5 \frac 2 3 \frac 3 4 \frac 4 5 \frac 1 1.

Now, we'd use a fact about the Farey sequence - consecutive terms are of the form a b < c d \frac{a}{b} < \frac{c}{d} where a d b c = 1 ad-bc = -1 (Prove this!). Since 29 70 > 41 99 \frac{29}{70} > \frac{41}{99} and 29 × 99 41 × 70 = 1 29\times 99 - 41\times 70 = 1 , hence these terms are consecutive.

We can also show that 99 70 > 2 > 140 99 \frac{ 99}{70 }> \sqrt{2} > \frac{140}{99} , which tell us that one of these rational numbers must be the best approximation. It remains to compare these two, and we can show that 99 70 2 > 2 140 99 \frac{99}{70} - \sqrt{2} > \sqrt{2} - \frac{140}{99} . Hence, this shows that 140 99 \frac{140}{99} is the best approximation to 2 \sqrt{2} , hence the answer is 99).

Note: Of course, this doesn't really explain where we got these terms from, apart from being very lucky in guessing.

Jason Zimmerman
Aug 12, 2013

Using the continued fraction to calculate 2 \sqrt{2} , the last value that has a denominator less than 120 120 is 99 70 \frac{99}{70} .

However, we can get even more precise than this. Since 2 = 2 2 \sqrt{2} = \frac {2}{\sqrt{2}} we can substitute with 99 70 \frac{99}{70} to get 99 70 = 140 99 \frac{99}{70} = \frac{140}{99} Using this method further gets us back to 99 70 \frac{99}{70} so it is no use to work with this method anymore. In addition, since the next value for the continued fraction has a denominator above 120 120 , we can stop here and say that 140 99 \frac{140}{99} is the closest approximation.

Moderator note:

In the theory of continued fractions there is a delicate distinction between convergents and semi-convergents. To find the smallest n x m |nx-m| for bounded n n and m , m, only convergents need to be considered. However, for the |x-m/n| approximation problem one also needs to consider the semi-convergents. Here is a rather imperfect reference: http://en.wikipedia.org/wiki/Continued_fraction Perhaps, someone on this forum can point to a better source.

This is also how I did it, but I feel like there's something more going on here that I couldn't explain. Since this is looks kinda like doing part of a step in Newton's approximation, could we use that to bound the error and actually prove that this is a good idea?

Eric Edwards - 7 years, 10 months ago

How did you know the continued fraction?

Taylor Lau - 7 years, 10 months ago

Sorry for not using an "approximation" (squiggly equal sign) for the thing, I didn't know how to do it in \latex \latex

Also I am not quite sure how solid my evidence is that 120 99 \frac {120}{99} is. (Discussion section, please let me know if you have ideas!)

jason zimmerman - 7 years, 10 months ago

Log in to reply

Use \approx to get \approx , and \rm\LaTeX to get LaTeX \rm\LaTeX .

George Williams - 7 years, 10 months ago

A blog post regarding (semi)-convergents is here . There are many texts on continued fractions, most good ones will make the distinction between best rational approximations of the first and second kind.

George Williams - 7 years, 10 months ago

I also found 140/99 by using this approach, and guessed it although I could not see a proof that there are no closer values. In theory there could have been a solution to k 2 = 2 n 2 ± 3 k^2 = 2n^2 \pm 3 but with 3 / n 2 3/n^2 smaller than the case of 140/99 which is a solution to k 2 = 2 n 2 ± 2 k^2 = 2n^2 \pm 2 , with difference 2 / 9 9 2 2/99^2 .

Something else that hasn't been mentioned is that we're all actually trying to minimize 2 k 2 n 2 2 - \frac{k^2}{n^2} , which is NOT the square of the expression in the question. However you can prove by analysis that minimising this expression also minimises the original one.

Matt McNabb - 7 years, 10 months ago
George Williams
Aug 12, 2013

If p / q p / q is a best upper approximation to x x , then:

  1. p / q x p / q \ge x
  2. If there exists ( r , s ) (r, s) with p / q > r / s x p / q > r / s \ge x , then s > q s > q .

If p / q p / q is a best lower approximation to x x , then:

  1. x p / q x \ge p / q
  2. If there exists ( r , s ) (r, s) with x r / s > p / q x \ge r / s > p / q then s > q s > q .

A rational number is a best upper or lower approximation of x x iff it is a convergent or semi-convergent of its continued fraction. Using the continued fraction approximation of 2 \sqrt{2} (that is, [ 1 ; 2 ] [1; 2 \ldots ] ), we find that the under-approximation 140 / 99 140/99 is the best with 99 < 120 99 < 120 .

I don't understand how you got a value of 140 / 99 140/99 from the continued fraction of [ 1 ; 2... ] [1; 2 ...] . The first few partial fractions are 1 1 , 3 2 , 7 5 , 17 12 , 41 29 , 99 70 , 239 169 \frac{1}{1}, \frac{3}{2}, \frac {7}{5}, \frac {17}{12}, \frac{41}{29}, \frac {99}{70}, \frac {239}{169} .

jason zimmerman - 7 years, 10 months ago

Log in to reply

140 / 99 140/99 is not a convergent, it is a semi-convergent. Semi-convergents are fractions of the form p k + n p k + 1 q k + n q k + 1 \frac{p_k + np_{k+1}}{q_k + nq_{k+1}} where p k q k \frac{p_k}{q_k} is the k k th convergent and n 0 n \ge 0 is an integer \ast .

All convergents are best rational approximations, it is incorrect to say that they are all the best rational approximations. Semi-convergents compose all best rational approximations.

Now, back to your question. Note that 41 29 \frac{41}{29} and 99 70 \frac{99}{70} , with n = 1 n = 1 , form a semi-convergent. If n = 2 n = 2 , the denominator is too large. We cannot take 239 / 169 239/169 , a larger convergent, because the denominator is too large.

\ast : Some people say that a semi-convergent is NOT a convergent as well. If you prefer this definition, say n 1 n \ge 1 , and amend the rest appropriately.

George Williams - 7 years, 10 months ago

Log in to reply

Okay, thanks

jason zimmerman - 7 years, 10 months ago
Forretrio Wong
Jan 1, 2014

We can use the continued fraction expansion and the solution is straightforward.

Alternatively, we use Farey series to estimate 2 1 \sqrt{2} -1 . From the property of Farey series if a b \frac{a}{b} and c d \frac{c}{d} is the best estimate for a certain Farey series F n F_n then the farey median a + b c + d \frac{a+b}{c+d} is the new estimate in the Farey series F c + d F_{c+d} where there are no more fractions with denominator smaller than c + d c+d between them. Now consider F 120 F_{120} and start from 0 1 \frac{0}{1} and 1 1 \frac{1}{1} and the solution is obvious.

Is there another solution which doesnt use much heavy machinery or advanced concepts

Nahom Yemane - 7 years, 5 months ago

Log in to reply

Sorry I shall work out the principle concerning Farey sequences.

Definition. Farey sequence F n F_n is a (finite) sequence of all reduced fractions with denominators at most n n .

If two fractions are in consecutive terms in F n F_n call them neighbours.

Lemma. If a b < c d \frac{a}{b} < \frac{c}{d} then their mediant a + c b + d \frac{a+c}{b+d} satisfies a b < a + c b + d \frac{a}{b} < \frac{a+c}{b+d} < \frac{c}{d}).

To see this we take the difference between the fractions:

a + c b + d a b = b c a d b ( b + d ) \frac{a+c}{b+d}-\frac{a}{b} = \frac{bc-ad}{b(b+d)}

c d a + c b + d = b c a d d ( b + d ) \frac{c}{d}-\frac{a+c}{b+d} = \frac{bc-ad}{d(b+d)}

The term b c a d bc-ad has to be positive so that the fraction a + c b + d \frac{a+c}{b+d} lies in a consistent interval.

Theorem. Two fractions a b \frac{a}{b} and c d \frac{c}{d} are neighbours on F m a x ( b , d ) F_{max(b,d)} if b c a d = 1 |bc-ad|=1 .

We can prove this by induction on n n where n n refers to the Farey sequence F n F_n . For F 1 F_1 the sequence is { 0 1 , 1 1 } \left\{ \frac{0}{1}, \frac{1}{1}\right\} that b c a d = 1 |bc-ad|=1 is obviously true.

Suppose that for F n F_n with neighbouring fractions a b , c d \frac{a}{b}, \frac{c}{d} with b c a d = 1 |bc-ad|=1 then if b + d = n + 1 b+d=n+1 then their mediant is in the next Farey sequence F n + 1 F_{n+1} . Also we have b ( a + c ) a ( b + d ) = 1 b(a+c)-a(b+d)=1 . It is clear that there will not be any more new fractions inserted between a b \frac{a}{b} and c d \frac{c}{d} as we proceed from F n F_n to F n + 1 F_{n+1} . Then by MI this is true for all F n F_n

From the above, we can conclude that if a b \frac{a}{b} and c d \frac{c}{d} are neighbours for some F n F_n then the fraction with smallest denominator between them will be a + c b + d \frac{a+c}{b+d} . We can use this property to get the best estimate towards a real number. Here I estimate 2 1 \sqrt{2}-1 by fractions. The estimate for 2 \sqrt{2} immediately follows (it is clear that the integer part won't change the denominator that gives the best estimate).

Start with 0 1 < 2 1 < 1 1 \frac{0}{1} < \sqrt{2}-1 < \frac{1}{1} . Their mediant is 1 2 \frac{1}{2} , so the next one is

0 1 < 2 1 < 1 2 \frac{0}{1} < \sqrt{2}-1 <\frac{1}{2} . Their mediant is 1 3 \frac{1}{3} , so the next one is:

1 3 < 2 1 < 1 2 \frac{1}{3} < \sqrt{2}-1 < \frac{1}{2} . We repeat the step for a few times and the denominator will very soon exceed 120. We go back a few steps, and from the two fractional estimate we pick the more accurate one and get the answer.

Forretrio Wong - 7 years, 5 months ago

Minimizing the distance between sqrt{2} and k/n minimizes the distance between 2 and k^2/n^2.. so we are basically minimizing (|2n^2-k^2|)/n^2

Let us start by equating 2n^2-k^2 to 1 or -1. If the ordered pair (a,b) satisfies the equation, it is easy to see that (a+b,2a+b) also satisfies that. It is clear that as we increase the values of n and k the difference reduces as (|2n^2-k^2|)/n^2=1/n^2

Therefore, starting from (2,3) we get the pairs (5,7), (12,17), (29,41),(70,99) and (169,239). We stop at (70,99) as after that the values exceed 120. We have arrived at (|2n^2-k^2|)/n^2=1/4900 after using the fraction 99/70.

Now, equating 2n^2-k^2 to 2 or -2, we again use the fact that if the ordered pair (a,b) satisfies the equation, it is easy to see that (a+b,2a+b) also satisfies that. And again, increasing values of n and k brings k/n closer to sqrt{2}. So staring from (1,2) we get the pairs (3,4), (7,10), (17,24), (41,58) and (99,140). Using the fraction 140/99 we have (|2n^2-k^2|)/n^2=2/9801<1/4900.

By equating |2n^2-k^2|=m>2, we have (|2n^2-k^2|)/n^2=m/n^2>=3/120^2>1/4900>2/9801. Therefore 140/99 is the required fraction.

Hrishikesh Nair - 7 years, 3 months ago

Log in to reply

I think to complete the solution we will have to show that if (a,b) is a solution of 2n^2-k^2 = 1, than so is (b-a,2a-b).

Abhay Gupta - 7 years, 2 months ago
Nicholas Tomlin
Aug 14, 2013

We can apply the following method to find convergents of d \sqrt{d} :

Define d = [ a 1 , a 2 , a 3 , a 4 . . . ] \sqrt{d} = [a_1,a_2,a_3,a_4...] .

Let P 0 = 0 P_0 = 0 , P 1 = 1 P_1 = 1 , and P k = a k 1 P k 1 + P k 2 P_k = a_{k-1}P_{k-1} + P_{k-2} .

Let Q 0 = 1 Q_0 = 1 , Q 1 = 0 Q_1 = 0 , and Q k = a k 1 Q k 1 + Q k 2 Q_k = a_{k-1}Q_{k-1} + Q_{k-2} .

Then, given k>1, P k Q k \frac{P_k}{Q_k} will be an approximation for d \sqrt{d} .

Specifically, we want to find the convergents of 2 \sqrt{2} , so let [ a 1 , a 2 , a 3 , a 4 . . . ] = [ 1 , 2 , 2 , 2... ] [a_1,a_2,a_3,a_4...] = [1,2,2,2...] .

Since we want a denominator less than 120 120 , simply calculate the first few values of Q k Q_k (note that P i P_i is relatively prime to Q i Q_i for all i i ):

Q 2 = 1 × 0 + 1 = 1 Q_2 = 1 \times 0 + 1 = 1 , Q 3 = 2 × 1 + 0 = 2 Q_3 = 2 \times 1 + 0 = 2 , Q 4 = 2 × 2 + 1 = 5 Q_4 = 2 \times 2 + 1 = 5 , Q 4 = 2 × 5 + 2 = 12 Q_4 = 2 \times 5 + 2 = 12 , Q 5 = 2 × 12 + 5 = 29 Q_5 = 2 \times 12 + 5 = 29 , Q 6 = 2 × 29 + 12 = 70 Q_6 = 2 \times 29 + 12 = 70 .

Then, Q 7 > 120 Q_7 > 120 , so P 6 Q 6 \frac{P_6}{Q_6} is the best approximation to 2 \sqrt{2} with denominator less than 120 120 . Then,

P 2 = 1 × 1 + 0 = 1 P_2 = 1 \times 1 + 0 = 1 , P 3 = 2 × 1 + 1 = 3 P_3 = 2 \times 1 + 1 = 3 , P 4 = 2 × 3 + 1 = 7 P_4 = 2 \times 3 + 1 = 7 , P 4 = 2 × 7 + 3 = 17 P_4 = 2 \times 7 + 3 = 17 , P 5 = 2 × 17 + 7 = 41 P_5 = 2 \times 17 + 7 = 41 , P 6 = 2 × 41 + 17 = 99 P_6 = 2 \times 41 + 17 = \boxed{99} , which is the solution.

Note that this is true because 2 = 2 2 \sqrt{2} = \frac{2}{\sqrt{2}} , so 99 70 2 ( 99 70 ) = 140 99 \frac{99}{70} \approx \frac{2}{(\frac{99}{70})} = \frac{140}{99} , which is a (slightly) better approximation.

Nicholas Tomlin - 7 years, 10 months ago
Maciek Bryński
Aug 12, 2013

Code:

public class problem {
    public static void main(String[] args) {
        double p = Math.pow(2, 0.5);
        double min = 1;
        for (int i = 1; i<=120;i++) {
            double a =  Math.floor(p * i);
            double b =  Math.ceil(p * i);
            if ((p - (a/i)) < min) {
                min = p - (a/i);
                System.out.println("Found new min " + a + "/" + i + " min: " + min);
            }
            if (((b/i) - p) < min) {
                min = (b/i) - p;
                System.out.println("Found new min " + b + "/" + i + " min: " + min);
            }
        }
    }
}

Moderator note:

Of course, many of our Algebra/Number Theory problems can be quite easily solved using computer, especially with math software. However they are intended to be done by hand. The trial run of the Computer Science at Brilliant was a great success. It should be back soon, on a permanent basis, with more appropriate programming challenges.

I'm afraid this is not a computing question...

Nhat Le - 7 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...