Flow Lab

Syllabus / Module 7: Systems of ODEs & Dynamical Systems

Lesson 7.6

Nonhomogeneous Linear Systems

x' = Ax + g(t): undetermined coefficients, variation of parameters (Duhamel's formula), and forced systems.

Written byClaude Sonnet

🌊
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.
On this page
·
  1. The shape of every answer, and steady states
  2. Sinusoidal forcing: the matrix transfer function
  3. Duhamel’s formula
  4. Two masses, two resonances
  5. Numerics: the integral, RK45 and the exact step
  6. Computing it
  7. Concept checks
  8. Problems
  9. Key Takeaways

A linearised aircraft flies through a gust, a building sways in a crosswind, two connected masses are shaken at one end. Each is x′=Ax+g(t)\mathbf x' = A\mathbf x + \mathbf g(t): the free dynamics of 7.5 The Matrix Exponential & Fundamental Matrices plus a push from outside. The scalar versions are old friends: 5.4 Nonhomogeneous Equations: Undetermined Coefficients guessed the answer, 5.5 Variation of Parameters built it from a kernel, 5.6 Forced Oscillations & Resonance measured gain and lag. Here they become one set of matrix formulas, and eAte^{At} does the work.

▶ Video Particular plus homogeneous, the steady state, the complex trick, Duhamel as a stack of kicks, and two resonance peakscaptions only
Transcript
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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\mathbf x_p is one solution, any other differs from it by a solution of x′=Ax\mathbf x' = A\mathbf x (subtract and the forcing cancels), so

x=xh+xp=eAtc+xp.\mathbf x = \mathbf x_h + \mathbf x_p = e^{At}\mathbf c + \mathbf x_p .

