This site is supported by donations to The OEIS Foundation.

# Rational numbers

Rational numbers are numbers that can be expressed as the ratio of two integers. If
 a
and
 b, b   ≠   0,
are both integers, then their ratio, denoted as
 a  ⁄  b
or
 a b
, is a rational number. For example, the fraction
−
 125 37
and the integer
 74
are both rational numbers.
 π
on the other hand is not a rational number.

Rational numbers, being algebraic numbers of degree 1, are the roots of a nonconstant linear equation with integer coefficients

${\displaystyle {\begin{array}{l}\displaystyle {a_{1}x+a_{0}=0,}\end{array}}}$
where
 a1, a0 ∈ ℤ, a1   ≥   1.
The rational numbers, designated by
 ℚ
, are numbers which can be expressed, in reduced form, as the ratio of two coprime integers, or more specifically as the division of an integer called the numerator by a positive integer called the denominator. Given a fraction, as
 numerator denominator
ratio, we can use the Euclidean algorithm to obtain the GCD and find whether the two numbers are coprime, and make them coprime otherwise.

## Rational integers

Rational integers (algebraic integers of degree 1) are the zeros of the monic linear polynomial with integer coefficients

${\displaystyle {\begin{array}{l}\displaystyle {x+a_{0}{\!\,\!},}\end{array}}}$
where
 a0 ∈ ℤ
. They are the ordinary integers (i.e. members of
 ℤ
).

## Base b expansions of rational numbers

The base
 b
expansions of rational numbers are eventually periodic, for example (see
 π
approximations)
${\displaystyle {\begin{array}{l}\displaystyle {{\frac {22}{7}}=3+{\frac {1}{7}}=3+{\frac {142857}{999999}}=3+{\frac {142857}{1000000}}\left({\frac {1}{1-{\frac {1}{1000000}}}}\right)=3+142857\sum _{n=1}^{\infty }1000000^{-n}=3.142857142857142857142857142857\ldots ,}\end{array}}}$

where we used the geometric series sum formula

${\displaystyle {\begin{array}{l}\displaystyle {{\frac {1}{1-r}}=\sum _{n=0}^{\infty }r^{n},\quad \vert r\vert <1.}\end{array}}}$

Long division gives the above decimal expansion, although without explicit emphasis on the geometric series involved in the decimal expansion.

Conversely, any number
 n = a.bcccccc…
with an eventually periodic representation, where
 a.b
is the pre-periodic prefix and
 c
is the periodic pattern, is rational. For example, in base 10 (the same principle works in any fixed base
 b
):
${\displaystyle {\begin{array}{l}\displaystyle {90n=100n-10n={\mbox{abc.ccccc...}}-{\mbox{ab.cccccc...}}={\mbox{abc}}-{\mbox{ab}},}\end{array}}}$
thus
 n
is the following rational number
${\displaystyle {\begin{array}{l}\displaystyle {n={\frac {{\mbox{abc}}-{\mbox{ab}}}{90}}.}\end{array}}}$

### Dual representations and standard form

Any rational number whose denominator is not coprime with the fixed base
 b
used for the representation has two representations, due to the fact that
 1 = 1.00000000… = 0.9999999999…
in base 10 (or the equivalent in any base
 b
). Considering
 n = 0.9999999…
implies
${\displaystyle {\begin{array}{l}\displaystyle {9n=10n-n=9.99999999\ldots -0.99999999\ldots =9,}\end{array}}}$

thus

${\displaystyle {\begin{array}{l}\displaystyle {n=1.}\end{array}}}$
The standard form base
 b
expansions of rational numbers requires to keep only the repeating zeros representation (and to throw away the repeating nines representation).

## Base b expansions of irrational numbers

The expansions of irrational numbers are never periodic in any base.
 π
, approximately
 3.1415926535897932384626433832795…
, is not a rational number and hence is irrational. But there are a plethora of rational [[pi approximations|
 π
approximations]], and the one and only optimal
 π
approximation, the [[pi convergents|
 π
convergents]] (the partial [[Continued fractions for pi|continued fractions for
 π
]]).

## Continued fractions for rational numbers

All the continued fractions for rational numbers are finite (see Category:Continued fractions for rational numbers).

## Graded orderings of rational numbers

The rational numbers (in reduced form)
 a b
, a ∈ ℤ , b ∈ ℤ+ ,
may be sorted with a graded ordering, where we first order by increasing sum
 | a | + | b |
of absolute values of numerator and denominator for all reduced form rational numbers, i.e. with
 gcd(numerator, denominator) = 1
(first grading of the ordering), then by increasing absolute values of numerators
 | a |
corresponding to that grade. This is the Cantor ordering of rational numbers, giving a one-to-one and onto mapping from the natural numbers to the rational numbers, thus showing that the rational numbers are countably infinite.

## Schinzel's conjecture

Assuming the Schinzel-Sierpinski conjecture, every positive rational number can be represented in an infinite number of ways as

${\displaystyle {\begin{array}{l}\displaystyle {{\frac {a}{b}}={\frac {p+1}{q+1}}}\end{array}}}$

and

${\displaystyle {\begin{array}{l}\displaystyle {{\frac {a}{b}}={\frac {p-1}{q-1}},}\end{array}}}$
with
 p
and
 q
prime.

## Rational numbers among the algebraic numbers

1. Rational numbers: algebraic numbers of degree one (rational integers: algebraic integers of degree one)
2. Quadratic numbers: algebraic numbers of degree two (quadratic integers: algebraic integers of degree two)
3. Cubic numbers: algebraic numbers of degree three (cubic integers: algebraic integers of degree three)
4. Quartic numbers: algebraic numbers of degree four (quartic integers: algebraic integers of degree four)
5. Quintic numbers: algebraic numbers of degree five (quintic integers: algebraic integers of degree five)
6. ...