Why this matters for simulation: Periodic forcing (gusts, vortex shedding) on a structure is handled exactly this way.
By the end of this lesson you can…
Explain why every solution of $L[y] = g$ is one particular solution plus a homogeneous solution, and fit initial conditions after $y_p$ is added.
Explain why a guess works when the forcing's family is closed under differentiation, by writing $L$ there as a small matrix.
Solve for polynomial, exponential, sinusoidal and product forcing, splitting sums of forcings.
Derive the modification rule (multiply by $t^m$) from $L[te^{st}] = (P(s)t + P'(s))e^{st}$.
Use $G = 1/P(i\omega)$ to get the amplitude and phase of the response to $\cos\omega t$, and recognise forcing such as $\tan t$ that no finite guess matches.
Until now nothing pushed on the system; the spring of 5.3 Mechanical Vibrations: Spring–Mass–Damper rang down by itself. A wing in a gust, a bridge deck in shedding vortices and a motor bolted to a frame are pushed by something independent of their state, so the model becomes ay′′+by′+cy=g(t). 5.1 Second-Order Linear Equations: Structure gave the structure of the unforced family and 5.2 Constant Coefficients & the Characteristic Equation found it. This lesson finds the one extra function the forcing adds, by a method that looks like guessing and is really a small linear solve. Arbitrary forcing and the resonance curve come next.
▶ VideoParticular plus homogeneous, why the guess family closes under differentiation, the guess table, the modification rule, complex exponentials, and applying initial conditions lastcaptions only
Transcript
Forcing adds one extra function. If y p is any one solution of L of y equals g, then y minus y p solves the homogeneous equation. So every solution is y h plus y p: the homogeneous plane, shifted off the origin by y p. Any one will do.
Why can a guess work? Differentiation never leaves the polynomials of degree two, so L is a small matrix there. For this equation it is triangular, with determinant two hundred sixteen, and solving it gives the coefficients two, minus three, two.
Cosine and sine work the same way: differentiation rotates one into the other, so L is a two by two matrix. Its determinant, twenty, is the area the unit square stretches to. An exponential gives a one by one matrix, P of s: invertible unless the exponent is a root.
A product with an exponential only shifts the constants, so t to the n times e to the s t takes a polynomial of the same degree. That builds this table; sums are solved piece by piece. Example: A is point one and B is minus point zero six.
Complex exponentials shortcut this: L of e to the i omega t is P of i omega times itself. So the response to a cosine is the real part of G e to the i omega t, with G one over P of i omega. Here P of two i is minus two plus four i.
Now push an undamped spring of natural frequency three. The gain, one over the size of nine minus omega squared, is point two at omega two, and about sixteen point seven at two point nine nine. It blows up as P of i omega nears zero.
Now the trap. For y double prime minus four y equals e to the two t, P of two is zero, so e to the two t already solves the homogeneous equation. The residual is minus e to the two t whatever A is: the guess cannot reach the forcing.
Leave the family: differentiate t e to the s t. The result is P of s times t, plus P prime of s. The first term, with no derivative on t, vanishes at a root; the second survives. Here P prime of two is four, giving a quarter t e to the two t. The rule: multiply by t to the multiplicity.
The rule at work. For y double prime plus three y prime equals six t, constants are in the kernel, so the guess is t times a line. For a cosine at the natural frequency, the answer is t over six times sine three t: an amplitude that grows forever, the limit of the gain.
Initial conditions come last. Here y of zero is three and y prime of zero is minus one. The particular solution already starts at two and minus three, so the homogeneous part must start at one and two. Fitting it alone lands the total at five and minus four.
RK45 is the referee. At t equal one it gives one point four seven eight; the right answer agrees, the wrong one says one point eight three four. The wrong answer is off by as much as two. What remains, y minus y p, fades: the transient.
Where does it stop? Each derivative of tan t raises the power of tan by one, so no finite family contains them all. Even one over t fails: each fix creates a new error, with coefficients one, minus two, twenty-four, and on. The terms shrink, then grow.
To recap: every solution is y h plus y p. A guess works because L is a small matrix on a family that differentiation never leaves; at a root, multiply by t to the multiplicity. Fit initial data last. Next: arbitrary forcing.
The shape of every answer
Write L[y]=ay′′+by′+cy and P(r)=ar2+br+c. If yp is any one solution of L[y]=g and y is another, linearity gives L[y−yp]=g−g=0, so y−yp is in the kernel, the family yh=c1y1+c2y2 of the last lesson. Therefore
y=yh+yp
the shape of the solutions of Ax=b in 1.3 Linear Systems, Kernel & Column Space: one particular solution plus the kernel. Geometrically the solutions form the plane (c1,c2), shifted off the origin by yp; it is not a vector space, since 0 is not a solution when g=0. Two choices of yp differ by a kernel element, so any one will do.
Why a guess can work
L is built from differentiation and constants. If g lives in a finite-dimensional space V of functions that differentiation never leaves, then L maps V into itself and is a small matrix there. Solving L[y]=g in V is then a linear system whose unknowns, the coordinates of y, are the “undetermined coefficients”. Three families:
Polynomials of degree at most 2, V=span{1,t,t2}. Here L[1]=c, L[t]=b+ct and L[t2]=2a+2bt+ct2, so the matrix, with these as columns, is
M=c00bc02a2bc,detM=c3.
Triangular, since differentiation only lowers the degree: solve from the top coefficient down.
One exponential, V=span{est} with s real or complex. L[est]=P(s)est, a 1×1 matrix.
Cosine and sine, V=span{cosωt,sinωt}. Differentiation rotates one into the other, and L[Acosωt+Bsinωt] has coordinates
Sines appear even for a pure cosine forcing because the damping term by′ turns cosines into sines; guessing Acosωt alone leaves a stray sin.
All three are invertible exactly when the forcing’s exponent (0, s or iω) is not a root of P, and then there is exactly one yp in V. Block A of the lab prints the matrices, with determinants 216=63 and 20=∣P(2i)∣2 for the examples below.
Products. Since (uest)′=(u′+su)est and (uest)′′=(u′′+2su′+s2u)est,
L[uest]=est(au′′+(2as+b)u′+P(s)u).
The exponential factors out and u sees the polynomial case with shifted constants and P(s) on the diagonal. So tnest calls for a degree-n polynomial times est, and s=σ+iω covers eσtcosωt=Reest. Block B checks the identity symbolically.
forcing g(t)
guess yp (exponent not a root of P)
antn+⋯+a0
Antn+⋯+A0, every power
Cest
Aest
cosωt, sinωt or a mix
Acosωt+Bsinωt
tnest
(Antn+⋯+A0)est
tneσtcosωt
eσt[(Antn+…)cosωt+(Bntn+…)sinωt]
g1+g2
yp1+yp2, each solved on its own
The last row is superposition: L[y1+y2]=g1+g2 when L[yi]=gi.
Worked examples
1. A polynomial.y′′+5y′+6y=12t2+2t+1. Here P=(r+2)(r+3), and P(0)=6=0, so guess At2+Bt+C:
L[yp]=6At2+(10A+6B)t+(2A+5B+6C).
From the top: 6A=12 gives A=2; 10A+6B=2 gives B=−3; 2A+5B+6C=1 gives C=2. So yp=2t2−3t+2. Block A solves the same system as Mx=g and gets (C,B,A)=(2,−3,2); block C checks with sympy that L[yp]−g=0. The guess needs every power: At2 alone gives 6At2+10At+2A, with a t and a constant that nothing can cancel.
2. A sum.y′′+2y′+2y=5cos2t+10et, with P having roots −1±i, so neither 1 nor 2i is a root. For 10et: P(1)=5, so yp2=2et. For 5cos2t guess Acos2t+Bsin2t:
L[yp]=(−2A+4B)cos2t+(−4A−2B)sin2t=5cos2t,
so B=−2A and −10A=5: A=−21, B=1. Together, yp=sin2t−21cos2t+2et.
3. A product.y′′+2y′+2y=te2t. With s=2: 2as+b=6 and P(2)=10, so u=At+B satisfies u′′+6u′+10u=t, i.e. 10At+6A+10B=t. Thus A=0.1 and B=−0.06: yp=(0.1t−0.06)e2t.
The complex-exponential shortcut
Since (eiωt)′=iωeiωt, we have L[eiωt]=P(iω)eiωt. If P(iω)=0, then w=eiωt/P(iω) solves L[w]=eiωt. Because a,b,c are real, ReL[w]=L[Rew], and Reeiωt=cosωt. So for g=Fcosωt, yp=FRe[Geiωt] with G=1/P(iω). Writing P(iω)=∣P∣eiφ,
yp=∣P(iω)∣Fcos(ωt−φ),∣P(iω)∣=(c−aω2)2+(bω)2
The response has the same frequency, gain ∣G∣ and phase lag φ; G is the transfer function, and ∣G(iω)∣ plotted against ω is the resonance curve of the forced-oscillations lesson. For Fsinωt take the imaginary part. For example 2, block D prints P(2i)=−2+4i, ∣P∣2=20, G=−0.1−0.2i, ∣G∣=0.2236068 and φ=2.034444 rad. The amplitude 5∣G∣=1.118034 equals 1+1/4, the amplitude of the real answer sin2t−21cos2t, and the cosine and sine coefficients of 5Re[Ge2it] are −0.5 and 1.0. The denominator is the determinant of the cosine-sine matrix, so the gain is large exactly when that matrix is nearly singular.
When the guess is already a solution
Take y′′−4y=e2t. Now P(2)=0, so e2t solves the homogeneous equation and L[Ae2t]=0 for everyA: the residual is −e2t whatever you choose. The 1×1 matrix is 0, and e2t is not in its range. We must leave the family. Compute (test)′=(1+st)est and (test)′′=(2s+s2t)est:
P(s)t collects the terms where no derivative lands on the factor t, and vanishes when P(s)=0; P′(s) collects the terms where one derivative turns t into 1. For a simple root, L[test]=P′(s)est, so g=Cest has yp=P′(s)Ctest. For y′′−4y=e2t, P′(2)=4 and yp=41te2t. For a double root, L[t2est]=(Pt2+2P′t+2a)est, leaving yp=2aCt2est: for y′′+6y′+9y=4e−3t, yp=2t2e−3t. Block B checks both identities for general a,b,c.
The rule: if the exponent is a root of P of multiplicity m, multiply the guess by tm.
Polynomial.y′′+3y′=6t has c=0, so s=0 is a root and the degree-2 matrix has zero diagonal and rank 2 (block A): L sends 1,t,t2 to 0,3,2+6t. Guess t(At+B): L=6At+(2A+3B), so A=1, B=−32 and yp=t2−32t. A constant in the guess would just be a free parameter, since constants are in the kernel.
Sinusoid, by complex exponentials.y′′+9y=cos3t has P(3i)=0, P′(3i)=6i:
yp=Re6ite3it=6tRe[−i(cos3t+isin3t)]=6tsin3t.
The amplitude t/6 grows without bound. It is the limit of the non-resonant gain 1/∣9−ω2∣, which is 0.2 at ω=2, 1.694915 at 2.9 and 16.694491 at 2.99 (block D).
Damped sinusoid. For y′′+2y′+2y=e−tcost, the exponent s=−1+i is a root, P′(s)=2i and yp=Re2itest=21te−tsint. Everything decays, but the extra t remains.
Initial conditions come last
The classic mistake is fitting c1,c2 to y(0),y′(0) with yh alone, then adding yp. The conditions constrain the sum, and yp has its own starting values that yh must make up for: find yp, write yh+yp, then impose the data on that.
Take example 1 with y(0)=3, y′(0)=−1; yp(0)=2 and yp′(0)=−3.
Wrong. Fit yh to (3,−1): c1+c2=3 and −2c1−3c2=−1 give c1=8, c2=−5, so 8e−2t−5e−3t+2t2−3t+2. But y(0)=5 and y′(0)=−4.
Right.yh must start from (3−2,−1+3)=(1,2): c1+c2=1 and −2c1−3c2=2 give c2=−4, c1=5:
y=5e−2t−4e−3t+2t2−3t+2,y(0)=3,y′(0)=−1.
Block E judges with RK45: y(1)=1.477528 numerically, 1.477528 for the right answer and 1.833747 for the wrong one. On [0,6] the right answer is within 1.80×10−10 of RK45 and the wrong one is off by up to 2.0000.
The gap y−yp equals yh: 1.0 at t=0, 0.477528 at t=1 and 3.066×10−5 at t=6. That is why yh is called the transient, but only if it decays: with b=0 it rings forever, and with c=0 it contains a constant.
Play with it
◆ InteractivePick a forcing, change b, c and the initial data: watch y_h fade so the total y lands on y_p, and read the guess and its solved coefficients
Loading simulation…
The default is y′′+2y′+2y=5cos2t with y(0)=1, y′(0)=0; the readout prints A=−0.5, B=1, the gain G, and the start values y(0)−yp(0) and y′(0)−yp′(0) for yh. Tick “WRONG answer” to draw the curve from fitting yh alone. The bottom-right plot is log10∣y−yp∣, a straight line down for a clean decay. The four RESONANCE presets explain why the plain guess is singular and multiply it by t. Every setting prints two self-checks: the largest residual ∣yp′′+byp′+cyp−g∣ and the gap to an RK4 integration of the ODE.
Where the method stops
Everything rested on the forcing living in a finite-dimensional family closed under differentiation: sums of terms tkest (a standard fact, from memory), such as polynomials, exponentials, sines, cosines and their finite products. cosh3t and cos2t qualify after rewriting.
tant does not. Its derivatives are 1+tan2t, then 2tant+2tan3t, each raising the power of tant by one (block F prints the degrees 1,2,3,4,5), so the family never closes. A concrete failure: y′′+y=1/t. Since L[t−m]=m(m+1)t−m−2+t−m, A0t−1 with A0=1 matches 1/t but leaves 2t−3; A1=−2 cancels it but leaves −24t−5; A2=24 and so on. The coefficients are (−1)k(2k)!: 1,−2,24,−720,40320,−3628800. The term sizes ∣Ak∣/t2k+1 at t=5 are 0.2, 0.016, 0.00768, 0.009216, 0.020644, 0.074318: they shrink, then grow, so the series diverges and no finite guess exists. Variation of parameters (next lesson) handles it. The method also needs constant coefficients, because the matrices came from P(s).
Lab
Blocks: A matrices, B identities, C residuals, D shortcut, E initial conditions, F limits, G problems.
🐍 PythonLab: the guess as a linear solve, sympy residuals, the transfer function, initial conditions, RK45
⌘/Ctrl + Enter
Exercise: the guess as a matrix, with sympy and RK45 as referees
Implement poly_matrix (the matrix of L on 1,t,…,tn), poly_particular (solve it), residual (a sympy check), start_values (the data yh must start from) and rk45_gap (the largest distance between a closed form and RK45).
🧪 Coding exerciseExercise: undetermined coefficients as a linear solve, verified by sympy and RK45✓ passed
⌘/Ctrl + Enter
💡 Column j has c at row j, b*j at row j-1 and a*j*(j-1) at row j-2. For rk45_gap use solve_ivp with t_eval on a fine grid.
Problems
✏️ Pen & paperA ramp, then initial conditions●○○
Solve y′′+7y′+12y=24t+38, y(0)=0, y′(0)=1. What does y look like for large t?
Show worked solution
P=(r+3)(r+4), so yh=c1e−3t+c2e−4t. Since P(0)=12=0, guess At+B: L=12At+7A+12B, so A=2 and B=2: yp=2t+2. Then yh starts from (0−2,1−2)=(−2,−1): c1+c2=−2 and −3c1−4c2=−1 give c2=7, c1=−9:
y=−9e−3t+7e−4t+2t+2.
Check: y(0)=0, y′(0)=27−28+2=1. For large t the exponentials die and y→2t+2; at t=2 the gap is −0.019961 (block G).
✏️ Pen & paperTwo forcings, one of them resonant●●○
Solve y′′−3y′+2y=6e3t+2et with y(0)=1, y′(0)=4.
Show worked solution
P=(r−1)(r−2), so yh=c1et+c2e2t. For 6e3t: P(3)=2, so yp1=3e3t. For 2et the exponent 1 is a simple root, so yp2=P′(1)2tet=−2tet since P′(r)=2r−3 gives P′(1)=−1. So yp=3e3t−2tet, with yp(0)=3 and yp′(0)=9−2=7. Then yh starts from (−2,−3): c1+c2=−2 and c1+2c2=−3 give c2=−1, c1=−1:
y=−et−e2t+3e3t−2tet.
Check: y(0)=1 and y′(0)=−1−2+9−2=4 (block G).
✏️ Pen & paperAmplitude, phase and the length of the transient●●●
For y′′+2y′+17y=50cos3t, y(0)=y′(0)=0: (a) use G=1/P(iω) to find yp, its amplitude and phase lag; (b) solve the IVP; (c) bound the transient by an envelope and find when it is 1% of the steady amplitude.
Show worked solution
(a) P(3i)=−9+6i+17=8+6i, ∣P∣=10, φ=0.643501 rad. The amplitude is 50/10=5, and 50/(8+6i)=4−3i gives yp=4cos3t+3sin3t=5cos(3t−0.643501).
(b) The roots are −1±4i. yp(0)=4 and yp′(0)=9, so yh(0)=−4, yh′(0)=−9. With yh=e−t(c1cos4t+c2sin4t): c1=−4 and −c1+4c2=−9, so c2=−3.25:
y=e−t(−4cos4t−3.25sin4t)+4cos3t+3sin3t.
Check: y(0)=0 and y′(0)=4−13+9=0.
(c) ∣y−yp∣=∣yh∣≤16+10.5625e−t=5.153882e−t. This equals 0.05 at t=ln(5.153882/0.05)=4.635482 (block G).
✅ Concept check
For $y'' + 5y' + 6y = 7e^{-3t}$ (roots of $P$: $-2$ and $-3$), which is the smallest correct form of the guess?
Why: $L[te^{st}] = (P(s)t + P'(s))e^{st}$ with $P(-3) = 0$ and $P'(-3) = -1$.
✅ Concept check
With $y_p = \sin 3t + 2$ and initial data $y(0) = 0$, $y'(0) = 1$, what must $y_h'(0)$ be? Give a number.
Why: $y_p'(0) = 3$, so $y_h'(0) = 1 - 3 = -2$. Fitting $y_h$ to $y'(0) = 1$ directly is the classic mistake.
✅ Concept check
Which forcing can NOT be handled by undetermined coefficients with any finite guess?
Why: The forcing must be a finite sum of terms $t^ke^{st}$. $\sec t$, $\tan t$, $1/t$ and $\ln t$ are not.
Key Takeaways
Every solution of L[y]=g is yh+yp: a particular solution plus the kernel, like Ax=b. Any yp will do.
The guess works because the forcing’s family is closed under differentiation, so L is a small matrix there: triangular with c or P(s) on the diagonal, or with determinant ∣P(iω)∣2 for cos and sin. The coefficients are the unknowns of a linear solve.
Guess the full family (all powers; both cos and sin); split sums of forcings.
If the exponent is a root of P of multiplicity m, the matrix is singular; multiply the guess by tm, because L[test]=(P(s)t+P′(s))est.
For Fcosωt: yp=(F/∣P(iω)∣)cos(ωt−φ), φ=argP(iω); G=1/P(iω) is the transfer function.
Apply initial conditions to yh+yp: yh starts from (y(0)−yp(0),y′(0)−yp′(0)). y−yp=yh fades only if yh decays.
The method needs constant coefficients and forcing made of tkest terms; tant, 1/t and lnt need variation of parameters.
Finished this lesson?
Mark it complete to track your progress (saved in this browser). Reading every section does this for you.