Ma · Mathematics

How Do You Compute Irrational Numbers?

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose a precision

    Decide how many decimal places or significant digits the calculation needs.

  2. 2. Use an approximation algorithm

    Apply a method that produces rational approximations, such as Newton's method for square roots.

  3. 3. Control the error

    Use a proven error bound or an enclosing interval to confirm the approximation is accurate enough.

  4. 4. Increase precision if needed

    Repeat with more digits or iterations; an irrational number generally has no finite exact decimal form.

An irrational number cannot be written exactly as a ratio of integers, and its decimal expansion neither terminates nor repeats. That does not prevent you from calculating it: in practice, you compute a rational approximation to a chosen precision, such as 10 decimal places.

The key is to pair an approximation method with a way to judge its accuracy. Here is how that works for 2\sqrt{2}, followed by guidance on other irrational numbers and what “computing” can mean.

What does it mean to compute an irrational number?

A calculator cannot display an infinite, non-repeating decimal expansion. Instead, it displays a finite approximation. For example,

2≈1.4142135624.\sqrt{2} \approx 1.4142135624.

The displayed decimal is rational: it is a fraction with a power of 10 as its denominator. It is not exactly 2\sqrt{2}, but it can be made as close as needed by calculating more digits.

There are two common ways to describe a computed value:

  • An approximation: a decimal or fraction believed to be close to the answer.
  • An approximation with an error bound: a statement that the answer lies within a specified distance or interval.

The second is stronger. If you know that xx lies between 1.4142 and 1.4143, you have a certified range for xx even if you do not know its exact decimal expansion.

Worked example: computing 2\sqrt{2}

Newton’s method can find a number xx satisfying x2=2x^2=2. Starting with a positive estimate, repeatedly apply

xn+1=12(xn+2xn).x_{n+1}=\frac{1}{2}\left(x_n+\frac{2}{x_n}\right).

For a positive starting value, this iteration approaches 2\sqrt{2}. Start with x0=1.5x_0=1.5:

x1=12(1.5+21.5)≈1.4166666667,x2≈12(1.4166666667+21.4166666667)≈1.4142156863,x3≈1.4142135624.\begin{aligned} x_1 &= \frac{1}{2}\left(1.5+\frac{2}{1.5}\right) \\ &\approx 1.4166666667,\\ x_2 &\approx \frac{1}{2}\left(1.4166666667+\frac{2}{1.4166666667}\right) \\ &\approx 1.4142156863,\\ x_3 &\approx 1.4142135624. \end{aligned}

The value after three updates agrees with 2\sqrt{2} to many decimal places. In exact rational arithmetic, the iterates here are 3/23/2, 17/1217/12, 577/408577/408, and 665857/470832665857/470832. Each iterate is rational, even though their limit is irrational.

If you need a verified answer, do not rely only on the number of iterations. Check an error bound or enclose the root. For instance, since 1.41422=1.99996164<21.4142^2=1.99996164<2 and 1.41432=2.00024449>21.4143^2=2.00024449>2, and squaring preserves order for positive numbers, you can conclude that

1.4142<2<1.4143.1.4142<\sqrt{2}<1.4143.

Choosing a method

The right algorithm depends on how the number is defined.

  • For a square root, use Newton’s method or bisection.
  • For constants such as π\pi, use a series or a specialized algorithm that produces digits with a known error bound.
  • For a number defined as the solution of an equation, use a root-finding method and verify the result with an interval or residual bound.
  • For expressions involving several quantities, use enough working precision to account for rounding during the intermediate calculations.

A computer typically represents numbers using a finite number of bits. Ordinary floating-point arithmetic is convenient, but it rounds values, so the last displayed digits may not be exact. For guaranteed accuracy, use interval arithmetic or arbitrary-precision arithmetic with suitable error control.

Can every irrational number be computed?

No. Many familiar irrationals, including 2\sqrt{2}, π\pi, and ee, are computable: there is an algorithm that produces approximations to any requested accuracy. But there are also noncomputable real numbers for which no algorithm can generate arbitrarily accurate approximations in general.

So “irrational” and “computable” describe different properties. Irrationality says a number is not a ratio of integers. Computability asks whether a finite procedure can approximate it to any specified precision. For ordinary mathematical constants, the practical question is usually which algorithm gives the needed accuracy efficiently.

Common mistakes

  • Treating a decimal approximation as exact. A finite display such as 1.41421356 is rational, not exactly 2\sqrt{2}.
  • Assuming more displayed digits mean more correct digits. Rounding and numerical instability can make some digits wrong. Check the method’s error bound.
  • Confusing irrational with impossible to calculate. Most standard irrationals encountered in school and science are computable to arbitrary precision.
  • Ignoring precision in later calculations. Subtracting two close approximations can magnify relative error; retain extra working digits and check the final error.

For a reliable numerical result, specify the desired precision, use a suitable algorithm, and verify how far the computed value can be from the true one.

References

  1. Computable Analysis: An Introduction — Klaus Weihrauch
  2. Modern Computer Arithmetic — Richard P. Brent and Paul Zimmermann

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.