For constant g\mathbf g try a constant xp=a\mathbf x_p = \mathbf a: then 0=Aa+g0 = A\mathbf a + \mathbf g, so xss=−A−1g\mathbf x_{ss} = -A^{-1}\mathbf g whenever AA is invertible (the scalar x′=−ax+gx' = -ax + g has g/ag/a). Take A=(−211−2)A = \begin{pmatrix}-2&1\\1&-2\end{pmatrix} (eigenvalues −1-1, −3-3) and g=(1,0)\mathbf g = (1, 0): A−1=13(−2−1−1−2)A^{-1} = \tfrac13\begin{pmatrix}-2&-1\\-1&-2\end{pmatrix}, so xss=(2/3,1/3)\mathbf x_{ss} = (2/3, 1/3).

Why it attracts. Put y=x−xss\mathbf y = \mathbf x - \mathbf x_{ss}. Then y′=Ax+g=Ay\mathbf y' = A\mathbf x + \mathbf g = A\mathbf y, so y=eAty0\mathbf y = e^{At}\mathbf y_0: the forced system is the free one with its origin moved to xss\mathbf x_{ss}. If every eigenvalue has negative real part, every solution falls into xss\mathbf x_{ss}. From rest, x(t)=xss−eAtxss\mathbf x(t) = \mathbf x_{ss} - e^{At}\mathbf x_{ss}, and block A measures the distance ∥x−xss∥\lVert\mathbf x - \mathbf x_{ss}\rVert from RK45: 0.260390.26039 at t=1t = 1 and 0.035200.03520 at t=3t = 3. Their ratio 0.13520.1352 is close to e−2=0.1353e^{-2} = 0.1353, because the slowest eigenvalue, −1-1, sets the rate.

When AA is singular. Take A=(−111−1)A = \begin{pmatrix}-1&1\\1&-1\end{pmatrix}, eigenvalues 00 and −2-2. Now Aa=−gA\mathbf a = -\mathbf g is solvable only if g\mathbf g lies in the column space of AA, the multiples of (1,−1)(1,-1) (1.3 Linear Systems, Kernel & Column Space). For g=(1,−1)\mathbf g = (1,-1) there is a whole line of steady states (0.5,−0.5)+s(1,1)(0.5, -0.5) + s(1,1), and from rest the solution lands on (0.5,−0.5)(0.5, -0.5) (block A). For g=(1,0)\mathbf g = (1, 0) there is none, with a mechanism: the row (1,1)(1,1) kills AA (since (1,1)A=0(1,1)A = 0), so s=x1+x2s = x_1 + x_2 obeys s′=g1+g2=1s' = g_1 + g_2 = 1 and grows forever. Block A gives x(10)=(5.25,4.75)\mathbf x(10) = (5.25, 4.75), sum 1010. 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\mathbf g = \mathbf g_c\cos\omega t + \mathbf g_s\sin\omega t the guess is xp=acos⁡ωt+bsin⁡ωt\mathbf x_p = \mathbf a\cos\omega t + \mathbf b\sin\omega t, two unknown vectors and a 2n×2n2n\times2n solve after matching cos and sin. The complex trick packs it into n×nn\times n. Write g=Re[feiωt]\mathbf g = \mathrm{Re}[\mathbf f e^{i\omega t}] with f=gc−igs\mathbf f = \mathbf g_c - i\mathbf g_s and look for xp=Re[zeiωt]\mathbf x_p = \mathrm{Re}[\mathbf z e^{i\omega t}]. Since AA is real, the real part commutes with AA, and the equation becomes iωz=Az+fi\omega\mathbf z = A\mathbf z + \mathbf f:

  z=(iωI−A)−1f,xp=Re[z eiωt]  \boxed{\;\mathbf z = (i\omega I - A)^{-1}\mathbf f,\qquad \mathbf x_p = \mathrm{Re}\big[\mathbf z\,e^{i\omega t}\big]\;}

The matrix H(iω)=(iωI−A)−1H(i\omega) = (i\omega I - A)^{-1} is the matrix transfer function at s=iωs = i\omega. It is what the Laplace transform of x′=Ax+g\mathbf x' = A\mathbf x + \mathbf g with x0=0\mathbf x_0 = 0 gives: (sI−A)X=G(sI - A)\mathbf X = \mathbf G, so X=H(s)G\mathbf X = H(s)\mathbf G with H(s)=(sI−A)−1H(s) = (sI - A)^{-1} (6.5 Convolution & Transfer Functions). Its denominator is det⁡(sI−A)\det(sI - A), the characteristic polynomial, so the poles are the eigenvalues. The amplitude of component jj is ∣zj∣\lvert z_j\rvert and its lag is −arg⁡zj-\arg z_j: the gain and lag of the forced-oscillation lesson, one per component.

Read H(iω)H(i\omega) as a machine. You feed it a vector of forcing amplitudes f\mathbf 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\mathbf g = \mathbf f e^{rt} with rr real, try xp=aert\mathbf x_p = \mathbf a e^{rt} and get (rI−A)a=f(rI - A)\mathbf a = \mathbf f, that is a=H(r)f\mathbf a = H(r)\mathbf f: sinusoids are just the imaginary values r=iωr = i\omega. Example: A=(−110−3)A = \begin{pmatrix}-1&1\\0&-3\end{pmatrix}, g=(0,e−2t)\mathbf g = (0, e^{-2t}). Then rI−A=(−1−101)rI - A = \begin{pmatrix}-1&-1\\0&1\end{pmatrix} at r=−2r = -2, so a2=1a_2 = 1, a1=−1a_1 = -1 and xp=(−1,1)e−2t\mathbf x_p = (-1, 1)e^{-2t}; substituting, both sides of the first equation are 2e−2t2e^{-2t} and of the second −2e−2t-2e^{-2t} (hand computation; not produced by the lab).

Check against the scalar lesson. x′′+x′+25x=cos⁡ωtx'' + x' + 25x = \cos\omega t is A=(01−25−1)A = \begin{pmatrix}0&1\\-25&-1\end{pmatrix}, f=(0,1)\mathbf f = (0, 1), so ω0=5\omega_0 = 5, ζ=0.1\zeta = 0.1. At ω=5\omega = 5 the first component is z1=1/(25−25+5i)=−0.2iz_1 = 1/(25 - 25 + 5i) = -0.2i: amplitude 0.20.2, lag π/2\pi/2, and against the static value 1/25=0.041/25 = 0.04 a gain of 5=1/(2ζ)5 = 1/(2\zeta) (block B).

Resonance. The solve fails exactly when iωI−Ai\omega I - A is singular, that is det⁡(iωI−A)=0\det(i\omega I - A) = 0: iωi\omega is an eigenvalue. Then no bounded xp\mathbf x_p exists and the modification rule of the scalar lesson applies (a factor tt, growth without bound in the undamped case). Damping moves the eigenvalues off the imaginary axis: here they are −0.5±4.975i-0.5 \pm 4.975i (block B), the distance 0.50.5 from the axis is what keeps the gain finite, and HH is largest where iωi\omega passes closest.

Duhamel’s formula

For arbitrary g(t)\mathbf g(t) use the integrating factor of 3.4 Linear First-Order Equations & Integrating Factors, with e−Ate^{-At} in its role. Because ddte−At=−Ae−At\frac{d}{dt}e^{-At} = -Ae^{-At} and AA commutes with e−Ate^{-At},

ddt[e−Atx]=e−At(x′−Ax)=e−Atg(t).\frac{d}{dt}\big[e^{-At}\mathbf x\big] = e^{-At}(\mathbf x' - A\mathbf x) = e^{-At}\mathbf g(t).

Integrate from 00 to tt, multiply by eAte^{At} and use eAte−As=eA(t−s)e^{At}e^{-As} = e^{A(t-s)}:

  x(t)=eAtx0+∫0teA(t−s) g(s) ds  \boxed{\;\mathbf x(t) = e^{At}\mathbf x_0 + \int_0^t e^{A(t-s)}\,\mathbf g(s)\,ds\;}

This is variation of parameters with fundamental matrix Φ=eAt\Phi = e^{At}: no Wronskian, since Φ−1(s)=e−As\Phi^{-1}(s) = e^{-As} is free. The first term is the homogeneous solution carrying x0\mathbf x_0, the second the response to g\mathbf g from rest.

Superposition of kicks. Over [s,s+ds][s, s + ds] the forcing adds g(s) ds\mathbf g(s)\,ds to the state, a small kick; from then on the kick evolves freely, so at time tt it has become eA(t−s)g(s) dse^{A(t-s)}\mathbf g(s)\,ds. The solution is the sum of all the kicks, each carried forward by the flow map. The matrix eAte^{At} is the Green’s function or impulse response: its column jj is the response to a unit kick in component jj (6.4 Impulses & the Dirac Delta), and the integral is a convolution of it with g\mathbf g, the time-domain face of H(s)G(s)H(s)\mathbf G(s). Constant g\mathbf g gives ∫0teA(t−s)g ds=A−1(eAt−I)g=xss−eAtxss\int_0^te^{A(t-s)}\mathbf g\,ds = A^{-1}(e^{At} - I)\mathbf g = \mathbf x_{ss} - e^{At}\mathbf x_{ss}, 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]−eAtRe z\mathbf x(t) = \mathrm{Re}[\mathbf z e^{i\omega t}] - e^{At}\mathrm{Re}\,\mathbf z (the steady state plus a homogeneous part chosen to cancel it at t=0t = 0). Block D uses this as the exact answer.

Two masses, two resonances

Wall, spring kk, mass m1m_1, spring kk, mass m2m_2, spring kk, wall, each mass with a dashpot cc to the ground, m1=m2=1m_1 = m_2 = 1, k=4k = 4, and a force Fcos⁡ωtF\cos\omega t on mass 1:

x1′′=−2kx1+kx2−cx1′+Fcos⁡ωt,x2′′=kx1−2kx2−cx2′.x_1'' = -2kx_1 + kx_2 - cx_1' + F\cos\omega t,\qquad x_2'' = kx_1 - 2kx_2 - cx_2'.

As a first-order system x=(x1,x2,x1′,x2′)\mathbf x = (x_1, x_2, x_1', x_2') is 44-dimensional and g=(0,0,Fcos⁡ωt,0)\mathbf g = (0, 0, F\cos\omega t, 0). Solving (iωI−A)z=f(i\omega I - A)\mathbf z = \mathbf f by elimination, with d=2k−ω2+icωd = 2k - \omega^2 + ic\omega, gives

z1=F dd2−k2,z2=F kd2−k2,d2−k2=(k−ω2+icω)(3k−ω2+icω).z_1 = \frac{F\,d}{d^2 - k^2},\qquad z_2 = \frac{F\,k}{d^2 - k^2},\qquad d^2 - k^2 = (k - \omega^2 + ic\omega)(3k - \omega^2 + ic\omega).

With c=0c = 0 the two factors vanish at ω2=k\omega^2 = k and ω2=3k\omega^2 = 3k, the normal modes: ω1=2\omega_1 = 2 with x2=x1x_2 = x_1 (masses in step) and ω2=23=3.4641\omega_2 = 2\sqrt3 = 3.4641 with x2=−x1x_2 = -x_1 (in antiphase). With damping, near a mode one factor is about cωc\omega and the other is large, so the peak scales as 1/c1/c. At ω=2\omega = 2: ∣d∣=4\lvert d\rvert = 4, and the denominator is 0.4×8.010.4\times8.01, so both amplitudes are about 1.251.25. This chain keeps its modes uncoupled (the dashpot acts the same on both), so each mode rings down as e−ct/2e^{-ct/2}; the eigenvalues of the 4×44\times4 matrix are −0.1±1.9975i-0.1 \pm 1.9975i and −0.1±3.4627i-0.1 \pm 3.4627i (block B), the damped mode frequencies ωj2−c2/4\sqrt{\omega_j^2 - c^2/4}, a little below 22 and 3.46413.4641.

The same peak from Duhamel. A unit kick of velocity on mass 1 makes x1x_1 ring as 12e−ct/2[sin⁡(ω1t)/ω1+sin⁡(ω2t)/ω2]\tfrac12 e^{-ct/2}\big[\sin(\omega_1t)/\omega_1 + \sin(\omega_2t)/\omega_2\big] (half the kick goes into each mode). Drive at ω=ω1\omega = \omega_1: the kicks arriving at ss are weighted by cos⁡ω1s\cos\omega_1s, and the mode-1 ring they start is sin⁡ω1(t−s)\sin\omega_1(t-s) with the same frequency, so their product contains a piece that does not oscillate in ss, 12sin⁡(ω1t)\tfrac12\sin(\omega_1t)-type, and the kicks add in phase. Only the decay e−c(t−s)/2e^{-c(t-s)/2} limits the pile-up, to about 2/c2/c time units, which gives an amplitude near 12⋅1ω1⋅12⋅2c=1/(2ω1c)\tfrac12\cdot\tfrac1{\omega_1}\cdot\tfrac12\cdot\tfrac2c = 1/(2\omega_1c), that is 1.251.25 at c=0.2c = 0.2, and 0.72170.7217 for the second mode (block C prints both, against the exact 1.26081.2608 and 0.73070.7307). Mechanism of resonance in time-domain language: kicks that arrive in step with the ringing reinforce one another, and the 1/c1/c comes from how long the ringing survives.

The numerator of z1z_1 has its own zero at ω2=2k\omega^2 = 2k, ω=8=2.828\omega = \sqrt8 = 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 z2z_2. At c=0.2c = 0.2, block C and the sim give

x1x_1x2x_2
first peak1.2611.261 at ω=1.990\omega = 1.9901.2481.248 at ω=2.000\omega = 2.000
second peak0.7310.731 at ω=3.469\omega = 3.4690.7240.724 at ω=3.452\omega = 3.452
dip0.03460.0346 at ω=2.825\omega = 2.8250.24510.2451 there

The static response at ω→0\omega \to 0 is 2/(3k)=0.16672/(3k) = 0.1667 for x1x_1. Halving cc to 0.10.1 doubles the heights (2.5052.505 and 1.4481.448 for x1x_1), and c=0.4c = 0.4 halves them (0.6460.646, 0.3780.378): the 1/c1/c law. The dip goes the other way, 0.01760.0176, 0.03460.0346, 0.06540.0654 for c=0.1,0.2,0.4c = 0.1, 0.2, 0.4: damping fills it in.

◆ Interactive Drive 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.2c = 0.2, ω=3\omega = 3: the measured amplitudes (last drive cycle of an RK4 run from rest) are 0.07570.0757 and 0.25960.2596, matching ∣z1∣,∣z2∣\lvert z_1\rvert, \lvert z_2\rvert from the matrix solve, with phases −0.618-0.618 and 3.0643.064 rad. (2) Sweep upward with the play box: the curves build and show two peaks, with x1x_1 dipping at 2.8252.825. (3) At ω=2\omega = 2 the two masses move together, at ω=3.464\omega = 3.464 in opposition (phases differ by 3.3133.313 rad, near π\pi; the readout wraps it to −2.970-2.970). (4) Set ω=1\omega = 1: ∣z1∣=0.2117\lvert z_1\rvert = 0.2117, ∣z2∣=0.1209\lvert z_2\rvert = 0.1209. (5) Damping 0.10.1 against 0.40.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.2c = 0.2 the transient is e−0.1te^{-0.1t}, still 1%1\% at t=ln⁡100/0.1=46.05t = \ln100/0.1 = 46.05, so the amplitudes 0.07570.0757 and 0.25960.2596 above came from a run to t=100t = 100 (block B) while the matrix solve is one 4×44\times4 system.

The Duhamel integral is an ordinary quadrature, with a matrix exponential at each node. For the chain at ω=3\omega = 3 from rest to T=10T = 10, block D compares hand-written rules with the exact value (0.03716,−0.06822,0.15367,−0.86827)(0.03716, -0.06822, 0.15367, -0.86827), the largest component error:

NNtrapezoidSimpson
40401.47×10−21.47\times10^{-2}2.75×10−32.75\times10^{-3}
80803.58×10−33.58\times10^{-3}1.34×10−41.34\times10^{-4}
1601608.90×10−48.90\times10^{-4}7.90×10−67.90\times10^{-6}

Doubling NN cuts the trapezoid error by about 44 (second order) and Simpson’s by about 1717 (fourth order, 4.1 Local Error, Global Error & Order). solve_ivp RK45 with default tolerances (4242 steps) is off by 2.8×10−32.8\times10^{-3}, with rtol=1e-6 (172172 steps) by 4.1×10−74.1\times10^{-7} and with rtol=1e-10 by 3.9×10−113.9\times10^{-11} (4.4 Adaptive Step Size & RK45). A consistent one-step method also keeps the steady state: at xss\mathbf x_{ss} every stage of Euler or RK4 sees Axss+g=0A\mathbf x_{ss} + \mathbf g = 0, so the numerical map fixes xss\mathbf x_{ss} exactly, and what a step size can do is only to make that fixed point unstable. The integral costs N+1N + 1 exponentials and needs g\mathbf g only at the nodes; RK45 adapts its steps and needs no matrix exponential, but is limited by stability when AA is stiff.

Exact steps for piecewise-constant forcing. If g\mathbf g is constant on [tn,tn+h][t_n, t_n + h], Duhamel gives xn+1=eAhxn+A−1(eAh−I)gn\mathbf x_{n+1} = e^{Ah}\mathbf x_n + A^{-1}(e^{Ah} - I)\mathbf g_n, exact for any hh. Test: A=(−100300−2)A = \begin{pmatrix}-100&30\\0&-2\end{pmatrix}, g=u(t)(50,4)\mathbf g = u(t)(50, 4) with uu a square wave (+1+1 on [0,1)[0,1), −1-1 on [1,2)[1,2), and so on), x(0)=0\mathbf x(0) = 0, to T=4T = 4. The step is exact at h=1h = 1 (block E: (−0.95388,−1.52268)(-0.95388, -1.52268), agreeing with RK45 at tolerance 10−1210^{-12} to 1.9×10−131.9\times10^{-13}). Largest error at T=4T = 4, with hh dividing the switch times:

hhexplicit EulerRK4exact step
0.10.17×10377\times10^{37}2×10982\times10^{98}2×10−162\times10^{-16}
0.050.057×10477\times10^{47}4×10904\times10^{90}2×10−162\times10^{-16}
0.0250.0257×10277\times10^{27}4.6×10−84.6\times10^{-8}2×10−162\times10^{-16}
0.01250.01251.1×10−21.1\times10^{-2}2.8×10−92.8\times10^{-9}2×10−152\times10^{-15}

The stability limits are 0.020.02 for Euler and 0.0278530.027853 for RK4 (2.7853/1002.7853/100, 4.5 Stability Regions & Stiffness): the exact step is not governed by them, as long as g\mathbf g really is constant on each step. For a smooth g\mathbf g it is only first order in hh.

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
⌘/Ctrl + Enter

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.)

✅ Concept check

When does the complex-trick formula $\mathbf z = (i\omega I - A)^{-1}\mathbf f$ break down?

✅ Concept check

For $x' = -2x + 1$ with $x(0) = 0$, Duhamel's formula gives $x(1) = \int_0^1 e^{-2(1-s)}\,ds$. What is its value? (Give a number.)

Problems

✏️ Pen & paperSteady state and approach●●○

For x′=(01−2−3)x+(06)\mathbf x' = \begin{pmatrix}0&1\\-2&-3\end{pmatrix}\mathbf x + \begin{pmatrix}0\\6\end{pmatrix}, x(0)=0\mathbf x(0) = 0: find the steady state and x1(3)x_1(3), using eAte^{At} from 7.5 The Matrix Exponential & Fundamental Matrices.

Show worked solution

A−1=12(−3−120)A^{-1} = \tfrac12\begin{pmatrix}-3&-1\\2&0\end{pmatrix}, so xss=−A−1(0,6)=(3,0)\mathbf x_{ss} = -A^{-1}(0,6) = (3, 0). From rest x=xss−eAtxss\mathbf x = \mathbf x_{ss} - e^{At}\mathbf x_{ss}, and with eAte^{At} first row (2e−t−e−2t, e−t−e−2t)(2e^{-t} - e^{-2t},\ e^{-t} - e^{-2t}), x1(t)=3−3(2e−t−e−2t)x_1(t) = 3 - 3(2e^{-t} - e^{-2t}). At t=3t = 3: 2e−3−e−6=0.09957−0.00248=0.097092e^{-3} - e^{-6} = 0.09957 - 0.00248 = 0.09709, so x1(3)=3−0.29129=2.70871x_1(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′=(−110−3)x+(0cos⁡t)\mathbf x' = \begin{pmatrix}-1&1\\0&-3\end{pmatrix}\mathbf x + \begin{pmatrix}0\\\cos t\end{pmatrix}.

Show worked solution

Here ω=1\omega = 1 and f=(0,1)\mathbf f = (0, 1). (iI−A)z=f(iI - A)\mathbf z = \mathbf f reads (1+i)z1−z2=0(1 + i)z_1 - z_2 = 0 and (3+i)z2=1(3 + i)z_2 = 1. So z2=(3−i)/10z_2 = (3 - i)/10, and z1=z2/(1+i)=(3−i)(1−i)/20=(2−4i)/20=(1−2i)/10z_1 = z_2/(1 + i) = (3 - i)(1 - i)/20 = (2 - 4i)/20 = (1 - 2i)/10. The real parts give x1=(cos⁡t+2sin⁡t)/10x_1 = (\cos t + 2\sin t)/10 and x2=0.3cos⁡t+0.1sin⁡tx_2 = 0.3\cos t + 0.1\sin t. Check the first equation: x1′=(2cos⁡t−sin⁡t)/10=0.2cos⁡t−0.1sin⁡tx_1' = (2\cos t - \sin t)/10 = 0.2\cos t - 0.1\sin t and −x1+x2=0.2cos⁡t−0.1sin⁡t-x_1 + x_2 = 0.2\cos t - 0.1\sin t. The amplitude of x1x_1 is 5/10=0.2236\sqrt5/10 = 0.2236. (Hand computation; not produced by the lab.)

✏️ Pen & paperSingular $A$ and resonance●●●

(a) For A=(0100)A = \begin{pmatrix}0&1\\0&0\end{pmatrix} and g=(0,1)\mathbf g = (0, 1) find x(t)\mathbf x(t) from rest with Duhamel’s formula, and say why there is no steady state. (b) For A=(01−40)A = \begin{pmatrix}0&1\\-4&0\end{pmatrix} and g=(0,cos⁡2t)\mathbf g = (0, \cos2t), show that the complex trick fails and find x1(t)x_1(t) from rest.

Show worked solution

(a) eAτ=I+Aτe^{A\tau} = I + A\tau, so eA(t−s)g=(t−s,1)e^{A(t-s)}\mathbf g = (t - s, 1) and the integral is (t2/2,t)(t^2/2, t). AA is singular and g\mathbf g is not in its column space (multiples of (1,0)(1,0)), so Aa=−gA\mathbf a = -\mathbf g has no solution: the second component drives the first without end. (b) det⁡(2iI−A)=(2i)2+4=0\det(2iI - A) = (2i)^2 + 4 = 0, so 2i2i is an eigenvalue. The scalar equation is x′′+4x=cos⁡2tx'' + 4x = \cos2t with x1=xx_1 = x, and by the modification rule xp=t4sin⁡2tx_p = \tfrac t4\sin2t (check: xp′′+4xp=cos⁡2tx_p'' + 4x_p = \cos2t). The homogeneous part is zero since xp(0)=xp′(0)=0x_p(0) = x_p'(0) = 0, so x1=(t/4)sin⁡2tx_1 = (t/4)\sin2t, growing linearly. (Hand computation; not produced by the lab.)

✏️ Pen & paperPredicting peak heights●●○

For the chain with k=4k = 4 and c=0.05c = 0.05, estimate the heights of the two peaks of ∣z1∣\lvert z_1\rvert with 1/(2ωjc)1/(2\omega_jc), then compare with the sim (damping slider at its minimum).

Show worked solution

ω1=2\omega_1 = 2 gives 1/(2⋅2⋅0.05)=5.00001/(2\cdot2\cdot0.05) = 5.0000, and ω2=23\omega_2 = 2\sqrt3 gives 1/(2⋅3.4641⋅0.05)=2.88681/(2\cdot3.4641\cdot0.05) = 2.8868. The sim’s peak readout at c=0.05c = 0.05 shows 5.00225.0022 at ω=1.999\omega = 1.999 and 2.88862.8886 at ω=3.464\omega = 3.464, so the estimate is within 0.1%0.1\% and 0.07%0.07\%. It is better than at c=0.2c = 0.2 (1.251.25 against 1.26081.2608, error 0.9%0.9\%) because the other mode’s tail matters less as the peak sharpens.

Key Takeaways

  • x=xh+xp\mathbf x = \mathbf x_h + \mathbf x_p; for constant g\mathbf g and invertible AA the steady state is −A−1g-A^{-1}\mathbf g, and y=x−xss\mathbf y = \mathbf x - \mathbf x_{ss} solves the free system, so it attracts when all eigenvalues have negative real part (0.2604→0.03520.2604 \to 0.0352 between t=1t = 1 and 33).
  • A singular AA has a direction nothing pushes back on: forcing along it accumulates (x1+x2x_1 + x_2 reached 1010 at t=10t = 10), or gives a line of steady states if g\mathbf g is in the column space.
  • Sinusoidal forcing: xp=Re[(iωI−A)−1feiωt]\mathbf x_p = \mathrm{Re}[(i\omega I - A)^{-1}\mathbf f e^{i\omega t}], the matrix transfer function H(s)=(sI−A)−1H(s) = (sI - A)^{-1} at s=iωs = i\omega; it fails exactly when det⁡(iωI−A)=0\det(i\omega I - A) = 0, resonance.
  • Duhamel: x(t)=eAtx0+∫0teA(t−s)g(s) ds\mathbf x(t) = e^{At}\mathbf x_0 + \int_0^te^{A(t-s)}\mathbf g(s)\,ds, from ddt[e−Atx]=e−Atg\frac{d}{dt}[e^{-At}\mathbf x] = e^{-At}\mathbf g; a sum of kicks, each carried by the flow map, i.e. a convolution with the Green’s function eAte^{At}.
  • The driven two-mass chain (k=4k = 4, c=0.2c = 0.2) has peaks near ω=2\omega = 2 and 23=3.4642\sqrt3 = 3.464 (heights 1.2611.261 and 0.7310.731 for x1x_1), an anti-resonance of mass 1 near 8\sqrt8, and peaks that scale like 1/c1/c.
  • Quadrature of the Duhamel integral converges at the rule’s order: trapezoid error ×14\times\tfrac14 per doubling, Simpson ×117\times\tfrac1{17} here, against RK45’s tolerance-controlled error.
  • For piecewise-constant forcing xn+1=eAhxn+A−1(eAh−I)gn\mathbf x_{n+1} = e^{Ah}\mathbf x_n + A^{-1}(e^{Ah} - I)\mathbf g_n is exact at any hh (10−1610^{-16} at h=0.1h = 0.1 where Euler and RK4 reach 103710^{37} and 109810^{98}). 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.