TExcelTAD
Home › Differential Equations › Complex and Repeated Roots

Complex and Repeated Roots

The characteristic equation ar2+br+c=0ar^2 + br + c = 0 does not always have two distinct real roots. Complex roots produce oscillations, and a double root needs a second solution of a new shape. Both cases are essential: they describe undamped and underdamped springs and critically damped systems.

Complex roots

If b2−4ac<0b^2 - 4ac < 0, the roots are r=α±iβr = \alpha \pm i\beta with α=−b2a\alpha = -\frac{b}{2a} and β=4ac−b22a\beta = \frac{\sqrt{4ac - b^2}}{2a}. The complex solutions e(α±iβ)xe^{(\alpha \pm i\beta)x} are fine, but we want real ones. Euler's formula eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta gives

e(α+iβ)x=eαxcos⁡βx+i eαxsin⁡βx.e^{(\alpha + i\beta)x} = e^{\alpha x}\cos\beta x + i\,e^{\alpha x}\sin\beta x.

The real and imaginary parts are themselves solutions (the equation has real coefficients), so

y=eαx(c1cos⁡βx+c2sin⁡βx).y = e^{\alpha x}\left(c_1\cos\beta x + c_2\sin\beta x\right).
  • β\beta is the angular frequency of the oscillation.
  • α\alpha decides the envelope: decay if α<0\alpha < 0, growth if α>0\alpha > 0, pure oscillation if α=0\alpha = 0.

Example. y′′+2y′+5y=0y'' + 2y' + 5y = 0: r=−1±2ir = -1 \pm 2i, so y=e−x(c1cos⁡2x+c2sin⁡2x)y = e^{-x}(c_1\cos 2x + c_2\sin 2x).

python · try it yourself
import numpy as np
import sympy as sp

print("roots:", np.roots([1, 2, 5]))
x = sp.symbols("x")
y = sp.Function("y")
print(sp.dsolve(y(x).diff(x, 2) + 2 * y(x).diff(x) + 5 * y(x), ics={y(0): 1, y(x).diff(x).subs(x, 0): 0}))
roots: [-1.+2.j -1.-2.j]
Eq(y(x), (sin(2*x)/2 + cos(2*x))*exp(-x))

Amplitude and phase

A combination c1cos⁡βx+c2sin⁡βxc_1\cos\beta x + c_2\sin\beta x is a single shifted cosine:

c1cos⁡βx+c2sin⁡βx=Rcos⁡(βx−δ),R=c12+c22,tan⁡δ=c2c1.c_1\cos\beta x + c_2\sin\beta x = R\cos(\beta x - \delta), \qquad R = \sqrt{c_1^2 + c_2^2}, \quad \tan\delta = \frac{c_2}{c_1}.

Use atan2(c2, c1) to get δ\delta in the right quadrant.

python · try it yourself
import math

c1, c2 = 3.0, -4.0
R, delta = math.hypot(c1, c2), math.atan2(c2, c1)
print(f"R = {R}, delta = {delta:.4f} rad")
for x in (0.0, 0.7, 2.0):
    print(f"x = {x}: {c1*math.cos(2*x) + c2*math.sin(2*x):.6f} = {R*math.cos(2*x - delta):.6f}")
R = 5.0, delta = -0.9273 rad
x = 0.0: 3.000000 = 3.000000
x = 0.7: -3.431897 = -3.431897
x = 2.0: 1.066279 = 1.066279

Repeated roots

If b2=4acb^2 = 4ac, there is one root r=−b2ar = -\frac{b}{2a} and only one exponential solution erxe^{rx}. A second, independent solution is

y2=x erx,y_2 = x\,e^{rx},

which you can find by reduction of order or by letting two distinct roots merge: er2x−er1xr2−r1→xerx\frac{e^{r_2x} - e^{r_1x}}{r_2 - r_1} \to xe^{rx}. So the general solution is y=(c1+c2x)erxy = (c_1 + c_2x)e^{rx}.

Example. y′′+6y′+9y=0y'' + 6y' + 9y = 0: (r+3)2=0(r + 3)^2 = 0, y=(c1+c2x)e−3xy = (c_1 + c_2x)e^{-3x}.

