Tool

Exact workbench

A scratchpad for the library. Type numbers into named matrices, then write expressions or press an operation. Numbers sets what may appear. Rational is the default, and every answer is an exact fraction. Turn on real algebraic and roots appear too: √2, eigenvalues, singular values, each held exactly as a polynomial with an interval around just that root, and they add, multiply and divide exactly. Complex adds the complex roots, shown in certified boxes. Ranges lets entries be intervals like 1:1.1 and gives enclosures, including exp(A). Mod p computes in the integers modulo a prime.

Writing numbers

FormMeans
3/4, -7, 1.25fractions, integers, terminating decimals
0.#3, 0.1#6repeating decimals: the digits after # repeat (1/3, 1/6)
2..1/2mixed number 2 + 1/2
3.~7~15continued fraction 3 + 1/(7 + 1/15)
(1/2)^3 + 1/4a cell may hold a small expression in numbers
sqrt(2), 1 + sqrt(3)/2with real algebraic numbers on
1:1.1, -1/2:1/2ranges (with Ranges on): every value from the first to the second
3, 1/2with Mod p on, a fraction means numerator × denominator⁻¹ mod p

Writing expressions

FormMeans
[1, 2; 3, 4]a matrix: commas between entries, semicolons (or new lines) between rows
[A, b], [A; B]side by side, or stacked
A + B, A - B, A*B, 2A, A/3arithmetic; a number next to a matrix multiplies it
A^3, A^-1, A'powers (negative powers invert) and transpose
C = A*B, k = det(A)save a result as a new matrix or number
↑ / ↓step through earlier commands

Functions

The same work from JavaScript

import { Matrix, det, inverse, solve } from "@ratmath/linalg";

const A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 10]]);
det(A).exact().toString();                 // "-3"
inverse(A).exact().toStrings();            // [["-2/3","-4/3","1"], ["-2/3","11/3","-2"], ["1","-2","1"]]
solve(A, [1, 2, 3]).exact().x.toStrings(); // [["-1/3"], ["2/3"], ["0"]]
Try itEdit the code and run it with @ratmath/linalg and Core's Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs