II. Linear algebra and geometry

21. Matrices

Write a matrix in square brackets as in Matlab: entries separated by spaces, rows by a semicolon or a new line. An entry may be a fraction, a root or a letter. The key with a grid on the f(x) tab opens a table to fill in cell by cell – or to paste into from the clipboard (cells copied from Excel or Google Sheets) or load from a CSV file.

For a single matrix a chip says what to compute: the determinant (2×2 by the formula, 3×3 by the rule of Sarrus, otherwise by expansion along a row or column or by row reduction to a triangular matrix – the method is a chip too), the inverse (2×2 by the formula, otherwise by Gauss–Jordan elimination with the identity beside it), the rank (row reduction to row echelon form) or the transpose.

Name several matrices with capital letters, each on its own line, and write what to compute on the last line: a sum, difference, multiple, product (row by column, with the sizes checked), power, transpose A^T, inverse A^-1, det(A), rank(A) – or a matrix equation AX = B or XA = B, which the app solves with the inverse. A system of equations given by a matrix (an augmented matrix, Ax = b) is covered in the chapter Systems of equations.

If a matrix contains a parameter (a letter), the app discusses its rank by the parameter's values just like a system – row reduction to echelon form, the critical values put in. For an inverse it first computes the determinant and the condition for which values of the parameter it isn't zero (the inverse exists). A 3×3 or bigger inverse is computed by Gauss–Jordan elimination or – by the chip – by the adjugate matrix (cofactors, A⁻¹ = adj A / det A).

For a square matrix you can also compute the eigenvalues and eigenvectors: the characteristic polynomial det(A − λE) is written out like a determinant, factored, and its roots are the eigenvalues (a quadratic factor by the discriminant, complex ones too; a cubic without a rational root approximately). The eigenvectors are the solutions of (A − λE)v = o by row operations to the reduced row echelon form; for each eigenvalue the app gives its algebraic and geometric multiplicity. The Diagonalization chip also builds P and D (A = PDP⁻¹), or explains why the matrix can’t be diagonalized. The singular value decomposition A = UΣVᵀ (SVD) and the pseudoinverse A⁺ work for a matrix of any size: SVD through the eigenvalues of AᵀA (AAᵀ for a wide matrix), the normalized eigenvectors and the other side computed from them; the pseudoinverse of a full-rank matrix by the formula (AᵀA)⁻¹Aᵀ, otherwise from the decomposition A⁺ = VΣ⁺Uᵀ – and if the singular values would be nested radicals, exactly from the rank factorization A = BC by A⁺ = Cᵀ(CCᵀ)⁻¹(BᵀB)⁻¹Bᵀ.

The app also works out the eigenvalues and the diagonalization of a matrix with one parameter (up to 3×3): it factors the characteristic polynomial with the parameter, writes the eigenvalues as its functions and finds the special values of the parameter – where two eigenvalues coincide (two factors have a common root, a quadratic factor a zero discriminant) or where the general computation of the eigenvectors would divide by zero; it also tells for which values the eigenvalues are complex. The general case is solved with the parameter, the special values are put in and discussed separately. The Diagonalization chip then answers for which values of the parameter the matrix is diagonalizable.

