Book contents
Contents
raw Math
RAW Book Analysis Rational Numbers

Introduction to Rational Numbers

Robert Eisele

The rational numbers are the numbers that can be written as a quotient of an integer numerator and a positive integer denominator. They form the set

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

This notation is intuitive but not yet fully formal, because many different pairs \((a,b)\) represent the same rational number, for example \(\frac{1}{2}\) and \(\frac{2}{4}\). The next sections make this precise by treating a rational number as an equivalence class of such pairs rather than one particular pair.

Rational numbers extend the integers and are dense on the real line, which makes them fundamental in analysis, number theory, and numerical work.

Closure Under Division

Integers are closed under addition, subtraction, and multiplication: combining two integers with any of these operations always produces another integer. Division breaks this pattern. Sharing 3 whole pizzas evenly among 4 people, for instance, cannot be recorded as an integer number of pizzas per person, since 3 is not a multiple of 4.

To describe such a share, each of the 3 pizzas is split into 4 equal parts, and every person receives 3 of these quarter-parts. This motivates the fraction \(\frac{p}{q}\), where \(q\) is the number of equal parts a whole is divided into, called the denominator, and \(p\) counts how many of these parts are taken, called the numerator. Algebraically, the fraction bar denotes division, \(\frac{p}{q}=p:q\), so a fraction makes the division \(p:q\) exact whenever \(q\) is nonzero.

The denominator cannot be \(0\). If \(\frac{p}{0}\) denoted a number \(a\), the defining property of division would require

\[a\cdot 0=p.\]

Since \(a\cdot 0=0\) for every \(a\), this equation only has a chance to hold when \(p=0\), and even then every \(a\) satisfies it, so no single value is determined. Division by \(0\) is therefore excluded from the definition of \(\mathbb{Q}\) altogether, matching the condition \(b\in\mathbb{N}\) above.

Classifying Fractions

Fractions fall into a few standard categories:

Every improper fraction splits into an integer part and a proper fractional remainder, called a mixed number, by applying division with remainder \(p=kq+r\) with \(0\le r<q\):

\[\frac{p}{q}=k+\frac{r}{q}.\]

For example, \(\frac{5}{2}=2+\frac{1}{2}\). The same division with remainder underlies the division algorithm for integers.

Equivalent Fraction Representations

A rational number is not represented uniquely by a pair \((a,b)\). For any nonzero integer \(k\):

\[\frac{a}{b}=\frac{ka}{kb}\]

Multiplying numerator and denominator by the same \(k\) is called extending the fraction; dividing both by a common factor is called reducing it. Both operations leave the value unchanged, so \(\frac{1}{2}=\frac{2}{4}=\frac{-3}{-6}\).

More generally, two fractions represent the same rational number exactly when their cross products agree:

\[\frac{a}{b}\sim\frac{a'}{b'}\iff ab'=a'b.\]

This relation is reflexive, symmetric, and transitive, so it partitions all integer pairs \((a,b)\) with \(b\neq 0\) into equivalence classes, and \(\mathbb{Q}\) is precisely the set of these classes. Every arithmetic operation on fractions defined below through numerator and denominator arithmetic gives the same result no matter which representative of a class is used, which is exactly what the cross-product criterion guarantees.

For addition this can be checked directly: if \(\frac{a}{b}\sim\frac{a'}{b'}\) and \(\frac{c}{d}\sim\frac{c'}{d'}\), so that \(ab'=a'b\) and \(cd'=c'd\), then

\[(ad+bc)b'd'=adb'd'+bcb'd'=a'bdd'+bb'c'd=(a'd'+b'c')bd,\]

which is exactly the cross-product condition \(\frac{ad+bc}{bd}\sim\frac{a'd'+b'c'}{b'd'}\). So the addition formula defined below gives the same rational number no matter which representative is used; the same kind of check applies to multiplication.

