TExcelTAD
Home › Calculus in Depth › Second-Order Linear Equations

Second-Order Linear Equations

A second-order linear equation with constant coefficients, ay′′+by′+cy=0ay'' + by' + cy = 0, is the model behind every spring, pendulum, circuit and camera smoother you will meet. This lesson proves why its solutions form a two-dimensional space, derives the three cases of the characteristic equation, uses the Wronskian to test independence, and contrasts initial-value problems (always one answer) with boundary-value problems (zero, one or infinitely many).

For a first look, see Second-order equations in the survey course. The first-order theory this builds on is in Linear Equations.

The structure of the solution set

A second-order linear equation has the form

P(x) y′′+Q(x) y′+R(x) y=G(x)P(x)\,y'' + Q(x)\,y' + R(x)\,y = G(x)

It is homogeneous when G(x)=0G(x) = 0. Write L[y]=Py′′+Qy′+RyL[y] = Py'' + Qy' + Ry. Differentiation is linear, so L[c1y1+c2y2]=c1L[y1]+c2L[y2]L[c_1y_1 + c_2y_2] = c_1L[y_1] + c_2L[y_2]. Two consequences follow:

Fact Statement
Superposition If y1y_1 and y2y_2 solve L[y]=0L[y] = 0, so does every c1y1+c2y2c_1y_1 + c_2y_2
Existence and uniqueness If PP, QQ, RR are continuous and P≠0P \ne 0 on an interval containing x0x_0, the problem L[y]=0L[y] = 0, y(x0)=y0y(x_0) = y_0, y′(x0)=y1y'(x_0) = y_1 has exactly one solution on that interval
General solution If y1y_1, y2y_2 are linearly independent solutions, every solution is c1y1+c2y2c_1y_1 + c_2y_2

The last row is a theorem, not a definition. Sketch of proof: let yy be any solution. Pick c1c_1, c2c_2 with c1y1(x0)+c2y2(x0)=y(x0)c_1y_1(x_0) + c_2y_2(x_0) = y(x_0) and c1y1′(x0)+c2y2′(x0)=y′(x0)c_1y_1'(x_0) + c_2y_2'(x_0) = y'(x_0). This 2×22 \times 2 system is solvable exactly when the Wronskian

W(y1,y2)=y1y2′−y2y1′W(y_1, y_2) = y_1 y_2' - y_2 y_1'

