6. Second-order linear equations with constant coefficients
Every equation so far has involved only y and y'. This lesson adds y'', restricted to the case where every coefficient is a plain constant — and the entire solving method reduces to a single algebraic equation, no integration required at all.
The equation and the characteristic equation
ay''+by'+cy=0
(a,b,c constants, a\ne0) is called homogeneous (the right side is 0). Guess a solution of the form y=e^{rx} for some constant r — motivated by the fact that e^{rx} reproduces itself under differentiation (\frac d{dx}e^{rx}=re^{rx}), so plugging it in should turn the differential equation into ordinary algebra:
a\big(r^2e^{rx}\big)+b\big(re^{rx}\big)+c\big(e^{rx}\big)=0\ \Longrightarrow\ e^{rx}\big(ar^2+br+c\big)=0
Since e^{rx} is never zero, this reduces to the characteristic equation:
ar^2+br+c=0
— an ordinary quadratic, solvable by the quadratic formula. Every root r of this equation gives a solution y=e^{rx} to the original differential equation — turning a calculus problem into an algebra problem.
Three cases, from the discriminant
The quadratic formula, r=\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}, behaves exactly as it did back in earlier algebra — three cases depending on the discriminant's sign, each producing a structurally different general solution.
Case 1: two distinct real roots r_1\ne r_2.
y=C_1e^{r_1x}+C_2e^{r_2x}
Case 2: a repeated root r (discriminant =0). A single exponential e^{rx} only supplies one independent solution; the second is xe^{rx} (verifiable directly by substitution):
y=(C_1+C_2x)e^{rx}
Case 3: complex conjugate roots r=\alpha\pm\beta i. Using Euler's formula (§8.3), $e^{(\alpha+\beta i)x}=e^{\alpha x}\big(\cos\beta x+i\sin\beta x\big)$ — the complex exponential splits into a real oscillating pair. Taking real linear combinations of the two complex solutions produces a purely real general solution:
y=e^{\alpha x}\big(C_1\cos\beta x+C_2\sin\beta x\big)
This is the exact mechanism behind oscillation — whenever the characteristic roots are complex, the solution genuinely oscillates (with the oscillation growing, shrinking, or staying constant in amplitude depending on the sign of \alpha), a direct physical consequence of Euler's formula converting a complex exponent into trigonometric functions.
Two constants need two conditions
A second-order equation's general solution carries two arbitrary constants (differentiating twice loses two pieces of information, the reverse of §4.0's single +C for one antiderivative) — pinning both down requires two initial conditions, typically y(x_0)=y_0 and y'(x_0)=y_0' (an initial position and an initial velocity, in a physical reading).
Doing it in Python
Solving y''-3y'+2y=0 (Case 1, distinct real roots), applying y(0)=1, y'(0)=0:
import sympy as sp
r, x = sp.symbols('r x')
a, b, c = 1, -3, 2
characteristic = a*r**2 + b*r + c
roots = sp.solve(characteristic, r)
print(f"characteristic equation: {characteristic} = 0")
print(f"roots: {roots}")
C1, C2 = sp.symbols('C1 C2')
y = C1*sp.exp(roots[0]*x) + C2*sp.exp(roots[1]*x)
y_prime = sp.diff(y, x)
solution_constants = sp.solve([sp.Eq(y.subs(x, 0), 1), sp.Eq(y_prime.subs(x, 0), 0)], [C1, C2])
y_particular = y.subs(solution_constants)
print(f"particular solution: y = {sp.simplify(y_particular)}")
Solving y''+4y=0 (Case 3, complex roots — simple harmonic motion), confirming the oscillating solution directly:
import sympy as sp
r, x = sp.symbols('r x')
a, b, c = 1, 0, 4
characteristic = a*r**2 + b*r + c
roots = sp.solve(characteristic, r)
print(f"roots (complex): {roots}")
print("real part 0, imaginary part 2 -- pure oscillation, angular frequency 2")
C1, C2 = sp.symbols('C1 C2')
y = C1*sp.cos(2*x) + C2*sp.sin(2*x)
print(f"general solution: y = {y}")
Confirming SymPy's built-in solver matches the characteristic-equation method for the repeated-root case:
import sympy as sp
x = sp.Symbol('x')
y = sp.Function('y')
ode = sp.Eq(y(x).diff(x, 2) - 4*y(x).diff(x) + 4*y(x), 0)
solution = sp.dsolve(ode, y(x))
print(f"sympy's solution: {solution}")
print("characteristic equation r^2-4r+4=(r-2)^2=0 has a repeated root r=2")
print("matching the (C1+C2*x)*e^(2x) form predicted by Case 2")
Worked example
Solve y''-3y'+2y=0, y(0)=1, y'(0)=0.
Characteristic equation: $r^2-3r+2=0\Rightarrow(r-1)(r-2)=0\Rightarrow r=1,2$ — two distinct real roots (Case 1).
y=C_1e^x+C_2e^{2x}
Apply the initial conditions. y(0)=C_1+C_2=1.
y'=C_1e^x+2C_2e^{2x}\ \Longrightarrow\ y'(0)=C_1+2C_2=0
Subtract the first equation from the second: C_2=-1. Then C_1=1-C_2=1-(-1)=2.
\boxed{y=2e^x-e^{2x}}
Sanity check. y(0)=2-1=1 ✓. y'=2e^x-2e^{2x}, so y'(0)=2-2=0 ✓ — both initial conditions confirmed directly. Substitute into the original equation as a full check: y''=2e^x-4e^{2x}, and y''-3y'+2y=(2e^x-4e^{2x})-3(2e^x-2e^{2x})+2(2e^x-e^{2x})=(2-6+4)e^x+(-4+6-2)e^{2x}=0 ✓, confirming the solution satisfies the differential equation exactly, not just the initial conditions. ✓
Your turn
1. Find the general solution to y''-5y'+6y=0 (find the roots first, then classify which case applies).
2. Find the general solution to y''+9y=0.
3. True or false: the general solution of a second-order linear homogeneous equation always contains exactly two arbitrary constants, regardless of which of the three root cases applies.
Solutions
1. r^2-5r+6=0\Rightarrow(r-2)(r-3)=0\Rightarrow r=2,3 — Case 1, distinct real roots.
\boxed{y=C_1e^{2x}+C_2e^{3x}}
2. r^2+9=0\Rightarrow r^2=-9\Rightarrow r=\pm3i — Case 3, complex roots with \alpha=0, \beta=3 (pure oscillation, no growth or decay in amplitude, since the real part is exactly zero).
\boxed{y=C_1\cos3x+C_2\sin3x}
3. True. All three cases produce exactly two arbitrary constants: C_1,C_2 multiplying two exponentials (Case 1), a constant plus a linear-in-x coefficient both multiplying one exponential (Case 2), or C_1,C_2 multiplying \cos and \sin (Case 3) — this count matches the "two initial conditions needed" fact from the concept section exactly, since a second-order equation always loses exactly two pieces of information relative to y itself, regardless of which root case the characteristic equation happens to fall into.
Check yourself in code
Solve y''-3y'+2y=0, y(0)=1, y'(0)=0 using the characteristic equation.
Print exactly this:
roots: [1, 2]
particular solution: y = (2 - exp(x))*exp(x)
import sympy as sp
r, x = sp.symbols('r x')
a, b, c = 1, -3, 2
characteristic = a*r**2 + b*r + c
roots = sp.solve(characteristic, r)
print("roots: ...")
C1, C2 = sp.symbols('C1 C2')
y = C1*sp.exp(roots[0]*x) + C2*sp.exp(roots[1]*x)
y_prime = sp.diff(y, x)
solution_constants = sp.solve([sp.Eq(y.subs(x, 0), 1), sp.Eq(y_prime.subs(x, 0), 0)], [C1, C2])
y_particular = y.subs(solution_constants)
print("particular solution: y = ...")
import sympy as sp
r, x = sp.symbols('r x')
a, b, c = 1, -3, 2
characteristic = a*r**2 + b*r + c
roots = sp.solve(characteristic, r)
print(f"roots: {roots}")
C1, C2 = sp.symbols('C1 C2')
y = C1*sp.exp(roots[0]*x) + C2*sp.exp(roots[1]*x)
y_prime = sp.diff(y, x)
solution_constants = sp.solve([sp.Eq(y.subs(x, 0), 1), sp.Eq(y_prime.subs(x, 0), 0)], [C1, C2])
y_particular = sp.simplify(y.subs(solution_constants))
print(f"particular solution: y = {y_particular}")
A homogeneous linear equation with constant coefficients, ay''+by'+cy=0, reduces entirely to algebra: substitute y=e^{rx}, solve the resulting characteristic equation ar^2+br+c=0, and read the general solution off directly from the roots — real and distinct give two exponentials, a repeated root gives an exponential paired with x times itself, and complex roots give oscillation via Euler's formula (§8.3). Two arbitrary constants always need two initial conditions to pin down, exactly mirroring how a second derivative loses exactly two pieces of information.
Next: what happens when the equation isn't homogeneous — a nonzero forcing term on the right side, requiring one more piece added to the solution found here.