{
  "id": "rational-or-irrational",
  "version": "a5bf367455d7",
  "status": "published",
  "name": "Rational or Irrational Calculator",
  "question": "Is this number rational or irrational?",
  "summary": "Tells whether a number is rational or irrational, with the reason: fractions, terminating and repeating decimals, square and cube roots, π, e and simple expressions such as (1 + √5)/2.",
  "category": "math",
  "subcategory": "arithmetic",
  "url": "https://www.acalculator.org/math/rational-or-irrational-calculator",
  "markdown": "https://www.acalculator.org/math/rational-or-irrational-calculator.md",
  "kind": "function",
  "method": "Read the number exactly as a + b·X, with a and b fractions and X one of √r, ∛r, π, 1/π, e, 1/e. It is rational when b = 0 (√r and ∛r count as rational when r is a square or a cube of a fraction), and irrational otherwise.",
  "assumptions": [
    "Decimals are read exactly: 0.75 is 3/4, and repeating digits are marked with brackets, 0.1(6), or typed twice before dots, 0.1666….",
    "π and e are irrational; so is the square root of a fraction that is not a square, and the cube root of one that is not a cube.",
    "Expressions mixing two kinds of irrational part (√2 + √3, π + e) are not read."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "x": {
        "title": "Number",
        "description": "A number or a short expression: 3/4, 0.75, 0.(3), 0.333…, √2, ∛9, 2π, e/3 or (1 + √5)/2.",
        "type": "string",
        "maxLength": 100
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Rational or irrational",
      "description": "Whether the number is rational or irrational.",
      "format": "text"
    },
    "reason": {
      "label": "Why",
      "description": "The reason, from its exact value.",
      "format": "text"
    },
    "exact": {
      "label": "Exact value",
      "description": "The number in simplest exact form: a fraction, or a fraction plus a multiple of one root or constant.",
      "format": "text"
    },
    "fraction": {
      "label": "As a fraction",
      "description": "A rational number as p/q in lowest terms.",
      "format": "text"
    },
    "decimal": {
      "label": "Decimal",
      "description": "The exact decimal of a rational number, with a bar over the repeating digits.",
      "format": "text"
    },
    "decimalType": {
      "label": "Decimal type",
      "description": "Whether the decimal ends, repeats, or does neither.",
      "format": "text"
    },
    "approx": {
      "label": "Approximate value",
      "description": "The number to 12 significant figures.",
      "format": "number"
    },
    "sets": {
      "label": "Number sets",
      "description": "The sets of numbers it belongs to: counting, whole, integer, rational, irrational, real.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "x": "√2"
    },
    "outputs": {
      "result": "Irrational",
      "reason": "It is √2, and 2 is not the square of a fraction, so its square root is irrational.",
      "exact": "√2",
      "decimal": "≈ 1.41421356237",
      "decimalType": "neither ends nor repeats",
      "approx": 1.4142135623730951,
      "sets": "Irrational number, real number"
    },
    "text": "Is √2 rational or irrational? Irrational. It is √2, and 2 is not the square of a fraction, so its square root is irrational."
  },
  "examples": [
    {
      "given": {
        "x": "√2"
      },
      "expect": {
        "result": "Irrational",
        "reason": "It is √2, and 2 is not the square of a fraction, so its square root is irrational.",
        "approx": 1.4142135623730951
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "√36"
      },
      "expect": {
        "result": "Rational",
        "fraction": "6",
        "sets": "Counting number, whole number, integer, rational number, real number"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "√44"
      },
      "expect": {
        "result": "Irrational",
        "exact": "2√11",
        "decimalType": "neither ends nor repeats"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "0.58(3)"
      },
      "expect": {
        "result": "Rational",
        "fraction": "7/12",
        "decimal": "0.583̅",
        "decimalType": "repeats"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx: (583 − 58) ÷ 900 = 525 ÷ 900 = 7/12"
    },
    {
      "given": {
        "x": "0.475"
      },
      "expect": {
        "result": "Rational",
        "fraction": "19/40",
        "decimalType": "ends",
        "reason": "It equals 19/40, a ratio of two integers."
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "(1 + √5)/2"
      },
      "expect": {
        "result": "Irrational",
        "exact": "1/2 + (1/2)√5",
        "approx": 1.618033988749895
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx",
      "tolerance": 1e-15
    },
    {
      "given": {
        "x": "√2 × √8"
      },
      "expect": {
        "result": "Rational",
        "fraction": "4"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx: √2 × √8 = √16 = 4"
    },
    {
      "given": {
        "x": "2π/3"
      },
      "expect": {
        "result": "Irrational",
        "exact": "(2/3)π",
        "reason": "It is (2/3)π, and π is irrational."
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "e"
      },
      "expect": {
        "result": "Irrational",
        "sets": "Irrational number, real number",
        "approx": 2.718281828459045
      },
      "source": "OpenStax, College Algebra 2e, §6.1 Exponential Functions (e is an irrational number: its decimal goes on forever without repeating), https://openstax.org/books/college-algebra-2e/pages/6-1-exponential-functions (retrieved 2026-10-19)"
    },
    {
      "given": {
        "x": "0.1666..."
      },
      "expect": {
        "fraction": "1/6",
        "decimal": "0.16̅"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx: the last digit repeats, so 0.1666… = 0.16̅ = 15 ÷ 90 = 1/6"
    },
    {
      "given": {
        "x": "∛27/8"
      },
      "expect": {
        "result": "Rational",
        "fraction": "3/8"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx: ∛27 = 3, then ÷ 8"
    },
    {
      "given": {
        "x": "-22/7"
      },
      "expect": {
        "result": "Rational",
        "decimal": "−3.1̅4̅2̅8̅5̅7̅",
        "sets": "Rational number, real number"
      },
      "source": "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers (a rational number can be written as a ratio of two integers; its decimal stops or repeats; square roots of whole numbers that are not perfect squares and π do not stop or repeat; Example 7.2: 0.583̅ and 0.475 are rational, 3.605551275… is irrational; Example 7.3: √36 = 6 is rational, √44 is irrational; Example 7.4: classifying counting, whole, integer, rational, irrational and real numbers), https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers (retrieved 2026-10-19); hand calculation in content.mdx: 22 ÷ 7 = 3.142857 142857…"
    }
  ],
  "sources": [
    "OpenStax, Prealgebra 2e, §7.1 Rational and Irrational Numbers: a rational number can be written as a ratio of two integers and its decimal stops or repeats; an irrational number cannot be, and its decimal does not stop or repeat; square roots of whole numbers that are not perfect squares and π are irrational; Examples 7.2 (0.583̅ and 0.475 are rational, 3.605551275… is irrational), 7.3 (√36 = 6 is rational, √44 is irrational) and 7.4 (counting, whole, integer, rational, irrational and real numbers), retrieved 2026-10-19. https://openstax.org/books/prealgebra-2e/pages/7-1-rational-and-irrational-numbers",
    "OpenStax, College Algebra 2e, §6.1 Exponential Functions: e ≈ 2.718282 is an irrational number, whose decimal goes on forever without repeating, retrieved 2026-10-19. https://openstax.org/books/college-algebra-2e/pages/6-1-exponential-functions"
  ],
  "related": [
    "simplifying-radicals",
    "square-root",
    "fraction-to-decimal",
    "pi"
  ],
  "changelog": []
}