The Jordan form of a square matrix (the chip Jordan form, written jordan(A)) comes from the ranks of the powers (A − λE)ᵏ: they give the number and the sizes of the Jordan blocks, the chains of generalized eigenvectors are built from the top vector down to an eigenvector and P, J are checked (A = PJP⁻¹). The Jordan form also gives the power Aⁿ for a general n (the chip Power Aⁿ, written A^n; a block's power by the binomial theorem, the result like 2ⁿ⁻¹(n + 2)) or a big number (A^10), and the matrix exponential eᴬᵗ and eᴬ (the chip Matrix exponential, written e^A, e^(At), exp(A), expm(A*t)) – useful for systems of differential equations x′ = Ax; complex eigenvalues are rewritten as cosines and sines. The minimal polynomial (the chip Minimal polynomial, written minpoly(A)) is found by trying the candidates – the divisors of the characteristic polynomial – from the lowest degree; the app recalls the Cayley–Hamilton theorem p(A) = O and for an invertible matrix gets the inverse from m(A) = O.

How to enter it

[1 2 3; 4 5 6; 7 8 10]Entries by spaces, rows by a semicolon (or on new lines inside the brackets).
A = [1 2; 3 4]
B = [0 1; 1 0]
A*B - 2B^T
Named matrices a line each, the computation on the last line.
det(A), A^-1, A^T, rank(A)Determinant, inverse and transpose, rank.
eig(A), diagonalize(A), svd(A), pinv(A), A^+Eigenvalues, diagonalization, singular value decomposition, pseudoinverse.
jordan(A), A^n, e^A, e^(At), minpoly(A)Jordan form, a general power, the matrix exponential, the minimal polynomial.

Examples

A 3×3 determinant by the rule of Sarrus.
Input: [1 2 3; 4 5 6; 7 8 10] Determinant
[1 2 3; 4 5 6; 7 8 10]
Expansion along the column with the most zeros.
Input: [1 0 2; 3 0 1; 4 5 6] Expansion
[1 0 2; 3 0 1; 4 5 6]
The inverse by Gauss–Jordan elimination.
Input: [1 2 3; 4 5 6; 7 8 10] Inverse matrix
[1 2 3; 4 5 6; 7 8 10]
[1 2 3; 4 5 6; 7 8 10][1 2 3; 4 5 6; 7 8 10]
The rank by row reduction.
Input: [1 2 3; 4 5 6; 7 8 9] Rank
[1 2 3; 4 5 6; 7 8 9]
The rank of a matrix with a parameter.
Input: [a 1 1; 1 a 1; 1 1 a] Rank
[a 1 1; 1 a 1; 1 1 a]
[a 1 1; 1 a 1; 1 1 a][a 1 1; 1 a 1; 1 1 a]
The inverse with a parameter by the adjugate matrix.
Input: [1 0 a; 0 1 0; 1 0 1] Adjugate matrix
[1 0 a; 0 1 0; 1 0 1]
[1 0 a; 0 1 0; 1 0 1][1 0 a; 0 1 0; 1 0 1]
Product, transpose, multiple and difference of matrices.
Input: A = [1 2; 3 4]
B = [0 1; 1 0]
A*B - 2B^T
A = [1 2; 3 4]
B = [0 1; 1 0]
A*B - 2B^T
A matrix equation AX = B by the inverse.
Input: A = [1 2; 3 4]
B = [5; 6]
AX = B
A = [1 2; 3 4]
B = [5; 6]
AX = B
The eigenvalues and eigenvectors of a symmetric matrix.
Input: [2 1; 1 2] Eigenvalues
[2 1; 1 2]
[2 1; 1 2][2 1; 1 2]
Irrational eigenvalues by the discriminant.
Input: [1 2; 3 4] Eigenvalues
[1 2; 3 4]
[1 2; 3 4][1 2; 3 4]
The diagonalization A = PDP⁻¹.
Input: [2 0 0; 0 3 4; 0 4 9] Diagonalization
[2 0 0; 0 3 4; 0 4 9]
[2 0 0; 0 3 4; 0 4 9][2 0 0; 0 3 4; 0 4 9]
A matrix that can’t be diagonalized.
Input: [1 1 0; 0 1 0; 0 0 2] Diagonalization
[1 1 0; 0 1 0; 0 0 2]
[1 1 0; 0 1 0; 0 0 2][1 1 0; 0 1 0; 0 0 2]
Eigenvalues of a matrix with a parameter – the special values and their cases.
Input: [1 1 0; 0 a 0; 0 0 2] Eigenvalues
[1 1 0; 0 a 0; 0 0 2]
[1 1 0; 0 a 0; 0 0 2][1 1 0; 0 a 0; 0 0 2][1 1 0; 0 a 0; 0 0 2][1 1 0; 0 a 0; 0 0 2]
For which values of the parameter the matrix is diagonalizable.
Input: [0 1; a 0] Diagonalization
[0 1; a 0]
[0 1; a 0][0 1; a 0]
The singular value decomposition of a 2×3 matrix.
Input: [3 2 2; 2 3 -2] Singular value decomposition (SVD)
[3 2 2; 2 3 -2]
[3 2 2; 2 3 -2][3 2 2; 2 3 -2]
The pseudoinverse of a matrix with independent columns.
Input: [1 0; 0 1; 1 1] Pseudoinverse
[1 0; 0 1; 1 1]
[1 0; 0 1; 1 1][1 0; 0 1; 1 1]
The pseudoinverse of a singular matrix from its singular value decomposition.
Input: A = [1 2; 2 4]
A^+
A = [1 2; 2 4]
A^+
A = [1 2; 2 4]
A^+A = [1 2; 2 4]
A^+
The pseudoinverse from the rank factorization A = BC.
Input: [1 2 3; 4 5 6; 7 8 9] Pseudoinverse
[1 2 3; 4 5 6; 7 8 9]
[1 2 3; 4 5 6; 7 8 9][1 2 3; 4 5 6; 7 8 9]
A Jordan form with two blocks of one eigenvalue.
Input: [1 1 0; -1 3 0; -1 1 2] Jordan form
[1 1 0; -1 3 0; -1 1 2]
[1 1 0; -1 3 0; -1 1 2][1 1 0; -1 3 0; -1 1 2]
The power Aⁿ through the Jordan form.
Input: [3 1; -1 1] Power Aⁿ
[3 1; -1 1]
[3 1; -1 1][3 1; -1 1]
The exponential eᴬᵗ – the solution of the system x′ = Ax.
Input: A = [0 1; -2 -3]
e^(At)
A = [0 1; -2 -3]
e^(At)
A = [0 1; -2 -3]
e^(At)A = [0 1; -2 -3]
e^(At)
The minimal polynomial, the Cayley–Hamilton theorem and the inverse from it.
Input: [2 1 0; 0 2 0; 0 0 3] Minimal polynomial
[2 1 0; 0 2 0; 0 0 3]
[2 1 0; 0 2 0; 0 0 3][2 1 0; 0 2 0; 0 0 3]

Known limitations