🛰️Ordinary Differential Equations: Initial Value Problems
Linear Systems and the Matrix Exponential
x′ = Ax, modes and stability, computing e^{At}, exact discretisation for digital control, transient growth, the Lyapunov equation
Nineteen dubious ways, 1978
By the 1970s, control engineers had a routine problem. A spacecraft, an aircraft or a chemical plant is modelled by linear differential equations , but the controller is a digital computer that reads sensors and sets actuators at fixed instants. To design it, the continuous model must become a difference equation, and the matrix that does that is the exponential . Every textbook gave a formula for it. Programs implementing those formulas gave different answers for the same matrix — some of them wrong in every digit.
In 1978 two numerical analysts, Cleve Moler and Charles Van Loan, published a survey in SIAM Review with a deliberately unsettling title: Nineteen Dubious Ways to Compute the Exponential of a Matrix. They examined series methods, ODE solvers, polynomial and eigenvector methods and matrix decompositions, and showed how each could fail. None was satisfactory for every matrix. A few were good enough to recommend.
The paper became one of the most influential in numerical linear algebra. Twenty-five years later the journal republished it with an update, Twenty-Five Years Later. Moler, meanwhile, had written a small interactive matrix program for his students — MATLAB — and its
expm function implemented the method they recommended.A linear system with constant coefficients, , , has the exact solution
the same series as the scalar exponential, which converges for every square matrix. Every linearised model in engineering has this form: a structure's vibration (Unit 6), small deviations of a spacecraft's attitude or an aircraft from trim, an electrical network, the error dynamics of a navigation filter. For such systems the time-stepping of lessons 9-1 to 9-4 is not needed at all: the exact solution is available.
Derivation
Why solves the system, and what it looks like in modes
It solves the equation. Differentiate the series term by term; each term loses one power of and gains a factor :
So satisfies , and at the series is , so .
In modes. If , then , and in general . Put that in every term of the series:
With this is , the modal sum below — the same modes as lesson 6-1's guess , now added up to fit the initial state.
💡Modes and stability
If with eigenvalues and eigenvectors (Unit 6), then , and
The solution is a sum of modes. A real eigenvalue gives exponential growth or decay with time constant ; a complex pair gives an oscillation at frequency with envelope . The system is asymptotically stable exactly when every eigenvalue has . For a damped oscillator the eigenvalues are : damping sets the decay, the natural frequency the oscillation. Eigenvalues spread over many orders of magnitude are what made the equations of lesson 9-4 stiff.
📐Moler and Van Loan's test matrix
has eigenvalues and , so is small: its entries are below 1.5. Summing the Taylor series, the terms grow to before they decay, and the answer is what remains after they cancel — catastrophic cancellation (lesson 1-2) on a grand scale. In single precision the result is wrong by 87%; in double precision it loses seven of its sixteen digits. The eigenvector formula is perfect here — but for a nearly defective matrix with two eigenvalues apart, the eigenvector matrix has condition number and the formula loses eight digits.
scipy.linalg.expm is accurate to on both.💡How expm works: scaling and squaring
The method Moler and Van Loan recommended, refined since by Nicholas Higham and Awad Al-Mohy, uses the identity :
- Scale: choose so that is below about 1 — the series of that small matrix has no large terms to cancel.
- Approximate with a rational (Padé) approximation of degree up to 13, accurate to double precision for such a small argument.
- Square the result times.
scipy.linalg.expm; never sum the series, and use the eigendecomposition only for symmetric (normal) matrices, where is orthogonal and perfectly conditioned.Exact discretisation. A digital controller applies an input and holds it constant until the next sample — a zero-order hold. Over one sample period the solution of is then exactly
Both come from one exponential of an augmented matrix: — a trick Van Loan published in the same year as the survey. There is no truncation error at all: the discrete model reproduces the continuous one exactly at the sampling instants, for any . Its eigenvalues are , inside the unit circle exactly when — continuous stability maps to discrete stability.
Derivation
The zero-order-hold formulas, and the augmented-matrix trick
Variation of constants. Multiply by . The left side becomes an exact derivative, because :
Integrate from to with held constant, then multiply by :
substituting in the integral. That is and , with no approximation anywhere.
One exponential for both. Let . Its powers keep the zero row: for . Summing the exponential series block by block,
and the top-right series is exactly (integrate term by term). One call to
expm gives and together.Euler's eigenvalues. Forward Euler uses , whose eigenvalues are . For , , which exceeds 1 whenever the damping is light compared with the frequency — however small is.
📐Forward Euler is not a discretisation
A lightly damped structural mode (1 Hz, 2% damping) sampled at ms and pushed by 10 N for half a second. The exact map has eigenvalues of magnitude 0.998744 ; after 20 s its prediction agrees with a high-accuracy ODE solution to all six printed digits ( m). The 'obvious' model — forward Euler — has eigenvalues of magnitude 1.000717: unstable, for any step size, as lesson 9-4's stability region predicts for eigenvalues near the imaginary axis. After 20 s it predicts m — fifty times the truth, and growing. A controller or Kalman filter designed on that model would be designed for a system that does not exist.
💡When eigenvalues mislead: transient growth
Stable eigenvalues guarantee that eventually, not that it stays small on the way. has eigenvalues and , yet rises to 12.5 at before decaying: its eigenvectors are nearly parallel, and two decaying modes that nearly cancel at stop cancelling as one decays faster than the other. Such non-normal matrices — whose eigenvectors are far from orthogonal — appear in shear flows (the transition to turbulence), in feedback loops and in coupled structures. Lloyd N. Trefethen's pseudospectra make this precise. The engineering lesson: check , not just the eigenvalues.
The Lyapunov equation. If a stable system is driven by white noise of intensity through , , its covariance settles to the solution of
a linear equation for the entries of , solved by
scipy.linalg.solve_continuous_lyapunov (the Bartels–Stewart algorithm of 1972, which first reduces to triangular form with the QR algorithm of lesson 6-3). For an oscillator shaken by noise it gives — 0.15625 for , , — and 4000 simulated oscillators agree (0.1568). Aleksandr Lyapunov introduced the equation in 1892 to prove stability; in Unit 12 it reappears as the steady-state uncertainty of a filter, and its nonlinear relative, the Riccati equation, as the steady state of the Kalman filter.Derivation
Where the Lyapunov equation comes from — and how the lab simulates the noise
One sample step. Over a short interval the state moves as , where is the noise collected during the interval, independent of , with covariance . Lesson 5-1's rule for a linear map, plus independence, gives the covariance one step later:
The continuous limit. For small , and (white noise adds variance in proportion to elapsed time). Then
dropping terms in . The covariance stops changing when the bracket is zero — the Lyapunov equation. A stable removes uncertainty through exactly as fast as the noise adds it through .
Exact noise for any . The noise entering during one interval is (the variation-of-constants formula above with as input), and its covariance is . Van Loan showed it can be read off one more augmented exponential, , and multiplied by its top-right block is . That is how the lab's 4000 oscillators are stepped without any discretisation error.
The greatest shortcoming of the human race is man's inability to understand the exponential function.
💡Where you will use this
Spacecraft Attitude Control and Optimal Control: every state-space design — pole placement, LQR, observers — starts from and . GNSS and Navigation: the Kalman filter's state transition matrix and its discrete process noise, computed with Van Loan's augmented exponential. Structural Dynamics: exact modal time-stepping for linear structures. Electrical and Power Systems: small-signal stability of power grids is an eigenvalue problem of . Rocket Propulsion: linearised models of feed-system and combustion instabilities.
📚Further reading
- Cleve Moler and Charles Van Loan, 'Nineteen dubious ways to compute the exponential of a matrix, twenty-five years later', SIAM Review 45(1), 3–49 (2003) — the survey of the cold open, updated.
- Nicholas Higham, Functions of Matrices: Theory and Computation (SIAM, 2008), chapter 10, 'Matrix Exponential' — scaling and squaring as
expmdoes it. - Charles Van Loan, 'Computing integrals involving the matrix exponential', IEEE Transactions on Automatic Control 23(3), 395–404 (1978) — the augmented-matrix formulas for Γ and for the discrete noise covariance.
↓But there is a problem
Every problem in this unit was an initial value problem: the whole state given at one instant, then marched forward in time.
A beam does not work that way. Its deflection is known at both ends — zero at two supports, or zero deflection and zero slope at a clamped end and zero moment at a free one — and the equation must be satisfied everywhere in between. A heat shield's temperature is set on both faces. The pressure in an aquifer is fixed on every boundary of the domain. These are boundary value problems, and when the unknown varies in space and time, partial differential equations. They are the next unit — and the place where most engineering simulation actually happens.