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] | 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
[1 2 3; 4 5 6; 7 8 10] Determinant
[1 0 2; 3 0 1; 4 5 6] Expansion
[1 2 3; 4 5 6; 7 8 10] Inverse matrix![[1 2 3; 4 5 6; 7 8 10]](img/matrices-inverse.png)
![[1 2 3; 4 5 6; 7 8 10]](img/matrices-inverse-1.png)
![[1 2 3; 4 5 6; 7 8 10]](img/matrices-inverse-2.png)
[1 2 3; 4 5 6; 7 8 9] Rank
[a 1 1; 1 a 1; 1 1 a] Rank![[a 1 1; 1 a 1; 1 1 a]](img/matrices-rank-parameter.png)
![[a 1 1; 1 a 1; 1 1 a]](img/matrices-rank-parameter-1.png)
![[a 1 1; 1 a 1; 1 1 a]](img/matrices-rank-parameter-2.png)
[1 0 a; 0 1 0; 1 0 1] Adjugate matrix![[1 0 a; 0 1 0; 1 0 1]](img/matrices-inverse-adjugate.png)
![[1 0 a; 0 1 0; 1 0 1]](img/matrices-inverse-adjugate-1.png)
![[1 0 a; 0 1 0; 1 0 1]](img/matrices-inverse-adjugate-2.png)
A = [1 2; 3 4]
B = [0 1; 1 0]
A*B - 2B^T
A = [1 2; 3 4]
B = [5; 6]
AX = B
[2 1; 1 2] Eigenvalues![[2 1; 1 2]](img/matrices-eigen.png)
![[2 1; 1 2]](img/matrices-eigen-1.png)
![[2 1; 1 2]](img/matrices-eigen-2.png)
[1 2; 3 4] Eigenvalues![[1 2; 3 4]](img/matrices-eigen-irrational.png)
![[1 2; 3 4]](img/matrices-eigen-irrational-1.png)
![[1 2; 3 4]](img/matrices-eigen-irrational-2.png)
[2 0 0; 0 3 4; 0 4 9] Diagonalization![[2 0 0; 0 3 4; 0 4 9]](img/matrices-diagonalize.png)
![[2 0 0; 0 3 4; 0 4 9]](img/matrices-diagonalize-1.png)
![[2 0 0; 0 3 4; 0 4 9]](img/matrices-diagonalize-2.png)
[1 1 0; 0 1 0; 0 0 2] Diagonalization![[1 1 0; 0 1 0; 0 0 2]](img/matrices-not-diagonalizable.png)
![[1 1 0; 0 1 0; 0 0 2]](img/matrices-not-diagonalizable-1.png)
![[1 1 0; 0 1 0; 0 0 2]](img/matrices-not-diagonalizable-2.png)
[1 1 0; 0 a 0; 0 0 2] Eigenvalues![[1 1 0; 0 a 0; 0 0 2]](img/matrices-eigen-parameter.png)
![[1 1 0; 0 a 0; 0 0 2]](img/matrices-eigen-parameter-1.png)
![[1 1 0; 0 a 0; 0 0 2]](img/matrices-eigen-parameter-2.png)
![[1 1 0; 0 a 0; 0 0 2]](img/matrices-eigen-parameter-3.png)
![[1 1 0; 0 a 0; 0 0 2]](img/matrices-eigen-parameter-4.png)
[0 1; a 0] Diagonalization![[0 1; a 0]](img/matrices-diagonalize-parameter.png)
![[0 1; a 0]](img/matrices-diagonalize-parameter-1.png)
![[0 1; a 0]](img/matrices-diagonalize-parameter-2.png)
[3 2 2; 2 3 -2] Singular value decomposition (SVD)![[3 2 2; 2 3 -2]](img/matrices-svd.png)
![[3 2 2; 2 3 -2]](img/matrices-svd-1.png)
![[3 2 2; 2 3 -2]](img/matrices-svd-2.png)
[1 0; 0 1; 1 1] Pseudoinverse![[1 0; 0 1; 1 1]](img/matrices-pseudoinverse.png)
![[1 0; 0 1; 1 1]](img/matrices-pseudoinverse-1.png)
![[1 0; 0 1; 1 1]](img/matrices-pseudoinverse-2.png)
A = [1 2; 2 4]
A^+![A = [1 2; 2 4]
A^+](img/matrices-pseudoinverse-svd.png)
![A = [1 2; 2 4]
A^+](img/matrices-pseudoinverse-svd-1.png)
![A = [1 2; 2 4]
A^+](img/matrices-pseudoinverse-svd-2.png)
[1 2 3; 4 5 6; 7 8 9] Pseudoinverse![[1 2 3; 4 5 6; 7 8 9]](img/matrices-pseudoinverse-factorization.png)
![[1 2 3; 4 5 6; 7 8 9]](img/matrices-pseudoinverse-factorization-1.png)
![[1 2 3; 4 5 6; 7 8 9]](img/matrices-pseudoinverse-factorization-2.png)
[1 1 0; -1 3 0; -1 1 2] Jordan form![[1 1 0; -1 3 0; -1 1 2]](img/matrices-jordan.png)
![[1 1 0; -1 3 0; -1 1 2]](img/matrices-jordan-1.png)
![[1 1 0; -1 3 0; -1 1 2]](img/matrices-jordan-2.png)
[3 1; -1 1] Power Aⁿ![[3 1; -1 1]](img/matrices-power.png)
![[3 1; -1 1]](img/matrices-power-1.png)
![[3 1; -1 1]](img/matrices-power-2.png)
A = [0 1; -2 -3]
e^(At)![A = [0 1; -2 -3]
e^(At)](img/matrices-exponential.png)
![A = [0 1; -2 -3]
e^(At)](img/matrices-exponential-1.png)
![A = [0 1; -2 -3]
e^(At)](img/matrices-exponential-2.png)
[2 1 0; 0 2 0; 0 0 3] Minimal polynomial![[2 1 0; 0 2 0; 0 0 3]](img/matrices-minpoly.png)
![[2 1 0; 0 2 0; 0 0 3]](img/matrices-minpoly-1.png)
![[2 1 0; 0 2 0; 0 0 3]](img/matrices-minpoly-2.png)
Known limitations
- Matrices up to 6×6.
- Eigenvalues, diagonalization, the singular value decomposition, the Jordan form, the power Aⁿ, the exponential and the minimal polynomial for matrices up to 4×4 and without a parameter; eigenvalues and diagonalization with one parameter up to 3×3 (no cubic factor with the parameter), the general case’s eigenvectors only for eigenvalues without a root of the parameter.
- The Jordan form with its steps only for rational eigenvalues, otherwise just the result; a general power Aⁿ and eᴬᵗ need exact eigenvalues (a cubic factor without a rational root: only eᴬ approximately).