Why this matters for simulation: Gust response of a linearized aircraft is a forced linear system.
By the end of this lesson you can…
Write the general solution of $\mathbf x' = A\mathbf x + \mathbf g(t)$ as $\mathbf x_h + \mathbf x_p$, and find the steady state $-A^{-1}\mathbf g$ for constant forcing, saying when it attracts and what happens when $A$ is singular.
Solve a sinusoidally forced system with the complex trick $\mathbf x_p = \mathrm{Re}[(i\omega I - A)^{-1}\mathbf g\,e^{i\omega t}]$, and say why it fails exactly when $i\omega$ is an eigenvalue of $A$.
Derive Duhamel's formula $\mathbf x(t) = e^{At}\mathbf x_0 + \int_0^t e^{A(t-s)}\mathbf g(s)\,ds$ with the integrating-factor idea and read it as a superposition of kicks.
Find the two resonance peaks, their heights and the anti-resonance of a driven two-mass chain, and see how damping sets the heights.
Evaluate the Duhamel integral by hand-written quadrature, compare it with RK45, and use the exact step $e^{Ah}\mathbf x_n + A^{-1}(e^{Ah} - I)\mathbf g$ for piecewise-constant forcing.
▶ VideoParticular plus homogeneous, the steady state, the complex trick, Duhamel as a stack of kicks, and two resonance peakscaptions only
Transcript
A forced system has solutions x h plus x p: the free e to the A t times c, plus one particular solution. For constant forcing try a constant: zero equals A a plus g, so the steady state is minus A inverse g. Here: two thirds, one third.
Subtract the steady state: y equals x minus x s s obeys y prime equals A y. From rest, the distance is 0.26039 at t equals 1 and 0.03520 at t equals 3. The ratio, 0.1352, is close to e to the minus 2: the slowest eigenvalue, minus 1, sets the rate.
With A singular, eigenvalues 0 and minus 2, forcing 1, minus 1 is in the column space: from rest the solution lands on 0.5, minus 0.5, on a line of steady states. Forcing 1, 0 has none: the sum obeys s prime equals 1, reaching 5.25, 4.75 at time ten.
With g the real part of f e to the i omega t, try z e to the i omega t: i omega z equals A z plus f, so z is i omega I minus A, inverse, f, the transfer function. Its modulus is the amplitude, minus its argument the lag, its poles the eigenvalues.
Check: x double prime plus x prime plus 25 x equals cosine omega t. At omega equals 5, z one is minus 0.2 i: amplitude 0.2, lag pi over 2, against a static 0.04, a gain of 5, one over two zeta.
The solve fails when i omega I minus A is singular: i omega is an eigenvalue, resonance. Damping moves the eigenvalues to minus 0.5 plus or minus 4.975 i, 0.5 from the axis, keeping the gain finite.
For any forcing, use an integrating factor: the derivative of e to the minus A t x is e to the minus A t g. Integrate, multiply by e to the A t, and Duhamel's formula appears: the homogeneous solution carrying x zero, plus the response to g from rest.
Read it as kicks. Over ds the forcing adds g of s ds, which then evolves freely: at time t it is e to the A, t minus s, g of s ds. The solution sums all the kicks, and e to the A t is the Green's function.
Two masses: springs k equals 4, dashpots c equals 0.2, a force F cosine omega t on mass 1. Elimination gives z one equals F d over d squared minus k squared. At c zero the denominator vanishes at omega squared equals k and 3 k.
Sweeping omega gives two peaks at the normal modes, 2 in step and 3.4641 in antiphase: for mass 1, 1.261 and 0.731, with an anti-resonance dipping to 0.0346. At omega equals 3 the matrix solve gives 0.0757 and 0.2596; at omega equals 1, 0.2117 and 0.1209.
Halving c to 0.1 doubles the peaks, 2.505 and 1.448; c of 0.4 halves them, 0.646 and 0.378: a one over c law. Kicks in step with a mode reinforce: 1.25 and 0.7217, against exact 1.2608 and 0.7307. Eigenvalues: minus 0.1 plus or minus 1.9975 i, and 3.4627 i.
Duhamel is just quadrature. For the chain at omega 3, doubling N cuts the trapezoid error by about 4 and Simpson's by about 17. RK45 reaches 2.8 times 10 to the minus 3 by default, 4.1 times 10 to the minus 7 at tolerance 10 to the minus 6, 3.9 times 10 to the minus 11 tight.
For piecewise-constant forcing, x n plus 1 equals e to the A h x n plus A inverse, e to the A h minus I, g n, is exact. On a stiff test at h 0.1, Euler errs by 7 times 10 to the 37, RK4 by 2 times 10 to the 98, the exact step by 2 times 10 to the minus 16. From memory, gust response is Duhamel too.
The shape of every answer, and steady states
If xp is one solution, any other differs from it by a solution of x′=Ax (subtract and the forcing cancels), so
x=xh+xp=eAtc+xp.
For constant g try a constant xp=a: then 0=Aa+g, so xss=−A−1g whenever A is invertible (the scalar x′=−ax+g has g/a). Take A=(−211−2) (eigenvalues −1, −3) and g=(1,0): A−1=31(−2−1−1−2), so xss=(2/3,1/3).
Why it attracts. Put y=x−xss. Then y′=Ax+g=Ay, so y=eAty0: the forced system is the free one with its origin moved to xss. If every eigenvalue has negative real part, every solution falls into xss. From rest, x(t)=xss−eAtxss, and block A measures the distance ∥x−xss∥ from RK45: 0.26039 at t=1 and 0.03520 at t=3. Their ratio 0.1352 is close to e−2=0.1353, because the slowest eigenvalue, −1, sets the rate.
When A is singular. Take A=(−111−1), eigenvalues 0 and −2. Now Aa=−g is solvable only if g lies in the column space of A, the multiples of (1,−1) (1.3 Linear Systems, Kernel & Column Space). For g=(1,−1) there is a whole line of steady states (0.5,−0.5)+s(1,1), and from rest the solution lands on (0.5,−0.5) (block A). For g=(1,0) there is none, with a mechanism: the row (1,1) kills A (since (1,1)A=0), so s=x1+x2 obeys s′=g1+g2=1 and grows forever. Block A gives x(10)=(5.25,4.75), sum 10. A zero eigenvalue means a direction the dynamics never push back on, and forcing along it accumulates.
Sinusoidal forcing: the matrix transfer function
For g=gccosωt+gssinωt the guess is xp=acosωt+bsinωt, two unknown vectors and a 2n×2n solve after matching cos and sin. The complex trick packs it into n×n. Write g=Re[feiωt] with f=gc−igs and look for xp=Re[zeiωt]. Since A is real, the real part commutes with A, and the equation becomes iωz=Az+f:
z=(iωI−A)−1f,xp=Re[zeiωt]
The matrix H(iω)=(iωI−A)−1 is the matrix transfer function at s=iω. It is what the Laplace transform of x′=Ax+g with x0=0 gives: (sI−A)X=G, so X=H(s)G with H(s)=(sI−A)−1 (6.5 Convolution & Transfer Functions). Its denominator is det(sI−A), the characteristic polynomial, so the poles are the eigenvalues. The amplitude of component j is ∣zj∣ and its lag is −argzj: the gain and lag of the forced-oscillation lesson, one per component.
Read H(iω) as a machine. You feed it a vector of forcing amplitudes f and it returns a vector of complex response amplitudes: the modulus of each entry is how big that component swings, the argument is how far it trails the push. The same machine handles an exponential. For g=fert with r real, try xp=aert and get (rI−A)a=f, that is a=H(r)f: sinusoids are just the imaginary values r=iω. Example: A=(−101−3), g=(0,e−2t). Then rI−A=(−10−11) at r=−2, so a2=1, a1=−1 and xp=(−1,1)e−2t; substituting, both sides of the first equation are 2e−2t and of the second −2e−2t (hand computation; not produced by the lab).
Check against the scalar lesson.x′′+x′+25x=cosωt is A=(0−251−1), f=(0,1), so ω0=5, ζ=0.1. At ω=5 the first component is z1=1/(25−25+5i)=−0.2i: amplitude 0.2, lag π/2, and against the static value 1/25=0.04 a gain of 5=1/(2ζ) (block B).
Resonance. The solve fails exactly when iωI−A is singular, that is det(iωI−A)=0: iω is an eigenvalue. Then no bounded xp exists and the modification rule of the scalar lesson applies (a factor t, growth without bound in the undamped case). Damping moves the eigenvalues off the imaginary axis: here they are −0.5±4.975i (block B), the distance 0.5 from the axis is what keeps the gain finite, and H is largest where iω passes closest.
Integrate from 0 to t, multiply by eAt and use eAte−As=eA(t−s):
x(t)=eAtx0+∫0teA(t−s)g(s)ds
This is variation of parameters with fundamental matrix Φ=eAt: no Wronskian, since Φ−1(s)=e−As is free. The first term is the homogeneous solution carrying x0, the second the response to g from rest.
Superposition of kicks. Over [s,s+ds] the forcing adds g(s)ds to the state, a small kick; from then on the kick evolves freely, so at time t it has become eA(t−s)g(s)ds. The solution is the sum of all the kicks, each carried forward by the flow map. The matrix eAt is the Green’s function or impulse response: its column j is the response to a unit kick in component j (6.4 Impulses & the Dirac Delta), and the integral is a convolution of it with g, the time-domain face of H(s)G(s). Constant g gives ∫0teA(t−s)gds=A−1(eAt−I)g=xss−eAtxss, the formula already found, and the one-step update that 7.5 The Matrix Exponential & Fundamental Matrices used as the exponential Euler step.
Sinusoidal forcing, full solution. Duhamel and the complex trick agree: from rest, x(t)=Re[zeiωt]−eAtRez (the steady state plus a homogeneous part chosen to cancel it at t=0). Block D uses this as the exact answer.
Two masses, two resonances
Wall, spring k, mass m1, spring k, mass m2, spring k, wall, each mass with a dashpot c to the ground, m1=m2=1, k=4, and a force Fcosωt on mass 1:
With c=0 the two factors vanish at ω2=k and ω2=3k, the normal modes: ω1=2 with x2=x1 (masses in step) and ω2=23=3.4641 with x2=−x1 (in antiphase). With damping, near a mode one factor is about cω and the other is large, so the peak scales as 1/c. At ω=2: ∣d∣=4, and the denominator is 0.4×8.01, so both amplitudes are about 1.25. This chain keeps its modes uncoupled (the dashpot acts the same on both), so each mode rings down as e−ct/2; the eigenvalues of the 4×4 matrix are −0.1±1.9975i and −0.1±3.4627i (block B), the damped mode frequencies ωj2−c2/4, a little below 2 and 3.4641.
The same peak from Duhamel. A unit kick of velocity on mass 1 makes x1 ring as 21e−ct/2[sin(ω1t)/ω1+sin(ω2t)/ω2] (half the kick goes into each mode). Drive at ω=ω1: the kicks arriving at s are weighted by cosω1s, and the mode-1 ring they start is sinω1(t−s) with the same frequency, so their product contains a piece that does not oscillate in s, 21sin(ω1t)-type, and the kicks add in phase. Only the decay e−c(t−s)/2 limits the pile-up, to about 2/c time units, which gives an amplitude near 21⋅ω11⋅21⋅c2=1/(2ω1c), that is 1.25 at c=0.2, and 0.7217 for the second mode (block C prints both, against the exact 1.2608 and 0.7307). Mechanism of resonance in time-domain language: kicks that arrive in step with the ringing reinforce one another, and the 1/c comes from how long the ringing survives.
The numerator of z1 has its own zero at ω2=2k, ω=8=2.828: mass 1 nearly stands still while mass 2 swings and its spring cancels the force. This anti-resonance is between the peaks and is absent in z2. At c=0.2, block C and the sim give
x1
x2
first peak
1.261 at ω=1.990
1.248 at ω=2.000
second peak
0.731 at ω=3.469
0.724 at ω=3.452
dip
0.0346 at ω=2.825
0.2451 there
The static response at ω→0 is 2/(3k)=0.1667 for x1. Halving c to 0.1 doubles the heights (2.505 and 1.448 for x1), and c=0.4 halves them (0.646, 0.378): the 1/c law. The dip goes the other way, 0.0176, 0.0346, 0.0654 for c=0.1,0.2,0.4: damping fills it in.
◆ InteractiveDrive mass 1 of a two-mass chain: slide the frequency across the two resonance peaks and the anti-resonance, change the damping, and compare measured amplitude and phase with the complex-trick formula
Loading simulation…
What to try. (1) c=0.2, ω=3: the measured amplitudes (last drive cycle of an RK4 run from rest) are 0.0757 and 0.2596, matching ∣z1∣,∣z2∣ from the matrix solve, with phases −0.618 and 3.064 rad. (2) Sweep upward with the play box: the curves build and show two peaks, with x1 dipping at 2.825. (3) At ω=2 the two masses move together, at ω=3.464 in opposition (phases differ by 3.313 rad, near π; the readout wraps it to −2.970). (4) Set ω=1: ∣z1∣=0.2117, ∣z2∣=0.1209. (5) Damping 0.1 against 0.4 changes the peak heights and the dip depth as above.
Numerics: the integral, RK45 and the exact step
A time-stepper pays for the transient the complex trick skips: at c=0.2 the transient is e−0.1t, still 1% at t=ln100/0.1=46.05, so the amplitudes 0.0757 and 0.2596 above came from a run to t=100 (block B) while the matrix solve is one 4×4 system.
The Duhamel integral is an ordinary quadrature, with a matrix exponential at each node. For the chain at ω=3 from rest to T=10, block D compares hand-written rules with the exact value (0.03716,−0.06822,0.15367,−0.86827), the largest component error:
N
trapezoid
Simpson
40
1.47×10−2
2.75×10−3
80
3.58×10−3
1.34×10−4
160
8.90×10−4
7.90×10−6
Doubling N cuts the trapezoid error by about 4 (second order) and Simpson’s by about 17 (fourth order, 4.1 Local Error, Global Error & Order). solve_ivp RK45 with default tolerances (42 steps) is off by 2.8×10−3, with rtol=1e-6 (172 steps) by 4.1×10−7 and with rtol=1e-10 by 3.9×10−11 (4.4 Adaptive Step Size & RK45). A consistent one-step method also keeps the steady state: at xss every stage of Euler or RK4 sees Axss+g=0, so the numerical map fixes xss exactly, and what a step size can do is only to make that fixed point unstable. The integral costs N+1 exponentials and needs g only at the nodes; RK45 adapts its steps and needs no matrix exponential, but is limited by stability when A is stiff.
Exact steps for piecewise-constant forcing. If g is constant on [tn,tn+h], Duhamel gives xn+1=eAhxn+A−1(eAh−I)gn, exact for any h. Test: A=(−100030−2), g=u(t)(50,4) with u a square wave (+1 on [0,1), −1 on [1,2), and so on), x(0)=0, to T=4. The step is exact at h=1 (block E: (−0.95388,−1.52268), agreeing with RK45 at tolerance 10−12 to 1.9×10−13). Largest error at T=4, with h dividing the switch times:
h
explicit Euler
RK4
exact step
0.1
7×1037
2×1098
2×10−16
0.05
7×1047
4×1090
2×10−16
0.025
7×1027
4.6×10−8
2×10−16
0.0125
1.1×10−2
2.8×10−9
2×10−15
The stability limits are 0.02 for Euler and 0.027853 for RK4 (2.7853/100, 4.5 Stability Regions & Stiffness): the exact step is not governed by them, as long as g really is constant on each step. For a smooth g it is only first order in h.
Computing it
🐍 PythonLab: steady states, the complex trick, the chain's response curves, Duhamel quadrature against RK45, and the exact step (blocks A to E)
⌘/Ctrl + Enter
Now write the Simpson version of the integral and the RK45 reference yourself. Everything graded is real.
🧪 Coding exerciseExercise: Duhamel by Simpson's rule against RK45✓ passed
⌘/Ctrl + Enter
💡 Each node needs expm(A*(T - s)) applied to g(s). Weights: ones, then 4 at odd indices and 2 at even interior indices.
Concept checks
✅ Concept check
$A = \begin{pmatrix}-2&1\\1&-2\end{pmatrix}$, $\mathbf g = (0, 3)$ constant. What is the second component of the steady state $-A^{-1}\mathbf g$? (Give a number.)
A−1=21(−32−10), so xss=−A−1(0,6)=(3,0). From rest x=xss−eAtxss, and with eAt first row (2e−t−e−2t,e−t−e−2t), x1(t)=3−3(2e−t−e−2t). At t=3: 2e−3−e−6=0.09957−0.00248=0.09709, so x1(3)=3−0.29129=2.70871. (Hand computation, cross-checked with RK45 in a scratch run; not produced by the lab.)
✏️ Pen & paperThe complex trick by hand●●○
Find the steady response of x′=(−101−3)x+(0cost).
Show worked solution
Here ω=1 and f=(0,1). (iI−A)z=f reads (1+i)z1−z2=0 and (3+i)z2=1. So z2=(3−i)/10, and z1=z2/(1+i)=(3−i)(1−i)/20=(2−4i)/20=(1−2i)/10. The real parts give x1=(cost+2sint)/10 and x2=0.3cost+0.1sint. Check the first equation: x1′=(2cost−sint)/10=0.2cost−0.1sint and −x1+x2=0.2cost−0.1sint. The amplitude of x1 is 5/10=0.2236. (Hand computation; not produced by the lab.)
✏️ Pen & paperSingular $A$ and resonance●●●
(a) For A=(0010) and g=(0,1) find x(t) from rest with Duhamel’s formula, and say why there is no steady state. (b) For A=(0−410) and g=(0,cos2t), show that the complex trick fails and find x1(t) from rest.
Show worked solution
(a) eAτ=I+Aτ, so eA(t−s)g=(t−s,1) and the integral is (t2/2,t). A is singular and g is not in its column space (multiples of (1,0)), so Aa=−g has no solution: the second component drives the first without end. (b) det(2iI−A)=(2i)2+4=0, so 2i is an eigenvalue. The scalar equation is x′′+4x=cos2t with x1=x, and by the modification rule xp=4tsin2t (check: xp′′+4xp=cos2t). The homogeneous part is zero since xp(0)=xp′(0)=0, so x1=(t/4)sin2t, growing linearly. (Hand computation; not produced by the lab.)
✏️ Pen & paperPredicting peak heights●●○
For the chain with k=4 and c=0.05, estimate the heights of the two peaks of ∣z1∣ with 1/(2ωjc), then compare with the sim (damping slider at its minimum).
Show worked solution
ω1=2 gives 1/(2⋅2⋅0.05)=5.0000, and ω2=23 gives 1/(2⋅3.4641⋅0.05)=2.8868. The sim’s peak readout at c=0.05 shows 5.0022 at ω=1.999 and 2.8886 at ω=3.464, so the estimate is within 0.1% and 0.07%. It is better than at c=0.2 (1.25 against 1.2608, error 0.9%) because the other mode’s tail matters less as the peak sharpens.
Key Takeaways
x=xh+xp; for constant g and invertible A the steady state is −A−1g, and y=x−xss solves the free system, so it attracts when all eigenvalues have negative real part (0.2604→0.0352 between t=1 and 3).
A singular A has a direction nothing pushes back on: forcing along it accumulates (x1+x2 reached 10 at t=10), or gives a line of steady states if g is in the column space.
Sinusoidal forcing: xp=Re[(iωI−A)−1feiωt], the matrix transfer function H(s)=(sI−A)−1 at s=iω; it fails exactly when det(iωI−A)=0, resonance.
Duhamel: x(t)=eAtx0+∫0teA(t−s)g(s)ds, from dtd[e−Atx]=e−Atg; a sum of kicks, each carried by the flow map, i.e. a convolution with the Green’s function eAt.
The driven two-mass chain (k=4, c=0.2) has peaks near ω=2 and 23=3.464 (heights 1.261 and 0.731 for x1), an anti-resonance of mass 1 near 8, and peaks that scale like 1/c.
Quadrature of the Duhamel integral converges at the rule’s order: trapezoid error ×41 per doubling, Simpson ×171 here, against RK45’s tolerance-controlled error.
For piecewise-constant forcing xn+1=eAhxn+A−1(eAh−I)gn is exact at any h (10−16 at h=0.1 where Euler and RK4 reach 1037 and 1098). Next, the nonlinear case: 7.7 Nonlinear Systems & Linearization.
Finished this lesson?
Mark it complete to track your progress (saved in this browser). Reading every section does this for you.