Formally, let \(F=\mathbb{Z}\times(\mathbb{Z}\setminus\{0\})\) be the set of all integer numerator-denominator pairs, with \(\sim\) as defined above. The equivalence class of \((a,b)\),

\[\left[\frac{a}{b}\right]=\left\{\frac{c}{d}:\frac{c}{d}\sim\frac{a}{b}\right\},\]

collects every pair representing the same value, for example

\[\left[\frac{1}{2}\right]=\left\{\ldots,\frac{-2}{-4},\frac{-1}{-2},\frac{1}{2},\frac{2}{4},\frac{3}{6},\ldots\right\}.\]

A rational number is, strictly speaking, one such class rather than any single pair, so \(\mathbb{Q}=F/{\sim}\). Once arithmetic has been shown to be independent of the chosen representative, the bracket notation is dropped again and a rational number is written simply as \(\frac{a}{b}\), understood as standing for its whole class.

A canonical representative is obtained by reducing to lowest terms with a positive denominator:

\[\frac{a}{b}=\frac{n}{d},\quad \gcd(|n|,d)=1,\; d>0\]

This reduced form is unique. Existence follows by dividing \(a\) and \(b\) by \(\gcd(|a|,|b|)\) and moving a possible minus sign into the numerator, for example

\[\frac{-18}{-24}=\frac{18}{24}=\frac{3}{4},\qquad \frac{18}{-24}=-\frac{3}{4}.\]

For uniqueness, suppose \(\frac{a}{b}=\frac{c}{d}\) with both fractions reduced and \(b,d>0\), so \(ad=bc\). Euclid's lemma applied to this equation gives \(a\mid c\) and \(c\mid a\), hence \(|a|=|c|\); together with \(ad=bc\) and positive denominators this forces \(a=c\) and \(b=d\). So the reduced form is not just canonical but the only pair satisfying \(\gcd(|n|,d)=1\) and \(d>0\).

Rational Numbers as Slopes of Lines

The equivalence relation above has a direct geometric picture. For integers \(b\neq 0\) and \(a\), the point \((b,a)\) lies on a unique line through the origin, and the slope of that line is \(\frac{a}{b}\). Another integer point \((b',a')\) lies on the very same line exactly when \(ab'=a'b\), which is the cross-product criterion for equivalent fractions restated in coordinates.

So the infinitely many fractions representing one rational number correspond to the infinitely many integer points on one and the same line through the origin, and the rational number itself is the common slope of that line. This also gives a geometric picture for the order relation defined below: comparing two rational numbers amounts to comparing the heights at which their lines cross the vertical line \(x=1\).

Embedding Integers and Number Chain

Every integer is rational via

\[n=\frac{n}{1}\]

Hence \(\mathbb{Z}\subseteq\mathbb{Q}\subseteq\mathbb{R}\), matching the standard hierarchy of sets.

This embedding preserves arithmetic: for integers \(a,b\),

\[\frac{a}{1}+\frac{b}{1}=\frac{a+b}{1},\qquad \frac{a}{1}\cdot\frac{b}{1}=\frac{ab}{1}.\]

So integer addition and multiplication are exactly the restrictions of the rational operations defined below, and computing with an integer as \(n\) or as \(\frac{n}{1}\) gives the same result.

Order on Rational Numbers

\[\leq:\mathbb{Q}\times\mathbb{Q}\to\{\mathrm{true},\mathrm{false}\}\]

Given \(\frac{n_1}{d_1},\frac{n_2}{d_2}\in\mathbb{Q}\) with \(d_1,d_2>0\), we define:

\[\frac{n_1}{d_1}\leq \frac{n_2}{d_2}\iff n_1d_2\leq n_2d_1\]

This is compatible with the usual order on \(\mathbb{R}\).

Arithmetic Operations

Let \(q_1=\frac{n_1}{d_1}\) and \(q_2=\frac{n_2}{d_2}\) with \(d_1,d_2>0\).

Addition and Subtraction

\[\pm:\mathbb{Q}\times\mathbb{Q}\to\mathbb{Q}\]

