Courses

How to Solve Difference Equations: Video Tutorial

Watch the video
Comments

Solve linear difference equations using characteristic roots, initial conditions and particular solutions. Follow Fibonacci and repeated-root examples and verify each formula.

Illustration for How to Solve Difference Equations: Video Tutorial
On this page

Difference equations, also known as recurrence relations, are similar to differential equations. The difference is that they are defined in discrete domains, such as discrete time or space. They describe a sequence xnx_n in which each term depends on the terms before it.

This video tutorial presents the general form of linear difference equations and recurrence relations. It explains a solution approach based on eigenfunctions and eigenvalues. Several examples are worked out, including the Fibonacci series. The tutorial also covers the case of repeated (non-distinct) roots of the characteristic equation. Finally, it discusses non-homogeneous difference equations through the concepts of general and particular solutions.

Mostapha Kalami Heris teaches the 35 minute 59 second video. Follow the worked recurrences to see how initial conditions determine the constants in each solution.

A first example

The video starts with the simple equation xn=xn−1+1x_n = x_{n-1} + 1. Its solution is xn=n+cx_n = n + c, where the constant cc comes from the initial condition. With x0=0x_0 = 0 the sequence is 0,1,2,3,…0, 1, 2, 3, \dots, and with x0=2x_0 = 2 it is the same sequence shifted by two. As with differential equations, the equation gives the structure of the solution, and the initial values select one solution.

The characteristic equation method

Consider the second order linear equation

xn=α xn−1+β xn−2x_n = \alpha\, x_{n-1} + \beta\, x_{n-2}

with given values of x0x_0 and x1x_1. The key idea is that sns^n plays the same role for differences as este^{st} plays for derivatives. If xn=αxn−1x_n = \alpha x_{n-1}, then trying xn=snx_n = s^n gives sn=αsn−1s^n = \alpha s^{n-1}, so s=αs = \alpha and the solution is αn\alpha^n. In this sense, sns^n is an eigenfunction of the shift (time delay) operation.

For the second order equation, the same trial solution gives the characteristic equation:

s2=αs+βs^2 = \alpha s + \beta

If its roots s1s_1 and s2s_2 are distinct, the general solution is a linear combination of the two eigenfunctions:

xn=c1s1n+c2s2nx_n = c_1 s_1^n + c_2 s_2^n

The constants c1c_1 and c2c_2 come from the initial conditions. The same method works for any order kk: the characteristic equation has degree kk, and its kk roots give the terms of the solution.

Worked example: the Fibonacci sequence

The Fibonacci sequence is defined by F0=0F_0 = 0, F1=1F_1 = 1 and Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2}, which gives 0,1,1,2,3,5,8,13,21,…0, 1, 1, 2, 3, 5, 8, 13, 21, \dots. The characteristic equation is s2=s+1s^2 = s + 1, and its roots are

s1,2=1±52s_{1,2} = \frac{1 \pm \sqrt{5}}{2}

The initial conditions give two linear equations, c1+c2=0c_1 + c_2 = 0 and c1s1+c2s2=1c_1 s_1 + c_2 s_2 = 1. Their solution is c1=1/5c_1 = 1/\sqrt{5} and c2=−1/5c_2 = -1/\sqrt{5}, so

Fn=15[(1+52)n−(1−52)n]F_n = \frac{1}{\sqrt{5}} \left[ \left( \frac{1 + \sqrt{5}}{2} \right)^n - \left( \frac{1 - \sqrt{5}}{2} \right)^n \right]

This closed form is known as Binet’s formula. The video checks it in MATLAB (from 10:40): it finds the roots of the characteristic polynomial with roots, defines the formula as a function of nn, and computes the first terms of the sequence.

The closed form also proves a well known fact. Since ∣s2∣<1|s_2| < 1, the second term vanishes as nn grows, so the ratio Fn/Fn−1F_n / F_{n-1} tends to s1s_1, the golden ratio (1+5)/2(1 + \sqrt{5})/2.

Repeated roots

