Why the answers stay in fractions

Floating point would be easier. Exact rationals are the reason the output reads like a textbook.

Why the answers stay in fractions

Differentiate sqrt(x) and a floating-point engine hands back 0.5·x^-0.5. Correct, and wrong for the purpose — no one writes that down.

This engine carries coefficients as exact rationals: a numerator, a denominator, and a normalisation step that keeps them in lowest terms. The same derivative comes out as 1/(2√x).

Where it matters most

Fractional exponents are the obvious case, but the payoff is larger in higher derivatives. Each round of differentiation multiplies coefficients together, and floating point accumulates error at every round. By the fifth derivative of a root function the decimals have drifted; the rationals have not.

The trade

Exact arithmetic is slower and the code is longer — every add, multiply and power has to work on pairs of integers with a greatest-common-divisor step. For a tool whose whole job is to look like handwriting, it is the right trade.

Back to the blog Back to the calculator