is non-zero at x0x_0. Then yy and c1y1+c2y2c_1y_1 + c_2y_2 solve the same initial-value problem, so by uniqueness they are equal everywhere. For solutions of L[y]=0L[y] = 0, WW is either never zero or identically zero (Abel's formula: W(x)=W(x0)⋅exp⁡(−∫Q/P dx)W(x) = W(x_0) \cdot \exp\left(-\int Q/P\,dx\right)), so checking a single point is enough.

Constant coefficients: the characteristic equation

For ay′′+by′+cy=0ay'' + by' + cy = 0, try y=erxy = e^{rx}. Then y′=rerxy' = re^{rx}, y′′=r2erxy'' = r^2e^{rx}, and dividing by erx≠0e^{rx} \ne 0 leaves the characteristic equation

ar2+br+c=0ar^2 + br + c = 0
Discriminant b2−4acb^2 - 4ac Roots General solution
>0> 0 two real r1≠r2r_1 \ne r_2 y=c1er1x+c2er2xy = c_1e^{r_1x} + c_2e^{r_2x}
=0= 0 one real rr (double) y=c1erx+c2xerxy = c_1e^{rx} + c_2xe^{rx}
<0< 0 α±βi\alpha \pm \beta i y=eαx(c1cos⁡βx+c2sin⁡βx)y = e^{\alpha x}(c_1\cos\beta x + c_2\sin\beta x)

Why xerxxe^{rx} in the double-root case? With r=−b/(2a)r = -b/(2a), substitute y=xerxy = xe^{rx}: L[y]=(ar2+br+c) xerx+(2ar+b) erxL[y] = (ar^2 + br + c)\,xe^{rx} + (2ar + b)\,e^{rx}, and both brackets are zero. Why cosines in the complex case? Euler's formula e(α+iβ)x=eαx(cos⁡βx+isin⁡βx)e^{(\alpha + i\beta)x} = e^{\alpha x}(\cos\beta x + i\sin\beta x) gives complex solutions whose real and imaginary parts are real solutions (see Complex Numbers).

SymPy's dsolve produces all three shapes. It prints C1, C2 for the constants and exp(...) for e(…)e^{(\ldots)}; sp.roots returns a dictionary {root: multiplicity}, and I is ii.

python · try it yourself
import sympy as sp

x = sp.symbols('x')
y = sp.Function('y')
for a, b, c in [(1, 1, -6), (1, -6, 9), (1, 2, 10)]:
    ode = sp.Eq(a*y(x).diff(x, 2) + b*y(x).diff(x) + c*y(x), 0)
    r = sp.symbols('r')
    roots = sp.roots(a*r**2 + b*r + c, r)
    print(f"a, b, c = {a}, {b}, {c}   roots {roots}")
    print("   ", sp.dsolve(ode).rhs)
a, b, c = 1, 1, -6   roots {2: 1, -3: 1}
    C1*exp(-3*x) + C2*exp(2*x)
a, b, c = 1, -6, 9   roots {3: 2}
    (C1 + C2*x)*exp(3*x)
a, b, c = 1, 2, 10   roots {-1 - 3*I: 1, -1 + 3*I: 1}
    (C1*sin(3*x) + C2*cos(3*x))*exp(-x)

Initial-value problems

Solve y′′+y′−6y=0y'' + y' - 6y = 0 with y(0)=1y(0) = 1, y′(0)=7y'(0) = 7. The roots are 2 and −3-3, so y=c1e2x+c2e−3xy = c_1e^{2x} + c_2e^{-3x} and

y(0)=c1+c2=1y′(0)=2c1−3c2=7→ 5c1=10, c1=2, c2=−1y=2e2x−e−3x\begin{aligned} y(0) &= c_1 + c_2 = 1 \\ y'(0) &= 2c_1 - 3c_2 = 7 && \to\ 5c_1 = 10,\ c_1 = 2,\ c_2 = -1 \\ y &= 2e^{2x} - e^{-3x} \end{aligned}

The Wronskian of e2xe^{2x} and e−3xe^{-3x} is e2x⋅(−3e−3x)−e−3x⋅2e2x=−5e−xe^{2x} \cdot (-3e^{-3x}) - e^{-3x} \cdot 2e^{2x} = -5e^{-x}, never zero, so these two really are a basis. The program checks the solution symbolically and against a numerical solver.

python · try it yourself
import numpy as np
import sympy as sp
from scipy.integrate import solve_ivp

x = sp.symbols('x')
y = sp.Function('y')
ode = sp.Eq(y(x).diff(x, 2) + y(x).diff(x) - 6*y(x), 0)
sol = sp.dsolve(ode, ics={y(0): 1, y(x).diff(x).subs(x, 0): 7})
print(sol)
print("checkodesol:", sp.checkodesol(ode, sol))
y1, y2 = sp.exp(2*x), sp.exp(-3*x)
print("Wronskian:", sp.simplify(sp.wronskian([y1, y2], x)))

# the same problem as a first-order system u = (y, y')
num = solve_ivp(lambda t, u: [u[1], 6*u[0] - u[1]], (0, 1), [1, 7], rtol=1e-10, atol=1e-12)
print("numeric y(1) =", round(float(num.y[0, -1]), 6), " exact =", round(float(sol.rhs.subs(x, 1)), 6))
Eq(y(x), 2*exp(2*x) - exp(-3*x))
checkodesol: (True, 0)
Wronskian: -5*exp(-x)
numeric y(1) = 14.728325  exact = 14.728325

Boundary-value problems

Prescribe values at two different points instead, and uniqueness can fail. Take y′′+4y=0y'' + 4y = 0, whose solutions are y=c1cos⁡2x+c2sin⁡2xy = c_1\cos 2x + c_2\sin 2x, with y(0)=0y(0) = 0, which forces c1=0c_1 = 0:

Second condition Effect on c2c_2 Number of solutions
y(π/4)=3y(\pi/4) = 3 sin⁡(π/2)⋅c2=3→c2=3\sin(\pi/2) \cdot c_2 = 3 \to c_2 = 3 exactly one
y(π)=0y(\pi) = 0 sin⁡(2π)⋅c2=0\sin(2\pi) \cdot c_2 = 0 holds for every c2c_2 infinitely many
y(π)=1y(\pi) = 1 0⋅c2=10 \cdot c_2 = 1 none
python · try it yourself
import sympy as sp

x, c2 = sp.symbols('x c2')
y = c2 * sp.sin(2*x)                  # already satisfies y(0) = 0
for point, value in [(sp.pi/4, 3), (sp.pi, 0), (sp.pi, 1)]:
    condition = sp.Eq(y.subs(x, point), value)      # SymPy simplifies it at once
    print(f"y({point}) = {value}  becomes  {condition}")
y(pi/4) = 3  becomes  Eq(c2, 3)
y(pi) = 0  becomes  True
y(pi) = 1  becomes  False

Eq(c2, 3) pins down c2c_2; True means the condition holds for every c2c_2; False means no c2c_2 works. The point π\pi is special because sin⁡2x\sin 2x vanishes there: this is the eigenvalue phenomenon behind vibrating strings, where only certain frequencies fit between two fixed ends.

Note: Initial-value problems are what simulations solve, step by step from a known state. Boundary-value problems appear in beam deflection, heat flow between two walls and quantum wells, and need different numerical methods (shooting, finite differences).

In software

  • Physics and animation. Every damped spring, from a car suspension in a racing game to a UI "spring" animation, is ay′′+by′+cy=0ay'' + by' + cy = 0 plus a forcing term. The three cases are overdamped, critically damped and underdamped motion (Applications of Second-Order Equations).
  • Digital filters. A second-order IIR filter ("biquad") in audio code is the discrete twin of this equation. Its characteristic roots (poles) decide whether it rings, and the filter is stable when they lie inside the unit circle, just as the ODE is stable when the roots have negative real part.
  • Stability checks. Control and simulation code tests stability by computing characteristic roots, often with numpy.roots.

Exercises

Exercise 1: Two real roots

Find the general solution of y′′−5y′+6y=0y'' - 5y' + 6y = 0.

Answer

y=c1e2x+c2e3xy = c_1e^{2x} + c_2e^{3x}.

Solution
r2−5r+6=(r−2)(r−3)=0  →  r=2,3y=c1e2x+c2e3x\begin{aligned} &r^2 - 5r + 6 = (r - 2)(r - 3) = 0 \;\to\; r = 2, 3 \\ &y = c_1e^{2x} + c_2e^{3x} \end{aligned}

Exercise 2: A double root with initial values

Solve y′′+6y′+9y=0y'' + 6y' + 9y = 0 with y(0)=2y(0) = 2, y′(0)=−1y'(0) = -1.

Answer

y=(2+5x)e−3xy = (2 + 5x)e^{-3x}.

Solution
r2+6r+9=(r+3)2  →  r=−3 (double)y=(c1+c2x)e−3x,y(0)=c1=2y′=c2e−3x−3(c1+c2x)e−3x,y′(0)=c2−3c1=c2−6=−1  →  c2=5\begin{aligned} &r^2 + 6r + 9 = (r + 3)^2 \;\to\; r = -3 \text{ (double)} \\ y &= (c_1 + c_2x)e^{-3x}, && y(0) = c_1 = 2 \\ y' &= c_2e^{-3x} - 3(c_1 + c_2x)e^{-3x}, && y'(0) = c_2 - 3c_1 = c_2 - 6 = -1 \;\to\; c_2 = 5 \end{aligned}
python · try it yourself
import sympy as sp
x = sp.symbols('x'); y = sp.Function('y')
ode = sp.Eq(y(x).diff(x, 2) + 6*y(x).diff(x) + 9*y(x), 0)
print(sp.dsolve(ode, ics={y(0): 2, y(x).diff(x).subs(x, 0): -1}))
Eq(y(x), (5*x + 2)*exp(-3*x))

Exercise 3: Complex roots

Find the general solution of y′′+4y′+13y=0y'' + 4y' + 13y = 0.

Answer

y=e−2x(c1cos⁡3x+c2sin⁡3x)y = e^{-2x}(c_1\cos 3x + c_2\sin 3x).

Solution
r=−4±16−522=−4±−362=−2±3iα=−2, β=3  →  y=e−2x(c1cos⁡3x+c2sin⁡3x)\begin{aligned} &r = \frac{-4 \pm \sqrt{16 - 52}}{2} = \frac{-4 \pm \sqrt{-36}}{2} = -2 \pm 3i \\ &\alpha = -2,\ \beta = 3 \;\to\; y = e^{-2x}(c_1\cos 3x + c_2\sin 3x) \end{aligned}

Exercise 4: Wronskian (code)

Show that y1=excos⁡xy_1 = e^x\cos x and y2=exsin⁡xy_2 = e^x\sin x are independent by computing their Wronskian, first by hand and then with sympy.wronskian.

Answer

W=e2xW = e^{2x}, which is never zero, so they are independent.

Solution
y1′=ex(cos⁡x−sin⁡x),y2′=ex(sin⁡x+cos⁡x)W=y1y2′−y2y1′=e2x[cos⁡x(sin⁡x+cos⁡x)−sin⁡x(cos⁡x−sin⁡x)]=e2x(cos⁡2x+sin⁡2x)=e2x\begin{aligned} &y_1' = e^x(\cos x - \sin x), \quad y_2' = e^x(\sin x + \cos x) \\ W &= y_1y_2' - y_2y_1' = e^{2x}[\cos x(\sin x + \cos x) - \sin x(\cos x - \sin x)] \\ &= e^{2x}(\cos^2 x + \sin^2 x) = e^{2x} \end{aligned}
python · try it yourself
import sympy as sp
x = sp.symbols('x')
print(sp.simplify(sp.wronskian([sp.exp(x)*sp.cos(x), sp.exp(x)*sp.sin(x)], x)))
exp(2*x)

Exercise 5: A boundary-value problem

Solve y′′+9y=0y'' + 9y = 0 with y(0)=1y(0) = 1 and y(π/2)=2y(\pi/2) = 2. Is the solution unique?

Answer

y=cos⁡3x−2sin⁡3xy = \cos 3x - 2\sin 3x, and it is unique.

Solution
y=c1cos⁡3x+c2sin⁡3xy(0)=c1=1y(π/2)=c1cos⁡(3π/2)+c2sin⁡(3π/2)=0−c2=2  →  c2=−2\begin{aligned} y &= c_1\cos 3x + c_2\sin 3x \\ y(0) &= c_1 = 1 \\ y(\pi/2) &= c_1\cos(3\pi/2) + c_2\sin(3\pi/2) = 0 - c_2 = 2 \;\to\; c_2 = -2 \end{aligned}

The second condition determined c2c_2 uniquely because sin⁡(3π/2)≠0\sin(3\pi/2) \ne 0.

Test yourself

The characteristic equation of y′′−2y′+5y=0y'' - 2y' + 5y = 0 has roots 1±2i1 \pm 2i. What is the general solution?

  1. c1ex+c2e2xc_1e^x + c_2e^{2x}
  2. ex(c1cos⁡2x+c2sin⁡2x)e^x(c_1\cos 2x + c_2\sin 2x)
  3. e2x(c1cos⁡x+c2sin⁡x)e^{2x}(c_1\cos x + c_2\sin x)
  4. (c1+c2x)ex(c_1 + c_2x)e^x

Why is xerxxe^{rx} a solution when rr is a double root?

  1. Because every function times xx is a solution
  2. Because substituting it leaves (ar2+br+c) xerx+(2ar+b) erx(ar^2 + br + c)\,xe^{rx} + (2ar + b)\,e^{rx}, and both brackets vanish for a double root
  3. Because the Wronskian is zero
  4. It is not a solution

A boundary-value problem for y′′+y=0y'' + y = 0 asks for y(0)=0y(0) = 0 and y(π)=5y(\pi) = 5. How many solutions are there?

  1. Exactly one
  2. Two
  3. Infinitely many
  4. None