# Homework Help: Rational and irrational numbers

Tags:
1. Jun 24, 2015

### Curieuse

1. The problem statement, all variables and given/known data
Determine a positive rational number whose square differs from 7 by less than 0.000001 (10^(-6))

2. Relevant equations
-

3. The attempt at a solution
Let p/q be the required rational number.

So,
7> (p/q)^(2) > 7-(0.000001)
⇒ √(7) > p/q > √(7-.000001)
⇒√(7) q> p > √(7-.000001)q

I can't see where I'm going with this. T.T

p and q are both integers, so the root quantity should be an integer for the answer
Like p=q(√some perfect square that lies between 7 and 6.999999)

Is this the way i am supposed to worth this out? Also how can i find such a perfect square??

2. Jun 24, 2015

### SammyS

Staff Emeritus
Isn't it possible that (p/q)2 is slightly larger than 7? -- like: 7 + .000001 > (p/q)2 > 7 - .000001

It's difficult to tell what method you're supposed to use. What sort of course is this for?

3. Jun 24, 2015

### Curieuse

Oh yes! So,
√(7+.000001) q> p > √(7-.000001)q

It's from the schaums theory and problems of advanced calculus- that I'm using to redo single var. And learn multi var.
This question is in the preliminaries and I'm stumped already!

4. Jun 24, 2015

### SammyS

Staff Emeritus
Are you allowed to use derivatives?

5. Jun 24, 2015

### Curieuse

Well, it's just self study so i think i can! But how do i use derivatives here?

6. Jun 24, 2015

### Svein

The standard way is to determine the denominator first. Since the maximum difference is 0.000001, q2>1/0.000001=1000000 (which means that q>1000).
Now find a nominator p1 such that p1/q2≥7. You will find a value for p1 that most certainly is not a square. Now adjust q upwards and look for a matching p...

7. Jun 24, 2015

### HallsofIvy

I wouldn't worry about "numerator" and "denominator". Use the fact that any terminating decimal is a rational number.

Now, $\sqrt{7}= 2.6457513110645905905016157536393...$. Just cut that off to an appropriate number of decimal places.

8. Jun 24, 2015

### Curieuse

Well, thanks for this! I was blinded by all the algebra! It's so simple! T.T
But i still wanna know the algebraic way of doing this!

Why is q > 10^6 ? Are we just choosing an arbitrary denominator and arriving at the numerator from applying the conditions?
I should be missing something here!

9. Jun 24, 2015

### WWGD

$\sqrt 7$ is a Real number, and, as a decimal, it is the LUB of a certain expression 2.645........

Now, consider the sequence:

$a_1:= |2.645 ^2 -7|$
$a_2:= | 26.4575131^2 - 700|$
$a_3:=| 264. 575131106^2 - 70000|$
...
$a_n :=| 264575.... - 7(10^n)|$
This sequence converges to 0 because $\sqrt 7$ is the lub of the decimal expansion 2.64575....

By completeness of the Reals, the Cauchy sequence 2.64575131..... converges to what we call
$\sqrt 7$, which is then the LUB of the sequence. This means we can get as close as we want, by definition/properties of the LUB, so that , as Ivy said, by going far-enough into the sequence.

Last edited: Jun 24, 2015
10. Jun 24, 2015

### scientific601

Approximating an irrational number using a rational fraction can be done by using Continued Fractions. With each term the reconstructed fraction becomes more accurate. It is then a matter of checking whether the error < 1e-6 or to continue with more terms.
12th term - error is 1.7e-6... not quite good enough
13th term - error is 2.4e-7... OK
I do not want to show the fraction in case this is homework. The numerator and denominator are both below 10,000.
The problem statement does not specify whether the answer should be the smallest (numerator & denominator) fraction just below the error threshold but closest to it, or some arbitrarily very accurate number. Simply converting an N-decimal-digit number into the fraction,
e.g. (sqrt(7) * 10^N) / 10^N
as Hallsofivy suggested may be the quickest and most intuitive method.

Last edited: Jun 24, 2015
11. Jun 24, 2015

### SammyS

Staff Emeritus
Does your book cover Newton's method in this section ?

12. Jun 24, 2015

### SammyS

Staff Emeritus
Here is a Link to the Wikipedia entry for Newton's Method for finding roots to equations.

Let $\displaystyle \ f(x) = x^2-7 \ .\$ Your problem now boils down to finding a value of $\ x\$ such that $\ |f(x)|<10^{-6} \ .$

Start with some rational number for $\ x\$ whose square is pretty close to 7. Two or three iterations should give a good result.

You can even work this out to get $\ x\$ in the form $\displaystyle \ \frac{p}{q} \ .\$

Last edited: Jun 27, 2015
13. Jun 24, 2015

### Ray Vickson

A common way to determine numerical approximations to $\sqrt{u}$ for real $u > 0$ is to apply Newton's method to fine the root of $0 = f(x) \equiv x^2 - u$. That does, indeed, use derivatives. It applies the formula
$$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)},$$
to get the next approximation $x_{n+1}$ from the current approximation $x_n$. For the simple case of $f = x^2 - u$ it gives
$$x_{n+1} = \frac{1}{2} \left( x_n + \frac{u}{x_n} \right)$$

14. Jun 24, 2015

### SammyS

Staff Emeritus
Using what Ray has in the above post:

If you start with a rational number for your initial "guess", then the subsequent values will also be rational.

15. Jun 24, 2015

### Svein

Well, I was quoting a part of the standard proof for the theorem "Between two different real numbers there is a rational".

16. Jun 27, 2015

### SammyS