\[q_1\pm q_2=\frac{n_1d_2\pm n_2d_1}{d_1d_2}\]

The plain product \(d_1d_2\) always works as a common denominator, but it is rarely the smallest one. Replacing it with \(\operatorname{lcm}(d_1,d_2)\) keeps the intermediate numerators smaller:

\[ q_1\pm q_2=\frac{n_1\cdot\frac{\operatorname{lcm}(d_1,d_2)}{d_1}\pm n_2\cdot\frac{\operatorname{lcm}(d_1,d_2)}{d_2}}{\operatorname{lcm}(d_1,d_2)}. \]

For example, adding \(\frac{1}{10}+\frac{1}{5000}\) with the raw product gives the unnecessarily large denominator \(50\,000\), while \(\operatorname{lcm}(10,5000)=5000\) keeps the computation compact.

A mixed number is first converted to an improper fraction before applying the formula, for example

\[\frac{4}{5}-3\frac{1}{10}=\frac{8}{10}-\frac{31}{10}=-\frac{23}{10}=-2\frac{3}{10}.\]

Negation

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

\[-q=-\frac{n}{d}=\frac{-n}{d}=\frac{n}{-d}\]

So subtraction is addition of the negation, \(q_1-q_2=q_1+(-q_2)\), consistent with the \(\pm\) definition above.

Multiplication

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

\[q_1\cdot q_2=\frac{n_1n_2}{d_1d_2}\]

Common factors between any numerator and any denominator may be cancelled before multiplying, which keeps the intermediate numbers small:

\[\frac{5}{2}\cdot\frac{3}{18}\cdot\frac{2}{25}=\frac{5}{2}\cdot\frac{1}{6}\cdot\frac{2}{25}=\frac{1}{30}.\]

Multiplicative Inverse and Division

\[(\cdot)^{-1}:\mathbb{Q}\setminus\{0\}\to\mathbb{Q},\qquad /:\mathbb{Q}\times(\mathbb{Q}\setminus\{0\})\to\mathbb{Q}\]

For \(q\neq 0\):

\[q^{-1}=\left(\frac{n}{d}\right)^{-1}=\frac{d}{n}\]

and therefore for \(q_2\neq 0\):

\[\frac{q_1}{q_2}=q_1\cdot q_2^{-1}=\frac{n_1d_2}{d_1n_2}\]

For example,

\[\frac{36}{11}:\frac{18}{33}-\frac{15}{14}:\frac{5}{7}=\frac{36}{11}\cdot\frac{33}{18}-\frac{15}{14}\cdot\frac{7}{5}=6-\frac{3}{2}=\frac{9}{2}.\]

Complex Fractions

A fraction whose numerator or denominator is itself a fraction is simplified by treating the main fraction bar as division:

\[\frac{\frac{3}{5}+\frac{2}{7}}{\frac{35}{12}}=\frac{\frac{31}{35}}{\frac{35}{12}}=\frac{31}{35}\cdot\frac{12}{35}=\frac{372}{1225}.\]

Useful Fraction Identities

Distributivity, multiplication by an inverse, and multiplication by a common denominator give the following frequently used identities. For all displayed fractions, every denominator is assumed to be nonzero:

\[ \begin{aligned} ab+ac &= a(b+c),\\ a\left(\frac{b}{c}\right) &= \frac{ab}{c},\\ \frac{\frac{a}{b}}{c} &= \frac{a}{bc},\\ \frac{a}{\frac{b}{c}} &= \frac{ac}{b},\\ \frac{a}{b}-\frac{c}{d} &= \frac{ad-bc}{bd},\\ \frac{a}{b}+\frac{c}{d} &= \frac{ad+bc}{bd}. \end{aligned} \]

Changing both signs in a fraction leaves its value unchanged, and addition distributes over a common denominator:

\[ \frac{a-b}{c-d}=\frac{b-a}{d-c}, \qquad \frac{a+b}{c}=\frac{a}{c}+\frac{b}{c}. \]

