{{Short description|Quotient of two integers}} {{Redirect|Rationals||Rational (disambiguation)}} [[File:Number-systems_(NZQRC).svg|thumb|alt={{not a typo|ℕ ⊊ ℤ ⊊ ℚ ⊊ ℝ ⊊ ⁠ℂ}}|The rational numbers {{tmath|\Q}} are included in the real numbers {{tmath|\R}}, which are included in the complex numbers {{tmath|\C}}, while rationals include the integers {{tmath|\Z}}, which in turn include the natural numbers {{tmath|\N}}.]] In mathematics, a '''rational number''' is a number that can be expressed as the quotient or fraction {{tmath|\tfrac p q}} of two integers, a numerator {{mvar|p}} and a nonzero denominator {{mvar|q}}.<ref name="Rosen">{{cite book |last = Rosen |first=Kenneth |title=Discrete Mathematics and its Applications |year=2007 |edition=6th |publisher=McGraw-Hill |location=New York, NY|isbn=978-0-07-288008-3 |pages=105, 158–160}}</ref> For example, {{tmath|\tfrac{3}{7} }} is a rational number, as is every integer (for example, {{nobr|<math>-5 = \tfrac{-5}{1}</math>).}} The set of all rational numbers is often referred to as "'''the rationals'''",<ref>{{cite book |title=Elements of Pure and Applied Mathematics |edition=illustrated |first1=Harry |last1=Lass |publisher=Courier Corporation |year=2009 |isbn=978-0-486-47186-0 |page=382 |url=https://books.google.com/books?id=WAY_AwAAQBAJ}} [https://books.google.com/books?id=WAY_AwAAQBAJ&pg=PA382 Extract of page 382]</ref> and is closed under addition, subtraction, multiplication, and division by a nonzero rational number. It is a field under these operations and therefore also called the '''field of rationals'''<ref>{{cite book |title=The Collected Works of Julia Robinson |first1=Julia |last1=Robinson |publisher=American Mathematical Soc |year=1996 |isbn=978-0-8218-0575-6 |page=104 |url=https://books.google.com/books?id=_33D84OENIAC}} [https://books.google.com/books?id=_33D84OENIAC&pg=PA104 Extract of page 104]</ref> or the '''field of rational numbers'''. It is usually denoted by boldface {{math|'''Q'''}}, or blackboard bold {{tmath|\Q.}}

A rational number is a real number. The real numbers that are rational are those whose decimal expansion either terminates after a finite number of digits (example: {{math|1=3/4 = 0.75}}), or eventually begins to repeat the same finite sequence of digits over and over (example: {{math|1=9/44 = 0.20454545...}}).<ref>{{Cite web|title=Rational number|url=https://www.britannica.com/science/rational-number|access-date=2020-08-11|website=Encyclopedia Britannica|language=en}}</ref> This statement is true not only in base 10, but also in every other integer base, such as the binary and hexadecimal ones (see {{slink|Repeating decimal|Extension to other bases}}).

A real number that is not rational is called irrational.<ref name=":0">{{Cite web|last=Weisstein|first=Eric W.|title=Rational Number|url=https://mathworld.wolfram.com/RationalNumber.html|access-date=2020-08-11|website=Wolfram MathWorld|language=en}}</ref> Irrational numbers include the square root of 2 {{nowrap|({{tmath|\sqrt 2}}),}} {{pi}}, {{mvar|e}}, and the golden ratio ({{mvar|φ}}). Since the set of rational numbers is countable, and the set of real numbers is uncountable, almost all real numbers are irrational.<ref name="Rosen"/>

The field of rational numbers is the unique field that contains the integers, and is contained in any field containing the integers. In other words, the field of rational numbers is a prime field. A field has characteristic zero if and only if it contains the rational numbers as a subfield. Finite extensions of {{tmath|\Q}} are called algebraic number fields, and the algebraic closure of {{tmath|\Q}} is the field of algebraic numbers.<ref name="Gilbert">{{cite book |last1=Gilbert |first1=Jimmie |last2=Linda |first2=Gilbert|author2-link=Linda Gilbert Saucier |year=2005 |title=Elements of Modern Algebra |edition=6th |publisher=Thomson Brooks/Cole |location=Belmont, CA |isbn=0-534-40264-X |pages=243–244}}</ref>

In mathematical analysis, the rational numbers form a dense subset of the real numbers. The real numbers can be constructed from the rational numbers by completion, using Cauchy sequences, Dedekind cuts, or infinite decimals (see Construction of the real numbers).

==Terminology== In mathematics, "rational" is often used as a noun abbreviating "rational number". The adjective ''rational'' sometimes means that the coefficients are rational numbers. For example, a rational point is a point with rational coordinates (i.e., a point whose coordinates are rational numbers); a ''rational matrix'' is a matrix of rational numbers, though it sometimes also refers to a matrix whose entries are rational functions; a ''rational polynomial'' may be a polynomial with rational coefficients, although the term "polynomial over the rationals" is generally preferred, to avoid confusion between "rational expression" and "rational function" (a polynomial is a rational expression and defines a rational function, even if its coefficients are not rational numbers). However, a rational curve ''is not'' a curve defined over the rationals, but a curve which can be parameterized by rational functions.

===Etymology===

Although nowadays ''rational numbers'' are defined in terms of ''ratios'', the term ''rational'' is not a derivation of ''ratio''. On the contrary, it is ''ratio'' that is derived from ''rational'': the first use of ''ratio'' with its modern meaning was attested in English about 1660,<ref>{{cite book|title=Oxford English Dictionary|edition=2nd|date=1989|publisher=Oxford University Press}} Entry '''ratio''', ''n.'', sense 2.a.</ref> while the use of ''rational'' for qualifying numbers appeared almost a century earlier, in 1570.<ref>{{cite book|title=Oxford English Dictionary|edition=2nd|date=1989|publisher=Oxford University Press}} Entry '''rational''', ''a. (adv.)'' and ''n.''{{sup|1}}, sense 5.a.</ref> This meaning of ''rational'' came from the mathematical meaning of ''irrational'', which was first used in 1551, and it was used in "translations of Euclid (following his peculiar use of {{lang|grc|ἄλογος}})".<ref>{{cite book|title=Oxford English Dictionary|edition=2nd|date=1989|publisher=Oxford University Press}} Entry '''irrational''', ''a.'' and ''n.'', sense 3.</ref><ref>{{Cite web|date=2017-05-09|first=Peter|last= Shor|authorlink=Peter Shor|title=Does rational come from ratio or ratio come from rational|url=https://english.stackexchange.com/questions/217956/does-rational-come-from-ratio-or-ratio-come-from-rational/218079#218079|access-date=2021-03-19|website=Stack Exchange|language=en-US}}</ref>

This unusual history originated in the fact that ancient Greeks "avoided heresy by forbidding themselves from thinking of those [irrational] lengths as numbers".<ref>{{Cite web|last1=Coolman|first1=Robert|date=2016-01-29|title=How a Mathematical Superstition Stultified Algebra for Over a Thousand Years|url=https://nautil.us/blog/how-a-mathematical-superstition-stultified-algebra-for-over-a-thousand-years|access-date=2021-03-20|language=en-US}}</ref> So such lengths were ''irrational'', in the sense of ''illogical'', that is "not to be spoken about" ({{lang|grc|ἄλογος}} in Greek).<ref>{{cite book|last1=Kramer|first1=Edna|title=The Nature and Growth of Modern Mathematics|date=1983|publisher=Princeton University Press|page=28}}</ref>

==Arithmetic== {{See also|Fraction (mathematics)#Arithmetic with fractions}}

===Irreducible fraction=== Every rational number may be expressed in a unique way as an irreducible fraction {{tmath|\tfrac a b,}} where {{mvar|a}} and {{mvar|b}} are coprime integers and {{math|''b'' > 0}}. This is often called the canonical form of the rational number.

Starting from a rational number {{tmath|\tfrac a b,}} its canonical form may be obtained by dividing both {{mvar|a}} and {{mvar|b}} by their greatest common divisor, and, if {{math|''b'' < 0}}, changing the sign of the resulting numerator and denominator.

===Embedding of integers=== Any integer {{mvar|n}} can be expressed as the rational number {{tmath|\tfrac n 1,}} which is its canonical form as a rational number.

===Equality=== :<math>\frac{a}{b} = \frac{c}{d}</math> if and only if <math>ad = bc</math>

If both fractions are in canonical form, then: :<math>\frac{a}{b} = \frac{c}{d}</math> if and only if <math>a = c</math> and <math>b = d</math><ref name=":1">{{Cite book|last=Biggs|first=Norman L.|author-link=Norman L. Biggs|title=Discrete Mathematics|publisher=Oxford University Press|year=2002|isbn=978-0-19-871369-2|location=India|pages=75–78}}</ref> <!--Examples: :<math>\frac{1}{3} = \frac{2}{6}</math> :<math>\frac{-1}{2} = \frac{1}{-2}</math> :<math>\frac{0}{1} = \frac{0}{2}</math>-->

===Ordering=== If both denominators are positive (particularly if both fractions are in canonical form): :<math>\frac{a}{b} < \frac{c}{d}</math> if and only if <math>ad < bc.</math>

On the other hand, if either denominator is negative, then each fraction with a negative denominator must first be converted into an equivalent form with a positive denominator—by changing the signs of both its numerator and denominator.<ref name=":1" />

===Addition=== Two fractions are added as follows: :<math>\frac{a}{b} + \frac{c}{d} = \frac{ad+bc}{bd}.</math>

If both fractions are in canonical form, the result is in canonical form if and only if {{mvar|b, d}} are coprime integers.<ref name=":1" /><ref name=":2">{{Cite web|title=Fraction - Encyclopedia of Mathematics|url=https://encyclopediaofmath.org/wiki/Fraction|access-date=2021-08-17|website=encyclopediaofmath.org}}</ref>

===Subtraction=== :<math>\frac{a}{b} - \frac{c}{d} = \frac{ad-bc}{bd}.</math>

If both fractions are in canonical form, the result is in canonical form if and only if {{mvar|b, d}} are coprime integers.<ref name=":2" />

===Multiplication=== The rule for multiplication is: :<math>\frac{a}{b} \cdot\frac{c}{d} = \frac{ac}{bd}.</math>

where the result may be a reducible fraction—even if both original fractions are in canonical form.<ref name=":1" /><ref name=":2" />

===Inverse=== Every rational number {{tmath|\tfrac a b}} has an additive inverse, often called its ''opposite'', :<math> - \left( \frac{a}{b} \right) = \frac{-a}{b}.</math> If {{tmath|\tfrac a b}} is in canonical form, the same is true for its opposite.

A nonzero rational number {{tmath|\tfrac a b}} has a multiplicative inverse, also called its ''reciprocal'', :<math> \left(\frac{a}{b}\right)^{-1} = \frac{b}{a}. </math> If {{tmath|\tfrac a b}} is in canonical form, then the canonical form of its reciprocal is either {{tmath|\tfrac b a}} or {{tmath|\tfrac{-b}{-a},}} depending on the sign of {{mvar|a}}.

===Division=== If {{mvar|b, c, d}} are nonzero, the division rule is :<math>\frac{\,\dfrac{a}{b}\,} {\dfrac{c}{d}} = \frac{ad}{bc}.</math>

Thus, dividing {{tmath|\tfrac a b}} by {{tmath|\tfrac c d}} is equivalent to multiplying {{tmath|\tfrac a b}} by the reciprocal of {{tmath|\tfrac c d:}}<ref name=":2" /> :<math>\frac{ad}{bc} = \frac{a}{b} \cdot \frac{d}{c}.</math>

===Exponentiation to integer power=== If {{mvar|n}} is a non-negative integer, then :<math>\left(\frac{a}{b}\right)^n = \frac{a^n}{b^n}.</math> The result is in canonical form if the same is true for {{tmath|\tfrac a b.}} In particular, :<math>\left(\frac{a}{b}\right)^0 = 1.</math>

If {{math|''a'' ≠ 0}}, then :<math>\left(\frac{a}{b}\right)^{-n} = \frac{b^n}{a^n}.</math> If {{tmath|\tfrac a b}} is in canonical form, the canonical form of the result is {{tmath|\tfrac{b^n}{a^n} }} if {{math|''a'' > 0}} or {{mvar|n}} is even. Otherwise, the canonical form of the result is {{tmath|\tfrac{-b^n}{-a^n}.}}

==Continued fraction representation== {{Main|Simple continued fraction}} A '''finite continued fraction''' is an expression such as :<math>a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{ \ddots + \cfrac{1}{a_n} }}},</math> where {{mvar|a{{sub|n}}}} are integers. Every rational number {{tmath|\tfrac a b}} can be represented as a finite continued fraction, whose coefficients {{mvar|a{{sub|n}}}} can be determined by applying the Euclidean algorithm to {{math|(''a, b'')}}.

== Other representations ==

* common fraction: {{tmath|\tfrac 8 3}} * mixed numeral: {{tmath|2\tfrac 2 3}} * repeating decimal using a vinculum: <math>2.\overline 6</math> * repeating decimal using parentheses: <math>2.(6)</math> * continued fraction using traditional typography: <math>2 + \tfrac 1 {1 + \tfrac 1 2}</math> * continued fraction in abbreviated notation: <math>[2; 1, 2]</math> * Egyptian fraction: <math>2 + \tfrac 1 2 + \tfrac 1 6</math> * prime power decomposition: <math>2^3 \times 3^{-1}</math> * quote notation: <math>3'6</math>

are different ways to represent the same rational value.

==Formal construction== thumb|right|300px|A diagram showing a representation of the equivalent classes of pairs of integers The rational numbers may be built as equivalence classes of ordered pairs of integers.<ref name=":1" /><ref name=":2" />

More precisely, let {{tmath|(\Z \times (\Z \setminus \{0\}))}} be the set of the pairs {{math|(''m, n'')}} of integers such {{math|''n'' ≠ 0}}. An equivalence relation is defined on this set by : <math>(m_1, n_1) \sim (m_2, n_2) \iff m_1 n_2 = m_2 n_1.</math><ref name=":1" /><ref name=":2" />

Addition and multiplication can be defined by the following rules: :<math>(m_1, n_1) + (m_2, n_2) \equiv (m_1n_2 + n_1m_2, n_1n_2),</math> :<math>(m_1, n_1) \times (m_2, n_2) \equiv (m_1m_2, n_1n_2).</math><ref name=":1" />

This equivalence relation is a congruence relation, which means that it is compatible with the addition and multiplication defined above; the set of rational numbers {{tmath|\Q}} is the defined as the quotient set by this equivalence relation, {{tmath|(\Z \times (\Z \backslash \{0\})) / \sim,}} equipped with the addition and the multiplication induced by the above operations. (This construction can be carried out with any integral domain and produces its field of fractions.)<ref name=":1" />

The equivalence class of a pair {{math|(''m, n'')}} is denoted {{tmath|\tfrac m n.}} Two pairs {{math|(''m''{{sub|1}}, ''n''{{sub|1}})}} and {{math|(''m''{{sub|2}}, ''n''{{sub|2}})}} belong to the same equivalence class (that is are equivalent) if and only if :<math>m_1n_2 = m_2n_1.</math> This means that :<math>\frac{m_1}{n_1} = \frac{m_2}{n_2}</math> if and only if<ref name=":1" /><ref name=":2" /> :<math>m_1n_2 = m_2n_1.</math>

Every equivalence class {{tmath|\tfrac m n}} may be represented by infinitely many pairs, since :<math>\cdots = \frac{-2m}{-2n} = \frac{-m}{-n} = \frac{m}{n} = \frac{2m}{2n} = \cdots.</math> Each equivalence class contains a unique ''canonical representative element''. The canonical representative is the unique pair {{math|(''m, n'')}} in the equivalence class such that {{mvar|m}} and {{mvar|n}} are coprime, and {{math|''n'' > 0}}. It is called the representation in lowest terms of the rational number.

The integers may be considered to be rational numbers identifying the integer {{mvar|n}} with the rational number {{tmath|\tfrac n 1.}}

A total order may be defined on the rational numbers, that extends the natural order of the integers. One has :<math>\frac{m_1}{n_1} \le \frac{m_2}{n_2}</math> If :<math>\begin{align} & (n_1n_2 > 0 \quad \text{and} \quad m_1n_2 \le n_1m_2) \\ & \qquad \text{or} \\ & (n_1n_2 < 0 \quad \text{and} \quad m_1n_2 \ge n_1m_2). \end{align}</math>

== Properties == The set {{tmath|\Q}} of all rational numbers, together with the addition and multiplication operations shown above, forms a field.<ref name=":1" />

{{tmath|\Q}} has no field automorphism other than the identity. (A field automorphism must fix 0 and 1; as it must fix the sum and the difference of two fixed elements, it must fix every integer; as it must fix the quotient of two fixed elements, it must fix every rational number, and is thus the identity.)

{{tmath|\Q}} is a prime field, which is a field that has no subfield other than itself.<ref>{{cite book |url=https://books.google.com/books?id=WHjO9K6xEm4C&pg=PA578 |title=Encyclopedic Dictionary of Mathematics, Volume 1 |page=578 |location=London, England |publisher=MIT Press |isbn=0-2625-9020-4 |first=Nihon |last=Sūgakkai |year=1993}}</ref> The rationals are the smallest field with characteristic zero. Every field of characteristic zero contains a unique subfield isomorphic to {{tmath|\Q.}}

With the order defined above, {{tmath|\Q}} is an ordered field<ref name=":2" /> that has no subfield other than itself, and is the smallest ordered field, in the sense that every ordered field contains a unique subfield isomorphic to {{tmath|\Q.}}

{{tmath|\Q}} is the field of fractions of the integers {{tmath|\Z.}}<ref>{{cite book |last1=Bourbaki |first1=N. |author-link=Nicolas Bourbaki |title=Algebra II: Chapters 4 - 7 |date=2003 |publisher=Springer Science & Business Media |page=A.VII.5}}</ref> The algebraic closure of {{tmath|\Q,}} i.e. the field of roots of rational polynomials, is the field of algebraic numbers.

The rationals are a densely ordered set: between any two rationals, there sits another one, and, therefore, infinitely many other ones.<ref name=":1" /> For example, for any two fractions such that :<math>\frac{a}{b} < \frac{c}{d}</math> (where <math>b,d</math> are positive), we have :<math>\frac{a}{b} < \frac{a + c}{b + d} < \frac{c}{d}.</math> Any totally ordered set which is countable, dense (in the above sense), and has no least or greatest element is order isomorphic to the rational numbers.<ref>{{Cite tech report|first1=Martin|last1=Giese|first2=Arno|last2=Schönegge|title=Any two countable densely ordered sets without endpoints are isomorphic - a formal proof with KIV|date=December 1995|url=https://www.uio.no/studier/emner/matnat/ifi/nedlagte-emner/INF5170/v14/undervisningsmateriale/countable-densely-ordered-sets.pdf|access-date=17 August 2021}}</ref>

=== Countability ===

thumb|right|200px|Illustration of the countability of the positive rationals The set of positive rational numbers is countable, as is illustrated in the figure.

More precisely, one can sort the fractions by increasing values of the sum of the numerator and the denominator, and, for equal sums, by increasing numerator or denominator. This produces a sequence of fractions from which one can remove the reducible fractions (in red on the figure), obtaining a sequence that contains each rational number exactly once. This establishes a bijection between the rational numbers and the natural numbers, which maps each rational number to its rank in the sequence.

A similar method can be used for numbering all rational numbers (positive and negative).

As the set of all rational numbers is countable, and the set of all real numbers (as well as the set of irrational numbers) is uncountable, the set of rational numbers is a null set, that is, almost all real numbers are irrational, in the sense of Lebesgue measure.<ref>{{Cite book |last1=Royden |first1=Halsey |title=Real Analysis |last2=Fitzpatrick |first2=Patrick |publisher=Pearson |date=2017-02-13 |isbn=9780134689494 |edition=4th |pages=7–54 |language=en}}</ref>

==Real numbers and topological properties== The rationals are a dense subset of the real numbers; every real number has rational numbers arbitrarily close to it.<ref name=":1" /> A related property is that rational numbers are the only numbers with finite expansions as regular continued fractions.<ref>{{cite book |title=Introduction to Number Theory |author1=Anthony Vazzana |author2=David Garth |edition=2nd, revised |publisher=CRC Press |year=2015 |isbn=978-1-4987-1752-6 |page=1 |url=https://books.google.com/books?id=iJWwDwAAQBAJ}} [https://books.google.com/books?id=iJWwDwAAQBAJ&pg=RA1 Extract of page 1]</ref>

In the usual topology of the real numbers, the rationals are neither an open set nor a closed set.<ref>{{cite book |title=A First Course in Discrete Dynamical Systems |author1=Richard A. Holmgren |edition=2nd, illustrated |publisher=Springer Science & Business Media |year=2012 |isbn=978-1-4419-8732-7 |page=26 |url=https://books.google.com/books?id=5LUPBwAAQBAJ}} [https://books.google.com/books?id=5LUPBwAAQBAJ&pg=PA26 Extract of page 26]</ref>

By virtue of their order, the rationals carry an order topology. The rational numbers, as a subspace of the real numbers, also carry a subspace topology. The rational numbers form a metric space by using the absolute difference metric <math>d(x,y)=|x-y|,</math> and this yields a third topology on {{tmath|\Q.}} All three topologies coincide and turn the rationals into a topological field. The rational numbers are an important example of a space which is not locally compact. The rationals are characterized topologically as the unique countable metrizable space without isolated points. The space is also totally disconnected. The rational numbers do not form a complete metric space, and the real numbers are the completion of {{tmath|\Q}} under the metric <math>d(x,y)=|x-y|</math> above.<ref name=":2" />

==''p''-adic numbers== {{Main article|p-adic number|l1={{mvar|p}}-adic number}} In addition to the absolute value metric mentioned above, there are other metrics which turn {{tmath|\Q}} into a topological field:

Let {{mvar|p}} be a prime number and for any nonzero integer {{mvar|a}}, let <math>|a|_p = p^{-n},</math> where {{mvar|p{{sup|n}}}} is the highest power of {{mvar|p}} dividing {{mvar|a}}.

In addition set <math>|0|_p = 0.</math> For any rational number {{tmath|\frac a b,}} we set :<math>\left|\frac{a}{b}\right|_p = \frac{|a|_p}{|b|_p}.</math>

Then :<math>d_p(x,y) =|x-y|_p</math> defines a metric on {{tmath|\Q.}}<ref>{{Cite web|last=Weisstein|first=Eric W.|title=p-adic Number|url=https://mathworld.wolfram.com/p-adicNumber.html|access-date=2021-08-17|website=Wolfram MathWorld|language=en}}</ref>

The metric space {{tmath|(\Q, d_p)}} is not complete, and its completion is the {{mvar|p}}-adic number field {{tmath|\Q_p.}} Ostrowski's theorem states that any non-trivial absolute value on the rational numbers {{tmath|\Q}} is equivalent to either the usual real absolute value or a {{mvar|p}}-adic absolute value.

==See also== *Dyadic rational *Floating point *Ford circles *Gaussian rational *Naive height—height of a rational number in lowest term *Niven's theorem *Rational data type

{{Classification of numbers}}

==References== {{Reflist}} ===Notes=== {{notelist}}

==External links== {{Commons category|Rational numbers}} {{Wikiversity|Rational numbers}} *{{springer|title=Rational number|id=p/r077620}} *[http://mathworld.wolfram.com/RationalNumber.html "Rational Number" From MathWorld – A Wolfram Web Resource]

{{Algebraic numbers}} {{Number systems}} {{Rational numbers}} {{Authority control}}

Category:Elementary mathematics Category:Field theory Category:Fractions (mathematics) Category:Rational numbers Category:Sets of real numbers