Staff Emeritus
I looked at some edition of Schaum's Advanced Calculus. Seems the author may not have been looking any deeper than what HallsofIvy has suggested.

However, if you want something employing a bit of algebra and basic Calculus:

Using Newton's method, as Ray suggested, I used a spreadsheet to find a few rationals that work.

Starting with $\displaystyle \ x_0=\frac{8}{3} \,,\$ the second iteration gives: $\displaystyle \ x_2=\frac{32257}{12192} \$ with the square of that being
7.0000000067 .

I also looked at lots of starting numbers with two digit denominators. It's pretty easy to find candidates simply using a scientific calculator. A few of these gave a satisfactory result in a single iteration of Newton's method. Several others gave results in one iteration which were just slightly too large.

The satisfactory rational I found with the smallest denominator (and numerator) was $\displaystyle \ \frac{13451}{ 5084} \$ which had a starting value of $\displaystyle \ x_0=\frac{82}{31} \$.

17. Jun 27, 2015

### WWGD

Why not just try the rational sequence 2, 2.6, 2.64, 2.645 , etc. Adjust the terms so that the square is less than 7.

More specifically:
1) Find the greatest integer a so that $a^2 < 7$
2) Find the greatest integer $a_1$ so that $(a.a_1)^2 < 7$
....
n-1) Find the greatest integer $a_n$ so that $(a.a_0.....a_n)^2 < 7$.

Edit: The sequence we get is a monotone increasing, bounded (Cauchy) sequence that is bounded
above, so it must have a LUB.

Edit: I don't mean to be argumentative, it is just that the problem comes from a book on properties of the Real numbers, and this approach uses the LUB property of Reals.

Last edited: Jun 27, 2015
18. Jun 27, 2015

### SammyS

Staff Emeritus
There are many possible approaches to this problem. Your suggested approach has merit, but so do other approaches.

There's nothing wrong with considering the increasing sequence you suggest based on the idea of the LUB (least upper bound). We could just as well look at the similar sequence based on the GLB (greatest lower bound), in which x2>7 . Furthermore, we're looking for some rational number which fulfills some specific condition. Why limit the denominator to be some power of 10? For that matter, why limit ourselves to a base ten representation?

Yes, the problem apparently comes from a book on properties of the Real numbers so an approach based on properties of Reals might be in order.

However, the problem is stated in the OP only with reference to rational numbers, and the initial attempt is exclusively with rational numbers constructed as the ratio of integers. That's largely what led me to consider a method to get a solution explicitly of that form.

19. Jun 28, 2015

### Curieuse

I now see why you took denominator squared to be less than the allowed error! It comes from continuous fractions, if im not wrong. Also the fraction is simply to large to work with. As Scientific 601 said, the error is within limits only in the 13th term. Is there any way of doing this faster?

Why don't we take the sequence

$a_1:= |2.645 ^2 -7|$
$a_2:= | 2.64575131^2- 7|$
$a_3:=| 2.64575131106^2 - 7|$
...
$a_n :=| 2.64575.... ^2- 7|$

This would also converge to 0 right? And this is basically a proof for halls ofivy's method right?

I saw this method was used by the instructor in OSU's calc 1 course, involves computation though!

I'm trying to get the newtons method in place now! It seems the least computational.
Again thanks everyone for all the inputs! :D

20. Jun 28, 2015

### Curieuse

Is it by trial and error that we get the fraction that we write the continued fraction for? I tried with 2.6457514 and got 2+1/1+1/1+1/1+1/4+1/1+1/1+1/1+1/4+1/1+/1+1/1+1/4+1/1+87791/159294
I realised the quotients were repeating and this stopped.
I should solve for each and get the series 2, 3, 3/2, 5/2 , 8/3 , 37/14... Until 1/q^2 is less than 10^(-7)??

Is there a more efficient way of choosing the starting fraction?

21. Jun 28, 2015

### thelema418

From an algebraic standpoint, you could set up and solve continued fractions to find $\sqrt{7}$ to the desired degree of precision.

22. Jun 28, 2015

### Curieuse

Thanks ray! This method rocks totally!!! I'm so happy i learnt this!! It's ingenious!

23. Jun 28, 2015

### Svein

If you really want to find rationals, rewrite the formula slightly:
We want to find the square root of a expressed as p/q. Assume that you have found pn and qn. Then $p_{n+1}=p_{n}^{2}+a\cdot q_{n}^{2}$ and $q_{n+1}=2\cdot q_{n}\cdot p_{n}$.

Now, the choice of p1 and q1 is not critical, but different choices give different answers down the road. It is possible to start with p1 = 1 and q1 = 1, but there are better choices.

Another thing: both pn and qn grow very large very fast, so be on the lookout for a possible reduction of the fraction.

24. Jun 28, 2015

### scientific601

I would start with a more accurate fraction than the one you tried... no sense introducing another error such that the continued fraction converges, with its own error, on something that's off to begin with.

But you want a more algebraic solution instead of trial and error.
The first intuitive method I came up with was to use as many decimals as required from $\sqrt{7}$
2.645751311064591 (result from Apple Calculator)
Try 6 digits: 2.645751 - squaring it differs from 7 by 1.6e-6. Error too large.
Try 7 digits: 2.6457513 - squaring it differs from 7 by 5.85e-8 which is below 1e-6.
So the rational number is simply 26457513 / 10000000.

Somehow this answer feels like it's too primitive to be acceptable. It may depend on which level of mathematical sophistication you are expected to demonstrate.

25. Jun 28, 2015

### HallsofIvy

This was what I suggested in post #7!