Conversely, a common nonzero factor can be cancelled:

\[ \frac{ab+ac}{a}=b+c, \qquad a\neq 0. \]

Integer Powers

\[(\cdot)^m:\mathbb{Q}\to\mathbb{Q},\qquad m\in\mathbb{Z}\]

For \(m\in\mathbb{Z}\):

\[\left(\frac{n}{d}\right)^m=\frac{n^m}{d^m}\quad (m\ge 0),\qquad \left(\frac{n}{d}\right)^m=\left(\frac{d}{n}\right)^{-m}\quad (m<0,n\neq 0)\]

Rational Root

\[^:\mathbb{Q}\times\mathbb{Q}\to\mathbb{Q}\]

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

For \(\frac{a}{b}>0\) in lowest terms and a reduced exponent \(\frac{c}{d}\) with \(d>0\), the power \(\left(\frac{a}{b}\right)^{c/d}\) is itself rational exactly when \(a\) and \(b\) are both perfect \(d\)-th powers; otherwise Newton's method is needed to approximate it. For a negative base, a real result exists only when \(d\) is odd.

For a positive base \(a>0\), \(n\in\mathbb{Z}\), and \(m\in\mathbb{N}\), rational powers may equivalently be read as a root followed by a power or a power followed by a root:

\[ a^{\frac{n}{m}} =\left(a^{\frac{1}{m}}\right)^n =\left(a^n\right)^{\frac{1}{m}}. \]

For \(a,b\neq0\) and \(n\in\mathbb{Z}\), negative exponents invert a quotient:

\[ \left(\frac{a}{b}\right)^{-n} =\left(\frac{b}{a}\right)^n =\frac{b^n}{a^n}, \qquad \left(\frac{a}{b}\right)^n =\left(\frac{b}{a}\right)^{-n} =\frac{a^n}{b^n}. \]

Let

\[ x=\left(\frac{a}{b}\right)^{c/d} \iff x^d=\left(\frac{a}{b}\right)^c \iff x^d-\left(\frac{a}{b}\right)^c=0. \]

So we define

