ApasScript.

Exact Numbers

Why 1/3 stays 1/3: fractions, square roots and big numbers are kept exact, and decimals only appear when you ask.

Fractions stay fractions

Every number is kept exactly. 1/3 + 1/6 is 1/2, and even 0.1 + 0.2 is exactly 3/10 -- the rounding error other calculators show never happens.

Square roots

Square roots are simplified and kept exact: sqrt(8) is 2sqrt(2), and sqrt(2)*sqrt(2) is exactly 2.

Higher roots too: 54^(1/3), cbrt(54) and root(54, 3) are all 3cbrt(2), and cbrt(2)*cbrt(4) is exactly 2. A sum of unlike roots, cbrt(2) + 1, has no exact form and is a decimal.

Big numbers

Whole numbers have no size limit: every digit of 2^100 or 30! is correct.

A fraction is exact too, however long: sum(1/k, k, 1, 50) is a 23-digit over 22-digit fraction, and harmonicNumber(100) a 41-digit over 40-digit one. A sum whose exact total would pass 400 digits is refused by name: fsum(term, k, a, b) adds it in doubles instead, a million terms if need be. Primes and factors are found at any size up to 38 digits: isPrime(2^61 - 1), factor(2^64 + 1).

When decimals appear

Some values have no exact form -- pi, e, sin(1), ln(2). These are approximations and show 10 significant digits. Anything worked out from one is an approximation too.

ln(x) is the natural logarithm and log(x) the logarithm to base 10; log(b, x) takes the base first. JEE and most calculus texts write log for ln: write ln there. ln(e) is 1 and ln(e^3) is 3 exactly.

Two functions turn an exact value into a decimal on purpose: float(x) writes it to six decimals as text, and approx(x) gives it as a double you can go on calculating with, approx(1/3) is 0.3333333333 and approx([1/3, sqrt(2)]) a list of doubles.

Asking for a decimal

To see an exact number as a decimal, ask: decimal(x, digits) gives as many digits as you like, correctly, scientific uses powers of ten, float gives a quick approximation and repeating shows the repeating block.

Letters as symbols

A name that has no value yet is a symbol, so a formula written with it stays a formula you can differentiate, expand or solve.