Contents
raw book

TODO

Rational Numbers Introduction

TODO

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}\).

Orderdness

\[\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

TODO

Rational Addition

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

\[\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

\[-:\mathbb{Q}\mapsto\mathbb{Q}\]

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

Rational Subtraction

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

\[\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

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

\[\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

\[\cdot:\mathbb{R}\times\mathbb{Q}\mapsto\mathbb{Q}\]

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

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

\[\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}\]

The modulo operation for two rational numbers \( \frac{n_1}{d_1} \bmod \frac{n_2}{d_2} \) can be derived as follows:

Starting with the definition of modulo for integers: \[ \frac{n_1}{d_1} = k\cdot\frac{n_2}{d_2} + r, \]

where \( k \) is an integer multiple and the rest \( r \) satisfies \(0 \leq r < \frac{n_2}{d_2}\). Clearing fractions by multiplying through by \( d_1 d_2 \) (the least common denominator) gives:

\[ d_2 n_1 = n_2 d_1 k + d_1 d_2 r, \]

which rearranges to:

\[ r = \frac{d_2 n_1 - n_2 d_1 k}{d_1 d_2}. \]

The integer \( k \) is the quotient:

\[ k = \left\lfloor \frac{d_2 n_1}{n_2 d_1} \right\rfloor. \]

Substituting \( k \) back into the expression for \( r \) yields:

\[ r = \frac{d_2 n_1 - n_2 d_1 \cdot \left\lfloor \frac{d_2 n_1}{n_2 d_1} \right\rfloor}{d_1 d_2}. \]

The term \( d_2 n_1 - n_2 d_1 k \) represents the remainder when \( d_2 n_1 \) is divided by \( n_2 d_1 \), which is equivalent to:

\[ d_2 n_1 \mod (n_2 d_1). \]

Thus, the remainder \( r \) can be expressed compactly as:

\[ {q_1}\bmod{q_2}:= r = \frac{d_2 n_1 \mod (n_2 d_1)}{d_1 d_2}. \]

Greatest Common Divisor of Rational Numbers

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

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

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

\[\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

\[|\cdot|:\mathbb{Q}\times\mathbb{Q}\mapsto\mathbb{Q}\]

\[\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