Second-Order Linear Equations
A second-order linear equation with constant coefficients, , 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
It is homogeneous when . Write . Differentiation is linear, so . Two consequences follow:
| Fact | Statement |
|---|---|
| Superposition | If and solve , so does every |
| Existence and uniqueness | If , , are continuous and on an interval containing , the problem , , has exactly one solution on that interval |
| General solution | If , are linearly independent solutions, every solution is |
The last row is a theorem, not a definition. Sketch of proof: let be any solution. Pick , with and . This system is solvable exactly when the Wronskian
is non-zero at . Then and solve the same initial-value problem, so by uniqueness they are equal everywhere. For solutions of , is either never zero or identically zero (Abel's formula: ), so checking a single point is enough.
Constant coefficients: the characteristic equation
For , try . Then , , and dividing by leaves the characteristic equation
| Discriminant | Roots | General solution |
|---|---|---|
| two real | ||
| one real (double) | ||
Why in the double-root case? With , substitute : , and both brackets are zero. Why cosines in the complex case? Euler's formula 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 ; sp.roots returns a dictionary {root: multiplicity}, and I is .
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 with , . The roots are 2 and , so and
The Wronskian of and is , never zero, so these two really are a basis. The program checks the solution symbolically and against a numerical solver.
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 , whose solutions are , with , which forces :
| Second condition | Effect on | Number of solutions |
|---|---|---|
| exactly one | ||
| holds for every | infinitely many | |
| none |
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 ; True means the condition holds for every ; False means no works. The point is special because 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 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 .
Answer
.
Solution
Exercise 2: A double root with initial values
Solve with , .
Answer
.
Solution
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 .
Answer
.
Solution
Exercise 4: Wronskian (code)
Show that and are independent by computing their Wronskian, first by hand and then with sympy.wronskian.
Answer
, which is never zero, so they are independent.
Solution
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 with and . Is the solution unique?
Answer
, and it is unique.
Solution
The second condition determined uniquely because .
Test yourself
The characteristic equation of has roots . What is the general solution?
Why is a solution when is a double root?
- Because every function times is a solution
- Because substituting it leaves , and both brackets vanish for a double root
- Because the Wronskian is zero
- It is not a solution
A boundary-value problem for asks for and . How many solutions are there?
- Exactly one
- Two
- Infinitely many
- None