Mathwords logoMathwords

Linear Difference Equation of Second Order — Formula & Example

A linear difference equation of second order is a rule that gives each term of a sequence as a weighted sum of the two terms just before it. It is the step-by-step, whole-number version of a second-order linear differential equation.

A second-order linear homogeneous difference equation with constant coefficients has the form an+2+p an+1+q an=0a_{n+2} + p\,a_{n+1} + q\,a_n = 0 for all integers n≥0n \ge 0, where pp and qq are constants and q≠0q \neq 0. Its solutions form a two-dimensional vector space. Each solution is fixed uniquely by two initial values a0a_0 and a1a_1. Replacing the 0 on the right with a given sequence fnf_n makes the equation nonhomogeneous.

Key Formula

an+2+p an+1+q an=0⟹r2+p r+q=0a_{n+2} + p\,a_{n+1} + q\,a_n = 0 \quad\Longrightarrow\quad r^2 + p\,r + q = 0
Where:
  • ana_n = The nth term of the sequence
  • p,qp, q = Constant coefficients, with q ≠ 0 so the equation is truly second order
  • rr = A root of the characteristic equation. Distinct roots give an=Ar1 n+Br2 na_n = A r_1^{\,n} + B r_2^{\,n}. A repeated root gives an=(A+Bn) rna_n = (A + Bn)\,r^n.
  • A,BA, B = Constants found from the initial values a0a_0 and a1a_1

Worked Example

Problem: Solve an+2=an+1+6ana_{n+2} = a_{n+1} + 6a_n with a0=2a_0 = 2 and a1=1a_1 = 1. Find ana_n in closed form.
Step 1: Try an=rna_n = r^n. Substitute and divide by rnr^n, which is nonzero for r≠0r \neq 0. This gives the characteristic equation. Then factor it.
r2−r−6=0  ⟹  (r−3)(r+2)=0  ⟹  r=3 or r=−2r^2 - r - 6 = 0 \implies (r-3)(r+2) = 0 \implies r = 3 \text{ or } r = -2
Step 2: The roots are real and distinct, so the general solution combines the two powers. The negative root makes its term flip sign at every step.
an=A⋅3n+B⋅(−2)na_n = A\cdot 3^n + B\cdot(-2)^n
Step 3: Set n=0n = 0 and n=1n = 1 to use the initial values. From the first equation, B=2−AB = 2 - A. Substitute this into the second: 3A−2(2−A)=13A - 2(2 - A) = 1, so 5A=55A = 5.
A+B=2,3A−2B=1  ⟹  A=1,  B=1A + B = 2, \quad 3A - 2B = 1 \implies A = 1,\; B = 1
Answer: an=3n+(−2)na_n = 3^n + (-2)^n. Check: the recurrence gives a2=1+6(2)=13a_2 = 1 + 6(2) = 13, and the formula gives 9+4=139 + 4 = 13.

Why It Matters

Discrete math and computer science courses use these equations to find exact running times of recursive algorithms. They also produce Binet's closed formula for the Fibonacci numbers. In numerical methods, replacing y′′y'' with finite differences turns a second-order ODE into this kind of equation. You can then judge whether the computed solution stays stable.

Common Mistakes

Mistake: Carrying the ODE habit over and writing the solution as Ae3n+Be−2nA e^{3n} + B e^{-2n}.
Correction: In a difference equation, the trial solution is rnr^n, not erne^{rn}. Each root rr contributes rnr^n directly. A negative root such as −2-2 is allowed, and it gives the oscillating term (−2)n(-2)^n.

Related Terms