ApasScript.

Matrices

mat

Constructs a matrix from row arrays -- exactly 2x2 or 3x3 dispatches to the fixed-size fast path, anything else (including non-square) uses the general matrix type. A power A^k works for k from 1 to 10000, while n^2 * k * d is at most 30000, where n is the matrix's size and d the digits of its largest entry.

matDet

The determinant of a matrix.

matTrace

The trace (sum of diagonal entries) of a matrix.

matInverse

The inverse of a matrix, computed exactly (fractions, not floats). Returns explanatory text ('singular, no inverse') when the matrix has no inverse.

matTranspose

The transpose of a matrix.

matAdd

Adds two matrices of the same shape.

matSub

Subtracts b from a, for two matrices of the same shape.

matMul

Multiplies two compatibly-shaped matrices.

matScale

Multiplies every entry of a matrix by a scalar.

matSolve

Solves the linear system m*x = b for x, exactly, across 2x2/3x3/general shapes. Returns explanatory text ('no unique solution') when the system has none.

rref

Reduced row echelon form of any matrix (2x2, 3x3 or general rectangular), by exact Gauss-Jordan elimination -- fractions stay fractions.

matRank

The rank of a matrix: the number of pivots, exact. (rank() is a different thing: a tensor's number of indices, which is 2 for any matrix.) A decimal known only approximately is refused.

nullSpace

A basis of the null space, the solutions of A v = 0, as a list of vectors, one for each free column. An empty list when only v = 0 solves it.

columnSpace

A basis of the column space: the pivot columns of the matrix itself, as a list of vectors.

rowSpace

A basis of the row space: the nonzero rows of the reduced row echelon form.

charPoly

The characteristic polynomial det(xI - A), monic and exact. Books that write det(A - xI) differ by (-1)^n; the roots are the same.

eigenvalues

The distinct eigenvalues of a matrix of whole numbers and fractions: real ones smallest first, or all as complex numbers if any is not real. Exact where the characteristic polynomial's roots can be written exactly; otherwise decimals from a numerical solver.

eigenvectors

Each real eigenvalue with its multiplicity and a basis of its eigenspace (fields value, multiplicity, vectors). Refused if an eigenvalue is not real or is known only as a decimal.

diagonalize

P and D with A = P D P^-1: the eigenvectors as P's columns, the eigenvalues on D's diagonal in the same order (fields P, D). Refused when there are too few eigenvectors.

gramSchmidt

Orthogonal vectors spanning the columns of the matrix, by Gram-Schmidt, not scaled to length 1 so that they stay fractions. A column that depends on the earlier ones gives none.

orthonormalize

gramSchmidt's vectors scaled to length 1, exact (with square roots).

projection

The projection of the vector b onto the column space of the matrix.

leastSquares

The x that brings A x closest to b, solving A^T A x = A^T b, exact. Refused when A's columns are dependent, as there is then no one answer.

luDecomposition

P, L, U with P A = L U (fields P, L, U), exact, for a matrix of any shape: L unit lower triangular, a row swapped only where the pivot is zero.

qrDecomposition

Q and R with A = Q R (fields Q, R), by Gram-Schmidt, exact where the square roots allow: Q's columns orthonormal, R upper triangular with a positive diagonal. Refused when A's columns are dependent.

svdNumeric

The singular value decomposition, NUMERIC (decimals, not exact), by one-sided Jacobi: A = U diag(S) V^T, the fields U, S, V, with S the nonzero singular values, largest first, and one column of U and V for each.

rowReduce Apas Cloud

rref() as a step-by-step animation: one frame per elementary row operation (swap, scale, add a multiple of another row), each captioned with the exact operation, e.g. "R2 -> R2 - 2 R1".

matBrackets

How the matrices of this run (a page, a script) are written from here on: "square" puts them in square brackets, as the ACT prints them, "round" (the default) in round ones. Only the display changes, never a value.