When the characteristic equation has a repeated root, the formula above does not give enough independent terms. The video uses the example xn=2xn−1−xn−2x_n = 2x_{n-1} - x_{n-2} (from 18:18). Its characteristic equation s2−2s+1=0s^2 - 2s + 1 = 0 has the double root s=1s = 1. As in differential equations, the second term is multiplied by nn:

xn=c1sn+c2 n snx_n = c_1 s^n + c_2\, n\, s^n

With x0=1x_0 = 1 and x1=2x_1 = 2, this gives c1=c2=1c_1 = c_2 = 1 and xn=1+nx_n = 1 + n. For a root repeated three times, the terms are multiplied by 11, nn and n2n^2, and so on.

Non-homogeneous equations

When the equation has a term that does not contain xx, such as xn=2xn−1+nx_n = 2x_{n-1} + n, the solution has two parts (from 20:58):

xn=xn(g)+xn(p)x_n = x_n^{(g)} + x_n^{(p)}

The general solution xn(g)x_n^{(g)} solves the homogeneous equation, here c⋅2nc \cdot 2^n. The particular solution xn(p)x_n^{(p)} is any one solution of the full equation. For the polynomial forcing in this example, the video tries αn2+βn+γ\alpha n^2 + \beta n + \gamma and matches the coefficients of both sides. This gives α=0\alpha = 0, β=−1\beta = -1 and γ=−2\gamma = -2, so xn(p)=−n−2x_n^{(p)} = -n - 2. With x0=1x_0 = 1, the full solution is

xn=3⋅2n−n−2x_n = 3 \cdot 2^n - n - 2

The video starts with a polynomial of higher degree than needed on purpose. A trial polynomial that is too low in degree can lead to inconsistent coefficient equations. If the trial overlaps a homogeneous solution, multiply it by a suitable power of nn before matching coefficients. Extra terms are harmless in this example, but a trial form must still account for repeated roots and overlap.

A final example with both cases

The last example (from 28:47) combines a repeated root with a non-homogeneous term:

xn−4xn−1+4xn−2=n+1x_n - 4x_{n-1} + 4x_{n-2} = n + 1

The characteristic equation s2−4s+4=0s^2 - 4s + 4 = 0 has the double root s=2s = 2, so the general solution is c12n+c2 n 2nc_1 2^n + c_2\, n\, 2^n. The trial αn+β\alpha n + \beta gives the particular solution n+5n + 5. With x0=0x_0 = 0 and x1=5x_1 = 5, the constants are c1=−5c_1 = -5 and c2=9/2c_2 = 9/2, and the solution is

xn=9n⋅2n−1−5⋅2n+n+5x_n = 9n \cdot 2^{n-1} - 5 \cdot 2^n + n + 5

Where difference equations are used

Difference equations appear wherever a quantity is updated in discrete steps: digital signal processing and digital control, the analysis of recursive algorithms in computer science, discrete time models in economics and population models.

Who this tutorial is for

  • Math students
  • Computer science students
  • Engineering students
  • Anyone interested in mathematics

The tutorial needs only basic mathematics.

Check a closed form

Verify the initial conditions first, then substitute the expression into the recurrence. For the Fibonacci example, compute several small integer terms and compare them with direct iteration. Binet’s formula is exact symbolically, but powers and subtraction in floating point arithmetic can lose accuracy for large indices.

Watch online

The video tutorial is available to watch online on the Yarpiz YouTube channel.

How to Solve Difference Equations: Video TutorialWatch on YouTube (opens in a new tab)

How to cite

If you use this code or tutorial in your work, articles or publications, please cite it.

Plain text
Mostapha Kalami Heris, How to Solve Difference Equations: Video Tutorial (YPTDEQ190520), Yarpiz, 2019. https://yarpiz.com/how-to-solve-difference-equations-yptdeq190520
BibTeX
@misc{yarpiz-yptdeq190520,
  author = {{Mostapha Kalami Heris}},
  title = {{How to Solve Difference Equations: Video Tutorial}},
  howpublished = {Yarpiz},
  year = {2019},
  note = {Code YPTDEQ190520},
  url = {https://yarpiz.com/how-to-solve-difference-equations-yptdeq190520}
}

Comments

Sign in or create a free account to join the discussion. No password needed.