Topic · Differential Equations

Second-Order Linear ODEs

Pull a spring and let go — it doesn't snap straight to rest. It overshoots, swings back, overshoots the other way, and keeps oscillating until friction wears it down. Two forces are fighting: one restoring the spring toward its resting length (the harder you pull, the harder it pulls back), and one resisting fast motion (friction, air drag). That tug-of-war between a position-driven force and a velocity-driven force is exactly what the equation $ay'' + by' + cy = g(x)$ describes — and the same equation governs RLC circuits, pendulums under damping, and a building swaying in the wind. The whole theory rests on a single quadratic, and the rest is recognizing its three faces.

What you'll leave with

  • The shape of every constant-coefficient homogeneous solution — written down from the roots of one quadratic.
  • Why distinct real, repeated, and complex roots correspond to overdamped, critically damped, and underdamped motion in the physical world.
  • How the general solution splits as $y = y_h + y_p$ — and two ways to find $y_p$.
  • When to reach for undetermined coefficients versus variation of parameters.
  • A working picture of the spring-mass-damper system and what each parameter does to its motion.

1. The shape of the equation

Second-order linear ODE

An equation of the form $a(x) y'' + b(x) y' + c(x) y = g(x)$ in which $y$, $y'$, and $y''$ appear only to the first power and are not multiplied together. "Second-order" because the highest derivative is $y''$; "linear" because $y$ and its derivatives enter linearly.

For the rest of this topic we focus on the constant-coefficient case, where $a$, $b$, $c$ are numbers, not functions of $x$:

$$ a y'' + b y' + c y = g(x), \qquad a \neq 0. $$

Two further pieces of vocabulary set the agenda:

  • Homogeneous means $g(x) = 0$. The equation describes an unforced, isolated system — a spring with no one pushing it.
  • Inhomogeneous means $g(x) \neq 0$. The right-hand side is a forcing term — an outside agent driving the system.

We solve the homogeneous case first because the inhomogeneous case is built on top of it.

2. Linearity and superposition

The reason second-order linear ODEs are so tractable is that solutions add. If $y_1$ and $y_2$ both satisfy the homogeneous equation, so does $c_1 y_1 + c_2 y_2$ for any constants $c_1, c_2$. This is the superposition principle, and it has a precise consequence:

Structure theorem

The set of solutions to a second-order linear homogeneous ODE forms a two-dimensional vector space. Pick any two linearly independent solutions $y_1, y_2$ — together they span every possible solution: $y = c_1 y_1 + c_2 y_2$.

So the entire game is to find any two linearly independent solutions. The constants $c_1$ and $c_2$ are then pinned down by two initial conditions, typically $y(x_0)$ and $y'(x_0)$ — one for each dimension of the solution space.

3. The characteristic equation

For the homogeneous equation $ay'' + by' + cy = 0$, try the educated guess $y = e^{rx}$. Differentiating once and twice:

$$ y' = r e^{rx}, \qquad y'' = r^2 e^{rx}. $$

Substitute and factor out the (nonzero) $e^{rx}$:

$$ (ar^2 + br + c)\, e^{rx} = 0 \quad\Longrightarrow\quad ar^2 + br + c = 0. $$
Characteristic equation

The quadratic $ar^2 + br + c = 0$ obtained by substituting $y = e^{rx}$ into the homogeneous ODE. Its roots determine every solution.

From here we just read off the roots using the quadratic formula:

$$ r = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}. $$

The discriminant $\Delta = b^2 - 4ac$ decides which of three regimes we're in. Everything else follows.

4. Three regimes of the homogeneous solution

One quadratic, three personalities. Each regime corresponds to a sign of the discriminant.

