raw book


Rational Numbers Introduction


Definition of Rational Numbers

The set of rational numbers is defined as the ratio of two integers \(a\) and \(b\), the numerator and denominator:

\[\mathbb{Q} := \left\{\frac{a}{b} : a\in\mathbb{Z}, b\in\mathbb{N} \right\}\]

Embedding integer numbers

If \(b=1\) the number \(\frac{a}{1}\in\mathbb{Z}\subseteq\mathbb{Q}\), or seen the other way round, having a number \(n\in\mathbb{Z}\), we can embed that number into the space of rational numbers with \(\frac{n}{1}\in\mathbb{Q}\).


\[\frac{n_1}{d_1} \leq \frac{n_2}{d_2} :\Leftrightarrow n_1\cdot d_2\leq n_2\cdot d_1\]

Operators of Rational Numbers


Rational Addition


\[\begin{array}{rl} q_1 + q_2 :=& \frac{n_1}{d_1} + \frac{n_2}{d_2}\\ =& \frac{d_2n_1}{d_2d_1} + \frac{d_1n_2}{d_1d_2}\\ =& \frac{n_1d_2+d_1n_2}{d_1d_2}\\ \end{array}\]

This also shows that the sum of two rational numbers is always a rational number.

Rational Negation


\[\begin{array}{rl} - q :=& -\frac{n}{d} \end{array}\]

Rational Subtraction


\[\begin{array}{rl} q_1 - q_2 :=& \frac{n_1}{d_1} + (- \frac{n_2}{d_2})\\ =& \frac{d_2n_1}{d_2d_1} - \frac{d_1n_2}{d_1d_2}\\ =& \frac{n_1d_2-d_1n_2}{d_1d_2}\\ \end{array}\]

Rational Multiplication


\[\begin{array}{rl} q_1 \cdot q_2 :=& \frac{n_1}{d_1} \cdot \frac{n_2}{d_2}\\ =& \frac{n_1n_2}{d_1d_2} \end{array}\]

Rational Scalar Multiplication


Rational Multiplicative Inverse

\[\begin{array}{rl} q^{-1} :=& \left(\frac{n}{d}\right)^{-1}\\ =& \frac{\frac{n}{|n|}\cdot d}{|n|}\;\;\; (\forall n\neq 0) \end{array}\]

Rational Division


\[\begin{array}{rl} q_1 / q_2 :=& \frac{n_1}{d_1} \cdot \left(\frac{n_2}{d_2}\right)^{-1}\\ =& \frac{n_1}{d_1} \cdot \frac{d_2}{n_2}\\ =& \frac{n_1d_2}{d_1n_2} \end{array}\]

Rational Power

\[\hat{} :\mathbb{Q}\times\mathbb{Z}\mapsto\mathbb{Q}\]

\[\begin{array}{rl} q^a :=& \left(\frac{n}{d}\right)^a\\ =& \frac{n^a}{d^a} \end{array}\]

Rational Root

\[\hat{} :\mathbb{Q}\times\mathbb{Q}\mapsto\mathbb{Q}\]

For the general case, we can either work on prime factors of the numerator and denominator and cancel out the prime factors. Alternatively, we approximate the solution with Newton’s method:

\[\begin{array}{rrl} &x &= \left(\frac{a}{b}\right)^{c/d}\\ \Leftrightarrow &x^d &= \left(\frac{a}{b}\right)^c\\ \Leftrightarrow &x^d-\left(\frac{a}{b}\right)^c &= 0\\ \end{array}\]

So the function is \(f(x) = x^d-\left(\frac{a}{b}\right)^c\) and its derivative \(f'(x) = dx^{d-1}\). Now with newtons method, we can

\[ \begin{array}{rl} x_{n+1} &=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}}\\ &=x_{n}-{\frac {x_n^d-\left(\frac{a}{b}\right)^c}{dx_n^{d-1}}}\\ &=x_n + \frac{\left(\frac{a}{b}\right)^c x_n^{1 - d} - x_n}{d} \end{array} \]

Rational Modulo

\[\bmod :\mathbb{Q}\times\mathbb{Q}\mapsto\mathbb{Q}\]

\[\begin{array}{rrl} &q_1 =& aq_2 + b\\ \Leftrightarrow&\frac{n_1}{d_1} =& a\frac{n_2}{d_2} + b\\ \Leftrightarrow&n_1 d_2 =& a d_1 n_2 + bd_1d_2\\ \Leftrightarrow&{q_1}\bmod{q_2}:=&\frac{(n_1 d_2)\bmod(d_1 n_2)}{d_1d_2}\\ \end{array}\]

Greatest Common Divisor of Rational Numbers


We can write a rational number \(q=\frac{a}{b}\) as a product of it’s numerator and denominaotors primes with positive and negative powers in a unque way:

\[\frac{a}{b} = p_1^{a_{p_1} - b_{p_1}}\cdot p_2^{a_{p_1}-b_{p_2}}\cdot\dots\]

Having two such numbers in the prime representation reveals that we want the smallest positive exponent of each prime for the numerator (that is the GCD of the numerators) as the rational GCD and the greatest negative exponent for the denominator (that is the LCM of the denominators). From this idea follows directly the definition of the GCD for rational numbers:

\[\begin{array}{rl} gcd(q_1, q_2) :=& gcd\left(\frac{n_1}{d_1}, \frac{n_2}{d_2}\right)\\ =& \frac{gcd(n_1, n_2)}{lcm(d_1, d_2)}\\ =& \frac{gcd(n_1, n_2)\cdot gcd(d_1, d_2)}{|d_1\cdot d_2|}\\ =& \frac{gcd(n_1, n_2)\cdot gcd(d_1, d_2)}{d_1\cdot d_2}\\ \end{array}\]

Least Common multiple of Rational Numbers


\[\begin{array}{rl} lcm(q_1, q_2) :=& lcm\left(\frac{n_1}{d_1}, \frac{n_2}{d_2}\right)\\ =& \frac{lcm(n_1, n_2)}{gcd(d_1, d_2)}\\ =& \frac{|n_1\cdot n_2|}{gcd(n_1, n_2)\cdot gcd(d_1, d_2)}\\ \end{array}\]

Absolute value of a Rational Number


\[\begin{array}{rl} |q| :=& \left|\frac{n}{d}\right|\\ =& \frac{|n|}{d} \end{array}\]

Fraction equivalent to recurring decimal

A decimal number such as \(0.\overline{123}\) can be expressed as a fraction by multiplying by \(10^3\), which is 10 to the power of the length of the repeating group 123.

Hence \(10^3s = 123.\overline{123} = 123 + s\) and therefore

\[s = \frac{123}{10^3-1}\]

In general this is

\[s = \frac{g}{10^{\lfloor1+\log_{10}(g)\rfloor}-1}\]

With \(g\) being the repeating group within a decimal number.

Continues Fraction