A function of a matrix is not a function of its entries
Worth reading first: The matrix that is one row · The eigenvalues that are not there · The condition number is an amplifier.
The first thing anybody is told about a function of a matrix is that it is not the elementwise version. exp(A) is not the matrix of exp(aᵢⱼ); the exponential of the identity is not the matrix of e’s. Whatever f(A) is, it is not f applied to the entries.
The second thing is what it is, and it comes in the form of a recipe:
A = VΛV⁻¹ ⟹ f(A) = V f(Λ) V⁻¹
Diagonalise, apply f to each eigenvalue, undiagonalise. It is correct wherever A is diagonalisable, which is almost everywhere, and it looks like a method because it is written as three steps.
It is a definition. This essay is about the distance between those two words, and the distance is sixty-five orders of magnitude.
The family, which is built to leave no excuse
The obvious objection to any experiment of this kind is that the eigensolver was bad. So the experiment is arranged so that no eigensolver runs.
A_δ is upper bidiagonal: diagonal λ, λ+δ, λ+2δ, …, and μ above it. Two consequences:
Its eigenvalues are its diagonal, exactly. A triangular matrix’s eigenvalues are on its diagonal — that is not a computation, it is the definition of the characteristic polynomial of a triangular matrix — and the entries are written down.
Its eigenvectors have a closed form. Back-substitution gives, for the eigenvalue λ + kδ,
vᵢ = μ^(k−i) / ((k−i)! δ^(k−i)), i ≤ k
which is a formula, not an iteration.
So the route is handed exact eigenvalues and exact eigenvectors, and it still has to invert V. At δ = 10⁻¹² and n = 8, κ(V) is 3.3·10⁸².
And at δ = 0 the matrix is λI + μS with S the shift, which is not diagonalisable at all — one eigenvalue of multiplicity n, one eigenvector, no V — and whose exponential is known in closed form:
e^{λI + μS} = e^λ (I + μS + μ²S²/2! + … + μ^(n−1)S^(n−1)/(n−1)!)
a finite sum, because S is nilpotent. Every entry is e^λ μᵏ/k!.
The family therefore has a theorem at its limit and a route to it that has none.
What each route returns
| δ | ‖A_δ − A₀‖ | eigen route | scaling and squaring |
|---|---|---|---|
| 10⁻¹ | 0.70 | 0.545 | 0.545 |
| 10⁻² | 0.070 | 0.042 | 0.042 |
| 10⁻³ | 0.0070 | 4.4·10² | 0.0041 |
| 10⁻⁴ | 7.0·10⁻⁴ | 7.2·10⁸ | 4.1·10⁻⁴ |
| 10⁻⁶ | 7.0·10⁻⁶ | 1.6·10²³ | 4.1·10⁻⁶ |
| 10⁻⁸ | 7.0·10⁻⁸ | 5.5·10³⁷ | 4.1·10⁻⁸ |
| 10⁻¹² | 7.0·10⁻¹² | 2.9·10⁶⁵ | 4.1·10⁻¹² |
Two things to read out of it.
The right-hand column equals the second column. Scaling and squaring returns the exponential of the matrix it was handed, to full precision; the residual error is the distance from A_δ to A₀, which is not an error at all — it is the two matrices being different matrices.
The first two rows are the control. At δ = 0.1 and δ = 0.01 the two routes agree, because the matrix really is that far from the limit and κ(V) is only 10⁵ and 10¹². The separation is not an artefact of the comparison; it appears exactly where κ(V) does.
The one-sentence explanation
f(A) is a continuous function of A. V is not.
The exponential of a matrix is an entire function of its entries — it is a convergent power series in them — so a perturbation of 7·10⁻¹² in A moves e^A by about 7·10⁻¹². That is a theorem and the right-hand column of the table is it, measured.
The eigenvector matrix has no such property. As two eigenvalues approach each other their eigenvectors approach each other, V approaches singularity, and V⁻¹ blows up. At a defective matrix V does not exist at all. So a formula written in V is a formula in a quantity that has no limit where the answer does.
That is the sentence, and it applies to every f, not just the exponential. The square root, the logarithm, the sign, the sine — all of them have the same definition, all of them are continuous in A where they are defined, and all of them have the same defect if computed through V.
What a method looks like instead
The method that gets the right answer never mentions an eigenvalue.
Scaling and squaring. Choose s so that ‖A/2ˢ‖ is around a half. Compute a rational (Padé) approximant to e^{A/2ˢ}, which is a polynomial in A divided by another polynomial in A — evaluated as one linear solve. Then square s times:
e^A = (e^{A/2ˢ})^(2ˢ)
Every operation is a matrix product or a linear solve. No spectrum is computed, no eigenvector is formed, and nothing in it can notice whether A is diagonalisable.
That is not a coincidence, and it is the design principle: a computation whose only operations are polynomials in A and solves with A automatically respects the continuity that f(A) has and V does not. The site’s whole family of Krylov methods has the same property for the same reason.
The Jordan form is not the fix
The natural repair, on being shown the above, is to reach for the Jordan form: if the trouble is that A is nearly defective, use the decomposition that handles defective matrices.
It is worse, and the reason is instructive. The Jordan form is a discontinuous function of the matrix: A₀ has one block of size 8, and A_δ for any δ ≠ 0 has eight blocks of size 1. An arbitrarily small perturbation changes the answer completely, and a computation cannot distinguish δ = 0 from δ = 10⁻²⁰.
The Schur form is the one that works — every matrix has one, it is computed by orthogonal similarities
so nothing amplifies, and f of a triangular matrix can be got by a recurrence. That recurrence has its
own difficulty when two diagonal entries are close, which is handled by grouping them into blocks, and
the whole business is the standard funm algorithm. It is a real method and it is not the definition.
Where this bites in practice
A nearly defective matrix sounds like a laboratory construction. It is the ordinary case in three places.
Repeated roots from symmetry. A structure with a symmetry has degenerate modes, and a small asymmetry — a manufacturing tolerance, a mesh that is not quite symmetric — splits them by a tiny amount. The eigenvectors are then determined by the perturbation rather than by the structure.
Multiple time constants in a linear system. ẋ = Ax with two decay rates that happen to be close. The transition matrix is e^{At}, and computing it through the eigendecomposition puts the difference of two nearly equal rates in a denominator.
Companion and controllability matrices. A companion matrix built from a polynomial with a near-double root is nearly defective by construction, and control theory forms them constantly.
In all three the eigenvalues themselves may be perfectly well determined — a symmetric matrix’s eigenvalues are always well conditioned — while the eigenvectors are not, and it is the vectors the formula needs.
What the definition is still for
None of this makes the eigendecomposition useless, and it is worth being precise about what it is still exactly right for, because the list is longer than the argument above suggests.
Reasoning. f(A)'s eigenvalues are f of A’s eigenvalues; f(A) commutes with A; ‖f(A)‖ ≥ max|f(λ)|. All of those come straight from the definition and none of them is a computation.
Symmetric and normal matrices. Here V is orthogonal, κ(V) = 1, and the definition is a method — the best one there is. The whole objection above is about κ(V), and for a symmetric matrix that number is one by construction. A symmetric matrix function should be computed by diagonalising, always.
Deciding what a function of a matrix even means for a defective one. The Jordan definition — f applied to a block involves f, f′, f″, … — is how the object is defined where there is no basis of eigenvectors, and the closed form this essay measures against is exactly that definition evaluated by hand.
So the split is clean: normal matrices, diagonalise; everything else, stay polynomial in A. That is one of the sharper practical rules the site has, and it falls out of a single number.
The exponential is where the stakes are
Of all the matrix functions, e^{At} is the one that is actually computed, because it is the solution operator of ẋ = Ax. Every linear system of ordinary differential equations, every Markov chain in continuous time, every exponential integrator, every state transition in a Kalman filter over an interval — all of them are asking for e^{At} or for its action on a vector.
And the standard failure has a name. Moler and Van Loan’s Nineteen Dubious Ways to Compute the Exponential of a Matrix is fifty years old, was reissued twenty-five years later with the count unchanged, and its conclusion was that no method is reliable for all classes of matrices. Two of the nineteen have survived as defaults: scaling and squaring with a Padé approximant, for the matrix; and Krylov, for the action on a vector.
Both of them are polynomials in A. That is not a coincidence either.
The other functions, and where each one stops existing
The exponential is the easy case in one respect that is worth being explicit about: it is entire, so e^A exists for every matrix and there is nothing to choose. The functions that follow it are not, and what they lose is worth separating from what this essay has been about.
The square root. Every matrix with no eigenvalue on the negative real axis has a principal square root — the one whose eigenvalues have positive real part — and it is unique. But a matrix with n distinct eigenvalues has 2ⁿ square roots, one per choice of sign, and if any eigenvalue is repeated there are infinitely many. So “the square root of A” is a convention, and a computation has to say which one it is producing. The identity matrix’s square roots include every reflection.
The logarithm. Same structure, worse: log A exists when A has no eigenvalue on the closed negative real axis, the principal branch is the one whose eigenvalues have imaginary part in (−π, π], and a real matrix with negative real eigenvalues has no real logarithm at all. That last case is not exotic — a rotation by π has one.
The sign function. sign(A) is defined for any matrix with no eigenvalue on the imaginary axis, and it is not continuous there: a matrix one rounding error either side of it returns a completely different answer. It is also the one whose definition is most obviously a computation rather than a formula, since sign(A) = A(A²)^(−1/2) is a composition of two other functions.
All three inherit this essay’s objection in full, and all three inherit something extra: where the exponential’s difficulty is the conditioning of a similarity, theirs is also the existence of the answer. A method has to decline rather than return a plausible matrix, which is the same discipline a proof that declines has everywhere on this site — and the interval field’s whole subject.
And the easy case is worth naming last, because it is most of what anybody computes. If A is symmetric, V is orthogonal, κ(V) = 1, and the definition is the best method there is. Diagonalise, apply f to the eigenvalues, undiagonalise; the answer is accurate to the conditioning of f on the spectrum and nothing else. Every objection in this essay is an objection about non-normal matrices, and the split is that sharp.
One consequence of that split is worth stating on its own, because it decides what a practitioner should do rather than what they should believe. Test whether the matrix is normal before choosing a method. ‖AᵀA − AAᵀ‖/‖A‖² costs two matrix products and answers it; if the answer is at rounding, the eigendecomposition is both the best method and the most informative one, and every objection above is void. If it is not, the number that matters is κ(V), which cannot be computed without the eigendecomposition it is a warning about — so the honest move is not to compute it at all and use a method that does not need it.
What is worth carrying
A definition and a method are different objects, and the definition of f(A) is written in a quantity that is not continuous in A. V has no limit where f(A) has one, so a formula in V is not a computation of f.
Handing the route exact eigenvalues and exact eigenvectors does not save it. The experiment above does exactly that — a triangular matrix’s spectrum is its diagonal and its eigenvectors are a closed form — and the answer is still wrong by sixty-five orders of magnitude at δ = 10⁻¹². The defect is the inversion of V, and nothing upstream of it can help.
A method that is a polynomial in A inherits the continuity that f(A) has. Scaling and squaring, the Schur–Parlett recurrence, and Krylov all have that property; the eigendecomposition and the Jordan form do not.
The next essay is about the method that does work, and about the fact that it has a parameter with a worst value on both sides: the series that has to be squared back.
What links here
Computed from the collection, not written here: the essays that point at this one.
Reads more easily once this is understood
Essays that name this one as worth reading first.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- An equation whose unknown is a matrix — both name condition number, eigenvalues, non-normality
- The vector was what was wanted — both name exact ground truth, matrix exponential, matrix function
- A condition number for one eigenvalue — both name condition number, non-normality
- The number that decides nothing — both name condition number, exact ground truth
- The spectrum that predicts nothing — both name condition number, non-normality
- The units the matrix is measured in — both name condition number, exact ground truth
Named objects
A flat tag is an object no other essay names yet.
Condition numberDefective matrixEigenvaluesEigenvectorsExact ground truthJordan formMatrix exponentialMatrix functionNon-normality