DiscriminantRootsGeneral solution
$\Delta > 0$
distinct real
$r_1, r_2 \in \mathbb{R}$, $r_1 \neq r_2$ $y = c_1 e^{r_1 x} + c_2 e^{r_2 x}$
$\Delta = 0$
repeated
$r$ (double root) $y = (c_1 + c_2 x)\, e^{r x}$
$\Delta < 0$
complex conjugate
$r = \alpha \pm \beta i$ $y = e^{\alpha x}\bigl(c_1 \cos\beta x + c_2 \sin\beta x\bigr)$

Distinct real roots

Both $e^{r_1 x}$ and $e^{r_2 x}$ solve the equation, and they're linearly independent (different exponential rates), so they span the solution space. Done.

Repeated root

With only one root, we have only one exponential — and the solution space is two-dimensional. The trick: multiply by $x$. You can verify by substitution that $x e^{rx}$ also satisfies $ay'' + by' + cy = 0$ when $r$ is a double root. The pair $\{e^{rx}, x e^{rx}\}$ is linearly independent and spans the space.

Complex roots

The roots come as a conjugate pair $\alpha \pm \beta i$. The complex-exponential solutions $e^{(\alpha + \beta i) x}$ and $e^{(\alpha - \beta i) x}$ are perfectly valid, but Euler's formula $e^{i\theta} = \cos\theta + i\sin\theta$ lets us repackage them as real functions:

$$ e^{(\alpha + \beta i) x} = e^{\alpha x}(\cos\beta x + i\sin\beta x). $$

Linear combinations of $e^{(\alpha + \beta i) x}$ and $e^{(\alpha - \beta i) x}$ produce $e^{\alpha x}\cos\beta x$ and $e^{\alpha x}\sin\beta x$ — two real solutions that span the same space. The pattern: the real part $\alpha$ controls amplitude growth or decay; the imaginary part $\beta$ controls the oscillation frequency.

One quadratic, three faces

The discriminant is doing the work. Run a slider over $b$ in $y'' + by' + y = 0$: at $b > 2$ the system overshoots toward zero from both directions (two real exponentials); at $b = 2$ the curves meet (repeated root); at $b < 2$ they peel off into spirals (complex roots). The qualitative behavior of the solution flips at $\Delta = 0$.

5. Physical picture: damped oscillation

The cleanest place to see the three regimes is the spring-mass-damper system. A mass $m$ on a spring of stiffness $k$, sliding against friction proportional to velocity with coefficient $c$, obeys Newton's second law:

$$ m\, y'' + c\, y' + k\, y = 0. $$

Here $y$ is the displacement from equilibrium. The characteristic equation is $m r^2 + c r + k = 0$ and its discriminant is $\Delta = c^2 - 4mk$. The sign of $\Delta$ has a name in physics:

Sign of $\Delta$NameMotion
$c^2 > 4mk$ Overdamped Returns to equilibrium without oscillating — slow and sluggish.
$c^2 = 4mk$ Critically damped Returns to equilibrium as fast as possible without overshooting.
$c^2 < 4mk$ Underdamped Oscillates with exponentially shrinking amplitude — a ringing-down decay.

Critical damping is what engineers usually want: a door closer that doesn't slam and doesn't drift; a car suspension that absorbs a bump without bouncing. Too little damping and the system rings; too much and it crawls.

0 1 2 3 4 5 6 1 0.5 0 −0.5 −1 t y overdamped critical
Overdamped — $c^2 > 4mk$ Critically damped — $c^2 = 4mk$ Underdamped — $c^2 < 4mk$

Three solutions of $my'' + cy' + ky = 0$ released from rest at $y(0) = 1$, $y'(0) = 0$. Same starting point, three temperaments — set by the sign of the discriminant.

6. Inhomogeneous equations: $y = y_h + y_p$

Now turn the forcing back on: $ay'' + by' + cy = g(x)$ with $g \neq 0$. The structure theorem extends in a beautiful way.

General solution structure

Every solution of the inhomogeneous equation has the form $y = y_h + y_p$, where $y_h$ is the general solution of the associated homogeneous equation and $y_p$ is any one particular solution of the inhomogeneous equation.

The argument is pure linearity: if $y_p$ satisfies the inhomogeneous equation and $\tilde y$ is another solution, then their difference $\tilde y - y_p$ satisfies the homogeneous equation. So $\tilde y - y_p$ is some $y_h$, which rearranges to $\tilde y = y_h + y_p$.

This splits the problem cleanly:

  1. Solve the homogeneous equation — you already know how. This gives $y_h = c_1 y_1 + c_2 y_2$.
  2. Find any particular solution $y_p$ of the inhomogeneous equation.
  3. Add them: $y = y_h + y_p$. Use initial conditions to nail down $c_1, c_2$.

The two standard ways to find $y_p$ are undetermined coefficients (a guess) and variation of parameters (a recipe).

7. Method 1 — Undetermined coefficients

When the forcing $g(x)$ is built from polynomials, exponentials, sines, and cosines — and products of those — the answer "looks like" $g$ does. The method: guess a form for $y_p$ with unknown coefficients, plug it into the equation, and match coefficients to solve for them.

The guess table

If $g(x)$ is…Try $y_p =$
$P_n(x)$  (polynomial of degree $n$)$A_n x^n + A_{n-1} x^{n-1} + \cdots + A_0$
$e^{\alpha x}$$A e^{\alpha x}$
$\cos\beta x$ or $\sin\beta x$$A \cos\beta x + B\sin\beta x$
$P_n(x)\, e^{\alpha x}\cos\beta x$ or sine version$\bigl(\text{degree-}n\text{ poly}\bigr) e^{\alpha x}\cos\beta x + \bigl(\text{degree-}n\text{ poly}\bigr) e^{\alpha x}\sin\beta x$

Walk-through

Solve $y'' - y = x$.

Step 1 — homogeneous. Characteristic: $r^2 - 1 = 0$, roots $\pm 1$. So $y_h = c_1 e^x + c_2 e^{-x}$.

Step 2 — guess. $g(x) = x$ is a degree-1 polynomial. Try $y_p = Ax + B$.

Step 3 — substitute. $y_p'' = 0$, so the equation reads $0 - (Ax + B) = x$. Matching coefficients: $-A = 1$ and $-B = 0$. So $A = -1$, $B = 0$, giving $y_p = -x$.

Step 4 — combine. $y = c_1 e^x + c_2 e^{-x} - x$.

The resonance trap

If your guessed form already appears in $y_h$, plugging it in gives $0$ on the left — and you can't solve $0 = g$. The fix: multiply the guess by $x$ (or by $x^2$ for a double root collision). For instance, $y'' + y = \cos x$ would normally suggest $y_p = A\cos x + B\sin x$, but those are already homogeneous solutions because $r = \pm i$. Promote to $y_p = x(A\cos x + B\sin x)$, then solve.

This case has a physical name: resonance. When the forcing frequency matches the system's natural frequency, the response grows without bound — the extra factor of $x$ is the mathematics announcing the runaway.

8. Method 2 — Variation of parameters

What if $g(x)$ is $\tan x$, or $\ln x$, or $1/(1 + x^2)$? The guess table doesn't help — no finite combination of polynomials, exponentials, and sinusoids reproduces these. Variation of parameters is the universal fallback. It works for any continuous $g$, at the cost of an integral.

Start from the homogeneous solution $y_h = c_1 y_1 + c_2 y_2$. Instead of constants, allow the coefficients to vary:

$$ y_p = u_1(x)\, y_1(x) + u_2(x)\, y_2(x). $$

That's two unknown functions for one equation, so we have one degree of freedom to spend. Spend it on a convenient constraint: $u_1' y_1 + u_2' y_2 = 0$. Substituting into the ODE (after dividing through by $a$ to put it in the form $y'' + py' + qy = g/a$) leaves a clean system:

$$ \begin{aligned} u_1' y_1 + u_2' y_2 &= 0, \\ u_1' y_1' + u_2' y_2' &= g(x)/a. \end{aligned} $$

Solve for $u_1'$ and $u_2'$ via Cramer's rule. The denominator is the Wronskian $W = y_1 y_2' - y_2 y_1'$, which is nonzero precisely because $y_1, y_2$ are linearly independent:

$$ u_1' = -\frac{y_2\, g/a}{W}, \qquad u_2' = \frac{y_1\, g/a}{W}. $$

Integrate to recover $u_1, u_2$, and assemble $y_p$.

When to use which

Undetermined coefficients is faster — when it applies. Variation of parameters always applies but generates integrals that may not have closed forms. Use undetermined coefficients first; reach for variation of parameters only when $g(x)$ is irregular.

9. Application: the spring-mass-damper, forced

Putting both halves together, the full forced spring-mass-damper system is:

$$ m\, y'' + c\, y' + k\, y = F(t). $$

The homogeneous part $y_h$ describes the system's natural "ringing down" — overdamped, critically damped, or underdamped depending on $c^2$ vs $4mk$. Because all three regimes have negative real parts in their exponents (for $c > 0$), $y_h \to 0$ as $t \to \infty$. This is the transient: it depends on how the system was started, but it dies out.

The particular solution $y_p$ describes the long-term response to the driving force. If $F(t)$ is itself sinusoidal — say $F(t) = F_0 \cos\omega t$ — then $y_p$ is also sinusoidal at frequency $\omega$, but with a different amplitude and phase. This is the steady state.

Two pieces, two roles:

  • Transient ($y_h$). Set by initial conditions, dies away over a time scale governed by the damping.
  • Steady state ($y_p$). Set by the forcing, persists as long as the forcing does. Resonance peaks when $\omega$ matches the natural frequency $\sqrt{k/m}$.

This decomposition is exactly why a guitar string both rings briefly when plucked (transient) and sings at the driver's frequency when bowed (steady state). Same equation, same split.

10. Common pitfalls

Forgetting the second solution in the repeated-root case

$\{e^{rx}\}$ alone is one-dimensional — you need a partner. The partner is $x e^{rx}$, not $e^{rx}$ a second time. Verify by substituting into the ODE that $x e^{rx}$ really does solve it when $r$ is a double root.

Leaving complex exponentials in the answer

When the roots are $\alpha \pm \beta i$, the answer $C_1 e^{(\alpha + \beta i) x} + C_2 e^{(\alpha - \beta i) x}$ is technically correct but unhelpful. Convert it to the real form $e^{\alpha x}(c_1 \cos\beta x + c_2 \sin\beta x)$ using Euler's formula. Real-world systems have real-valued answers.

Skipping the resonance bump

If your undetermined-coefficients guess overlaps with $y_h$, you must multiply by $x$ (or $x^2$ for a double overlap). Forgetting this gives the absurdity $0 = g(x)$ and a wasted page of algebra.

Variation of parameters needs the standard form

The formulas $u_1' = -y_2 g/(aW)$ and $u_2' = y_1 g/(aW)$ assume the ODE has been divided through so the coefficient of $y''$ is $1$ (or equivalently, that you carry the $1/a$ factor explicitly). Mixing up the leading coefficient is the single most common mistake in variation-of-parameters problems.

11. Worked examples

Example 1 · Distinct real roots: $y'' - 3y' + 2y = 0$

Characteristic equation: $r^2 - 3r + 2 = 0$, factoring as $(r - 1)(r - 2) = 0$. Roots $r_1 = 1$, $r_2 = 2$.

General solution:

$$ y = c_1 e^{x} + c_2 e^{2x}. $$

This is overdamped territory: two decaying exponentials (well, here they grow, but the point is that they're real, with no oscillation).

Example 2 · Repeated root: $y'' - 2y' + y = 0$

Characteristic equation: $r^2 - 2r + 1 = (r - 1)^2 = 0$. Double root $r = 1$.

General solution:

$$ y = (c_1 + c_2 x)\, e^{x}. $$

The factor of $x$ is the second linearly independent solution that the repeated root would otherwise have denied you.

Example 3 · Complex roots: $y'' + 2y' + 5y = 0$

Characteristic equation: $r^2 + 2r + 5 = 0$. Discriminant $\Delta = 4 - 20 = -16$. Roots:

$$ r = \frac{-2 \pm \sqrt{-16}}{2} = -1 \pm 2i. $$

So $\alpha = -1$ and $\beta = 2$. General solution:

$$ y = e^{-x}\bigl(c_1 \cos 2x + c_2 \sin 2x\bigr). $$

An underdamped oscillator: it rings at frequency $2$ while its amplitude decays like $e^{-x}$.

Example 4 · Undetermined coefficients: $y'' - y = x$

Homogeneous. $r^2 - 1 = 0$, roots $\pm 1$, so $y_h = c_1 e^x + c_2 e^{-x}$.

Guess. $g(x) = x$ is a degree-1 polynomial — try $y_p = Ax + B$. Then $y_p'' = 0$.

Substituting: $0 - (Ax + B) = x$, so $-A = 1$ and $-B = 0$. Hence $y_p = -x$.

General solution.

$$ y = c_1 e^{x} + c_2 e^{-x} - x. $$
Example 5 · Resonance: $y'' + y = \cos x$

Homogeneous. $r^2 + 1 = 0$, roots $\pm i$, so $y_h = c_1 \cos x + c_2 \sin x$. The natural frequency is $1$.

Naïve guess. $y_p = A\cos x + B\sin x$ — but this is exactly $y_h$. Bumping by $x$:

$$ y_p = x(A\cos x + B\sin x). $$

Compute $y_p''$ (chain rule and product rule), substitute, and matching coefficients of $\cos x$ and $\sin x$ on both sides gives $A = 0$, $B = \tfrac{1}{2}$. So:

$$ y_p = \tfrac{1}{2}\, x \sin x. $$

That factor of $x$ in the answer is the signature of resonance: amplitude grows linearly forever when an undamped oscillator is driven at its own frequency.

Example 6 · Variation of parameters: $y'' - y = x$ revisited

Same equation as Example 4, this time with the universal method. From the homogeneous solution: $y_1 = e^x$, $y_2 = e^{-x}$.

Wronskian. $W = y_1 y_2' - y_2 y_1' = e^x(-e^{-x}) - e^{-x}(e^x) = -1 - 1 = -2$.

Compute $u_1', u_2'$. Here $a = 1$ and $g = x$:

$$ u_1' = -\frac{y_2\, g}{W} = -\frac{e^{-x}\, x}{-2} = \tfrac{1}{2} x e^{-x}, $$ $$ u_2' = \frac{y_1\, g}{W} = \frac{e^{x}\, x}{-2} = -\tfrac{1}{2} x e^{x}. $$

Integrate (by parts, once each):

$$ u_1 = -\tfrac{1}{2}(x + 1) e^{-x}, \qquad u_2 = -\tfrac{1}{2}(x - 1) e^{x}. $$

Assemble.

$$ y_p = u_1 y_1 + u_2 y_2 = -\tfrac{1}{2}(x+1) - \tfrac{1}{2}(x-1) = -x. $$

Same $y_p$ as Example 4 — a useful sanity check that the two methods agree when both apply.

Sources & further reading

The treatment above is synthesized from standard references on ordinary differential equations. For full proofs, edge cases (Cauchy–Euler equations, reduction of order, series solutions), and broader physical applications, follow the sources below.

Test your understanding

A quiz that builds from easy to hard. Pick an answer to get instant feedback and a worked explanation. Your progress is saved in this browser — come back anytime to continue.

Question 1 of 28
0 correct