Rational and Irrational Numbers - Computer Science

advertisement
Intro to Maths for CS:
Rational and Irrational Numbers
Joshua Knowles
School of Computer Science, University of Birmingham
Term 1, 2015-16
(Slides by John Barnden)
Rational and Irrational Numbers
A rational number is one that is equal to some fraction m/n where m and n are whole
numbers (m positive, negative or zero; n positive or negative but non-zero).
All other numbers are irrational.
The word “rational” comes from “ratio” — it’s not a synonym of “logical” or “not
crazy”!
ASIDE: but look up the psychological sense of “rational” in a dictionary that gives
etymologies (word origins/histories).
In particular, all integers are rational.
It can be shown that π is irrational.
Many square roots (and cube roots, fourth roots, ...) are irrational. In particular, the
square root of any whole number that is not a perfect square is irrational.
For instance, take five ....
Barnden (SoCS)
Intro to Maths for CS: Rational and Irrational Numbers
Term 1, 2014–15
2/1
... Take 5
Proof that
√
5 is irrational.
√
SUPPOSE it’s rational, so 5 = m/n for some integers m, n. Clearly, we can ensure that
m and n are both bigger than 1.
Square both sides, to get m2 = 5n2 . Consider the prime factorizations of m and n. The
equation tells us that the power of 5 in m2 is one more than the power of 5 in n2 . But
this is IMPOSSIBLE, because the power must be even in both m2 and n2 .
So our supposition was WRONG, and we have our proof.
Barnden (SoCS)
Intro to Maths for CS: Rational and Irrational Numbers
Term 1, 2014–15
3/1
... and Now Take φ
Remember that the golden ratio φ (related to the Fibonacci sequence—see Fun Quiz) is
√
1+ 5
2
We now know that φ is irrational. Why? Because if it were rational, then
√
m
1+ 5
=
2
n
from which we get
√
5
=
2×
m
−1
n
=
2m − n
n
which is rational.
Barnden (SoCS)
Intro to Maths for CS: Rational and Irrational Numbers
Term 1, 2014–15
4/1
Irrationals via Rationals
It can be shown that any irrational number z can be approximated arbitrarily closely by
rational numbers.
That is, for any number ϵ > 0, we can find a rational number r whose difference
from z is less than ϵ.
In fact, we can show that any irrational (and non-”complex”) number can be expressed
as a decimal number with infinitely many digits after the decimal point (where the digits
after the point never form a recurring pattern).
What this really means is that ...
Barnden (SoCS)
Intro to Maths for CS: Rational and Irrational Numbers
Term 1, 2014–15
5/1
Irrationals via Rationals, contd
√
... for instance, in the case of√ 5 there is a a never-ending sequence of rational numbers
that get closer and closer to 5, where the first few are:
2
2.2
2.23
2.236
2.23606
2.236067
2.2360679
2.23606797
2.236067977
2.2360679774
2.23606797749
2.236067977499
2.2360679774997
2.23606797749979
Barnden (SoCS)
Intro to Maths for CS: Rational and Irrational Numbers
Term 1, 2014–15
6/1
Download