represents the domain of rational numbers, as in x∈Rationals.
Rationals
represents the domain of rational numbers, as in x∈Rationals.
Details
- x∈Rationals evaluates immediately if x is a numeric quantity.
- Simplify[expr∈Rationals,assum] can be used to try to determine whether an expression corresponds to a rational number under the given assumptions.
- (x1|x2|…)∈Rationals and {x1,x2,…}∈Rationals test whether all xi are rational numbers.
- The domain of integers is taken to be a subset of the domain of rationals.
- Rationals is output in StandardForm or TraditionalForm as
. This typeset form can be input using
rats
.
Examples
open all close allBasic Examples (3)
Scope (6)
Test domain membership of a numeric expression:
Element[21 / 32, Rationals]Element[Sqrt[2], Rationals]Element[Pi, Rationals]For some numeric expressions, domain membership may not be resolved automatically:
{Element[7 Sqrt[2] + 2 Sqrt[7], Rationals], Element[Sqrt[5 + 2Sqrt[6]] - Sqrt[2] - Sqrt[3], Rationals]}Use RootReduce to resolve domain membership of algebraic number expressions:
RootReduce[%]Make domain membership assumptions:
Refine[Element[x ^ 2 - 2x y + y ^ 3 / 3, Rationals], Element[x | y, Rationals]]Specify the default domain over which Reduce should work:
Reduce[(x ^ 3 - 8 / 27)(x ^ 3 - 2) == 0, x, Rationals]Test whether several numbers are rational:
(x | y | 1 / 2)∈RationalsIf any number is explicitly irrational, the result is False:
{x, y, Pi}∈RationalsTraditionalForm formatting:
Rationals//TraditionalFormProperties & Relations (2)
Tech Notes
Related Guides
History
Introduced in 1999 (4.0) | Updated in 2017 (11.2)
Text
Wolfram Research (1999), Rationals, Wolfram Language function, https://reference.wolfram.com/language/ref/Rationals.html (updated 2017).
CMS
Wolfram Language. 1999. "Rationals." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/Rationals.html.
APA
Wolfram Language. (1999). Rationals. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Rationals.html
BibTeX
@misc{reference.wolfram_2026_rationals, author="Wolfram Research", title="{Rationals}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/Rationals.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rationals, organization={Wolfram Research}, title={Rationals}, year={2017}, url={https://reference.wolfram.com/language/ref/Rationals.html}, note=[Accessed: 12-June-2026]}