python · try it yourself
import sympy as sp

x = sp.symbols("x")
y = sp.Function("y")
ode = y(x).diff(x, 2) + 6 * y(x).diff(x) + 9 * y(x)
print(sp.dsolve(ode))
print("x e^{-3x} is a solution:", sp.simplify(ode.subs(y(x), x * sp.exp(-3 * x)).doit()) == 0)
Eq(y(x), (C1 + C2*x)*exp(-3*x))
x e^{-3x} is a solution: True

In software

  • Damped oscillations eαxcos⁡βxe^{\alpha x}\cos\beta x appear in every spring-based UI animation: the "bounciness" setting chooses β\beta, the "damping" chooses α\alpha. A critically damped spring (repeated root) reaches its target fastest without overshoot, which is why smoothing helpers in game engines aim for it.
  • Digital oscillators in synthesizers and in signal processing generate cos⁡βn\cos\beta n with a two-term recurrence whose characteristic roots lie on the unit circle.

Exercises

Exercise 1: Pure oscillation

Solve y′′+16y=0y'' + 16y = 0, y(0)=0y(0) = 0, y′(0)=8y'(0) = 8. What is the period?

Answer

y=2sin⁡4xy = 2\sin 4x, period π2\frac{\pi}{2}.

Solution

r=±4ir = \pm 4i, y=c1cos⁡4x+c2sin⁡4xy = c_1\cos 4x + c_2\sin 4x. y(0)=c1=0y(0) = c_1 = 0 and y′(0)=4c2=8y'(0) = 4c_2 = 8. The period is 2π4\frac{2\pi}{4}.

Exercise 2: Repeated root

Solve y′′−4y′+4y=0y'' - 4y' + 4y = 0, y(0)=1y(0) = 1, y′(0)=3y'(0) = 3.

Answer

y=(1+x)e2xy = (1 + x)e^{2x}.

Solution

(r−2)2=0(r - 2)^2 = 0, y=(c1+c2x)e2xy = (c_1 + c_2x)e^{2x}. y(0)=c1=1y(0) = c_1 = 1; y′=(c2+2c1+2c2x)e2xy' = (c_2 + 2c_1 + 2c_2x)e^{2x}, so y′(0)=c2+2=3y'(0) = c_2 + 2 = 3 and c2=1c_2 = 1.

Exercise 3: Decay envelope (code)

For y′′+0.4y′+4.04y=0y'' + 0.4y' + 4.04y = 0, find α\alpha and β\beta. After how long has the envelope eαxe^{\alpha x} shrunk to 1 %?

Answer

α=−0.2\alpha = -0.2, β=2\beta = 2; after x=5ln⁡100≈23.03x = 5\ln 100 \approx 23.03.

Solution

r=−0.4±0.16−16.162=−0.2±2ir = \frac{-0.4 \pm \sqrt{0.16 - 16.16}}{2} = -0.2 \pm 2i. e−0.2x=0.01e^{-0.2x} = 0.01 at x=ln⁡1000.2x = \frac{\ln 100}{0.2}.

python · try it yourself
import numpy as np
print(np.roots([1, 0.4, 4.04]), round(np.log(100) / 0.2, 2))
[-0.2+2.j -0.2-2.j] 23.03

Test yourself

The roots −2±3i-2 \pm 3i give the general solution…

  1. c1e−2x+c2e3xc_1e^{-2x} + c_2e^{3x}
  2. e−2x(c1cos⁡3x+c2sin⁡3x)e^{-2x}(c_1\cos 3x + c_2\sin 3x)
  3. e3x(c1cos⁡2x+c2sin⁡2x)e^{3x}(c_1\cos 2x + c_2\sin 2x)
  4. (c1+c2x)e−2x(c_1 + c_2x)e^{-2x}

For a double root rr, the second solution is…

  1. e2rxe^{2rx}
  2. x erxx\,e^{rx}
  3. e−rxe^{-rx}
  4. x2erxx^2e^{rx}

3cos⁡2x+4sin⁡2x3\cos 2x + 4\sin 2x has amplitude…

  1. 3
  2. 4
  3. 5
  4. 7