\[ f(x)=x^d-\left(\frac{a}{b}\right)^c, \qquad f'(x)=d\,x^{d-1}. \]

Applying Newton's iteration \(x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}\) gives

\[ \begin{aligned} x_{n+1} &=x_n-\frac{x_n^d-\left(\frac{a}{b}\right)^c}{d\,x_n^{d-1}}\\ &=x_n+\frac{\left(\frac{a}{b}\right)^c x_n^{1-d}-x_n}{d}. \end{aligned} \]

Rational Numbers as a Field

Collecting the operations above, \((\mathbb{Q},+,\cdot)\) has an additive identity \(\frac{0}{d}=0\) and a multiplicative identity \(\frac{d}{d}=1\) for any \(d\neq 0\), every element \(\frac{n}{d}\) has an additive inverse \(-\frac{n}{d}\), and every nonzero element has the multiplicative inverse \(\frac{d}{n}\) defined above.

Associativity, commutativity, and distributivity all reduce to the corresponding laws for integers acting on numerators and denominators. For distributivity,

\[ \left(\frac{n_1}{d_1}+\frac{n_2}{d_2}\right)\cdot\frac{n_3}{d_3} =\frac{n_3(n_1d_2+n_2d_1)}{d_1d_2d_3} =\frac{n_1n_3}{d_1d_3}+\frac{n_2n_3}{d_2d_3}, \]

which is exactly \(\left(\frac{n_1}{d_1}+\frac{n_2}{d_2}\right)\cdot\frac{n_3}{d_3}=\frac{n_1}{d_1}\cdot\frac{n_3}{d_3}+\frac{n_2}{d_2}\cdot\frac{n_3}{d_3}\). Together with the identities and inverses above, this makes \(\mathbb{Q}\) a field, and in fact the smallest field containing \(\mathbb{Z}\): subtraction and division by anything except \(0\) are always exactly solvable, which is precisely the closure property integers were missing at the start.

Absolute Value, GCD, and LCM on Rational Numbers

Absolute Value

\[|\cdot|:\mathbb{Q}\to\mathbb{Q}_{\ge 0}\]

\[\left|\frac{n}{d}\right|=\frac{|n|}{d}\]

Rational GCD

\[\gcd:\mathbb{Q}\times\mathbb{Q}\to\mathbb{Q}_{\ge 0}\]

The integer foundation of \(\gcd\) is developed with greatest common divisors.

Ordinary divisibility is not useful here, since every nonzero rational divides every rational: the quotient of two rationals is again rational whenever the divisor is nonzero. The gcd and lcm below instead extract the common integer structure of the numerators and denominators.

Write rational numbers in reduced form:

\[ q_1=\frac{n_1}{d_1},\qquad q_2=\frac{n_2}{d_2},\qquad d_1,d_2>0. \]

For integers, gcd picks common prime factors with the minimum exponents. For rationals, denominator factors carry negative exponents, so the consistent extension becomes: take gcd on numerators and lcm on denominators.

\[\gcd\!\left(\frac{n_1}{d_1},\frac{n_2}{d_2}\right)=\frac{\gcd(n_1,n_2)}{\mathrm{lcm}(d_1,d_2)}\]

Using \(\mathrm{lcm}(u,v)=\frac{|uv|}{\gcd(u,v)}\), we also get

\[ \gcd\!\left(\frac{n_1}{d_1},\frac{n_2}{d_2}\right) =\frac{\gcd(n_1,n_2)\,\gcd(d_1,d_2)}{d_1d_2}. \]

Rational LCM

\[\mathrm{lcm}:\mathbb{Q}\times\mathbb{Q}\to\mathbb{Q}_{\ge 0}\]

Dual to gcd, the rational lcm takes lcm on numerators and gcd on denominators:

\[\mathrm{lcm}\!\left(\frac{n_1}{d_1},\frac{n_2}{d_2}\right)=\frac{\mathrm{lcm}(n_1,n_2)}{\gcd(d_1,d_2)}\]

and with \(\mathrm{lcm}(n_1,n_2)=\frac{|n_1n_2|}{\gcd(n_1,n_2)}\):

\[ \mathrm{lcm}\!\left(\frac{n_1}{d_1},\frac{n_2}{d_2}\right) =\frac{|n_1n_2|}{\gcd(n_1,n_2)\,\gcd(d_1,d_2)}. \]

For positive \(q_1,q_2\), the two quantities multiply back to the original product, just as for integers:

\[\gcd(q_1,q_2)\cdot\mathrm{lcm}(q_1,q_2)=q_1q_2.\]

Decimals and Rational Numbers

A real number is rational if and only if its decimal expansion is finite or eventually periodic.

Finite Decimals

Every finite decimal is rational, for example

\[12.375=\frac{12375}{1000}=\frac{99}{8}\]

Conversely, a fraction \(\frac{a}{b}\) in lowest terms with \(b>0\) has a terminating decimal expansion exactly when \(b\) has no prime factors other than \(2\) and \(5\), that is \(b=2^r5^s\): a terminating decimal always has a denominator of the form \(10^k=2^k5^k\), and a reduced denominator must divide some power of \(10\).

Purely Repeating Decimals

Let \(x=0.\overline{g}\), where \(g\) has \(k\) digits. Then

\[10^k x-x=g\quad\Rightarrow\quad x=\frac{g}{10^k-1}\]

Example:

\[0.\overline{123}=\frac{123}{999}=\frac{41}{333}\]

The same identity applied to \(x=0.\overline{9}\) gives \(10x-x=9\), so \(x=\frac{9}{9}=1\). Decimal representations are therefore not unique: \(0.\overline{9}\) and \(1\) denote the same rational number, exactly as \(\frac{1}{2}\), \(\frac{2}{4}\), and \(0.5\) are three notations for one value.

Eventually Repeating Decimals

For \(x=0.a_1\dots a_m\overline{b_1\dots b_k}\), one can remove the non-periodic prefix by multiplying with \(10^m\) and then apply the previous formula. This always yields a fraction of integers.

Why the Converse Holds

The remaining direction is that every rational number has a finite or eventually periodic decimal expansion. Long division of \(\frac{a}{b}\) produces, at every step, a remainder in \(\{0,1,\dots,b-1\}\). If a remainder \(0\) occurs, the expansion terminates. Otherwise, since only \(b-1\) nonzero remainders are possible, some remainder must reappear within the first \(b\) steps; from that point on, the division repeats the same sequence of digits, so the expansion is eventually periodic. Together with the criterion above,

\[x\in\mathbb{Q}\iff x\text{ has a finite or eventually periodic decimal expansion.}\]

Fractions, Decimals, and Percent

Percent (from Latin per centum, "per hundred") expresses a rational number relative to a denominator of \(100\). Whenever a fraction can be extended or reduced to denominator \(100\), the resulting numerator is directly the percent value:

\[\frac{1}{25}=\frac{4}{100}=4\%.\]

Since \(1\%=\frac{1}{100}=0.01\), converting a decimal expansion to percent only requires shifting the decimal point two places to the right:

\[\frac{5}{16}=0.3125=31.25\%.\]

The same shift applies to non-terminating decimals once they are rounded to a finite number of digits:

\[\frac{1}{3}=0.\overline{3}\approx 0.3333=33.33\%.\]

Rational Modulo

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

The modulo operation familiar from integers extends naturally to rational divisors. A practical modulo definition for positive divisor \(q_2\) is

\[q_1\bmod q_2:=q_1-q_2\left\lfloor\frac{q_1}{q_2}\right\rfloor\]

With \(q_1=\frac{n_1}{d_1}\), \(q_2=\frac{n_2}{d_2}\), the modulo operation can be derived as follows.

Start from

\[ \frac{n_1}{d_1}=k\cdot\frac{n_2}{d_2}+r, \]

where \(k\in\mathbb{Z}\) and \(r\) is the desired remainder.

Multiply by \(d_1d_2\):

\[ d_2n_1=n_2d_1k+d_1d_2r. \]

Rearrange for \(r\):

\[ r=\frac{d_2n_1-n_2d_1k}{d_1d_2}. \]

Since \(0\le r<\frac{n_2}{d_2}\), we get

\[ k=\left\lfloor\frac{d_2n_1}{n_2d_1}\right\rfloor. \]

Substituting this into \(r\) yields

\[q_1\bmod q_2= \frac{d_2n_1-n_2d_1\left\lfloor\frac{d_2n_1}{n_2d_1}\right\rfloor}{d_1d_2} =\frac{d_2n_1\bmod(n_2d_1)}{d_1d_2}\]

Continued Fractions and Best Approximations

Every rational number has a finite continued fraction expansion:

\[\frac{a}{b}=[c_0;c_1,\dots,c_r] =c_0+\cfrac{1}{c_1+\cfrac{1}{\ddots+\cfrac{1}{c_r}}}\]

The coefficients are obtained by the Euclidean algorithm, for example \(\frac{415}{93}=[4;2,6,7]\). Conversely, every finite continued fraction evaluates to a rational number. This representation is useful for simplification and for constructing best approximants.

Continued Fraction Calculator

Enter a fraction to compute its continued fraction expansion, for example \(\frac{355}{113}\), the classical best approximation of \(\pi\):

Egyptian Fraction Expansions

A different special representation writes a rational number strictly between \(0\) and \(1\) as a sum of distinct unit fractions, for example

\[\frac{5}{6}=\frac{1}{2}+\frac{1}{3}.\]

Repeating a unit fraction is not allowed, so \(\frac{2}{3}=\frac{1}{3}+\frac{1}{3}\) does not count as such an expansion, even though it is a true equation.

Such a decomposition always exists and can be constructed greedily: for \(\frac{m}{n}\) with \(0<m<n\), take the smallest unit fraction not exceeding it, \(\frac{1}{k}\) with \(k=\left\lceil\frac{n}{m}\right\rceil\), and subtract:

\[\frac{m}{n}-\frac{1}{k}=\frac{mk-n}{nk}.\]

Since \(k-1<\frac{n}{m}\le k\), multiplying by \(m\) gives \(0\le mk-n<m\), so the new numerator is strictly smaller than \(m\); repeating the step therefore terminates after finitely many steps. The remainder is also smaller than the unit fraction just removed, so every subsequent denominator is larger than the last, which is exactly why the resulting unit fractions come out distinct.

Applying this to \(\frac{5}{12}\): \(k=\left\lceil\frac{12}{5}\right\rceil=3\), so \(\frac{5}{12}-\frac{1}{3}=\frac{1}{12}\), which is already a unit fraction, giving

\[\frac{5}{12}=\frac{1}{3}+\frac{1}{12}.\]

Such expansions need not be unique: the same fraction also equals \(\frac{5}{12}=\frac{1}{4}+\frac{1}{6}\), a decomposition the greedy algorithm does not produce.

The greedy algorithm always terminates, but the denominators it produces can grow far faster than the input suggests. For \(\frac{5}{7}\) it gives the still-modest

\[\frac{5}{7}=\frac{1}{2}+\frac{1}{5}+\frac{1}{70},\]

but for inputs like \(\frac{19}{49}\) or \(\frac{5}{61}\) the last denominator already explodes to numbers with a dozen or more digits, a reminder that termination says nothing about how large the expansion becomes.

Egyptian Fraction Calculator

Enter a numerator and denominator with \(0<p<q\) to compute the greedy Egyptian fraction expansion:

Irrationality of the Square Root of Two

Not every number that arises naturally is rational — the diagonal of a unit square, for instance, has length \(\sqrt{2}\), and no fraction of integers equals it exactly. Suppose \(\sqrt{2}=\frac{a}{b}\) in the reduced form from above, with \(\gcd(a,b)=1\) and \(b>0\). Squaring gives

\[2b^2=a^2.\]

So \(a^2\) is even, and since the square of an odd number is odd, \(a\) itself must be even, say \(a=2c\). Substituting back,

\[2b^2=4c^2\quad\Rightarrow\quad b^2=2c^2,\]

so \(b\) is even by the same argument. But then \(2\) divides both \(a\) and \(b\), contradicting \(\gcd(a,b)=1\). No reduced fraction can therefore equal \(\sqrt{2}\), so \(\sqrt{2}\notin\mathbb{Q}\). The rational root subsection above shows how such irrational roots are approximated numerically instead, since no exact rational value exists.

Density in the Reals

Unlike the integers, \(\mathbb{Q}\) has no next element: if \(r<s\) are rational, then so is their midpoint,

\[r<\frac{r+s}{2}<s,\]

and repeating this construction produces infinitely many rational numbers between any two distinct ones.

More strongly, \(\mathbb{Q}\) is dense in \(\mathbb{R}\): for any \(x<y\) in \(\mathbb{R}\), there exists \(q\in\mathbb{Q}\) with \(x<q<y\). Choose \(n\in\mathbb{N}\) large enough that \(n(y-x)>1\), and set \(m=\lfloor nx\rfloor+1\). Then \(nx<m\le nx+1<ny\), so \(q=\frac{m}{n}\) satisfies \(x<q<y\). So rationals can approximate real numbers arbitrarily well, even though \(\mathbb{Q}\neq\mathbb{R}\) — a gap already visible above in the fact that \(\sqrt{2}\) has no rational value. That \(\mathbb{N}\) has no upper bound in \(\mathbb{R}\), used to choose \(n\) above, and the fact that \(\sqrt{2}\) exists as a real number despite having no rational value, are both consequences of the supremum axiom developed in the chapter on real numbers.