# Thread: Difference equations

1. ## Difference equations

Hi!

We just started on this new topic, and I donīt understand how to solve even the first problems.

If someone could walk me through how to solve the following, I would be immensly grateful!

$\displaystyle y_{n+1} - 2y_{n} = n \; \; \; \; n\geq 0 \; \; \; y_{0} = 2$

Thanks!

2. What is the question?

3. ## Hi!

The question was 'How do I solve this equation' basically.
I did however do some research on the web, and ask around a bit, and
I think I got at least a bit hang of it.

If any of the following is incorrect, let me know.

Equation (1):
$\displaystyle y_{n+1} - 2y_{n} = n \; \; \; \; n\geq 0 \; \; \; y_{0} = 0$

The characteristic equation is: $\displaystyle r - 2 = 0 \Rightarrow \, r = 2$
Meaning that the homogenous part of the solution to $\displaystyle y_{n}$
is $\displaystyle y_{h} = A\cdot 2^n$
Now we need to find the particular solution to the equation (1).
Since the right side is a polynomial of degree q = 1, we will look for a
polynomial of the same degree.
$\displaystyle P(n) = C*n + D \; \mbox{where C and D are constants}$

Now we take this polynomial $\displaystyle P(n)$ and put it
into equation (1). Giving us:
$\displaystyle C*n + C + D - 2*C*n - 2*D = n$
Now we have a equation system which can be solved:
$\displaystyle n(-C) = n \; \; \mbox{and} \; \; C-D = 0$
This gives us $\displaystyle C = -1 \; and D=C=-1$
So we get:
$\displaystyle y_{n} = A*2^n -n -1$
And with $\displaystyle y_{0}=0 \; \mbox{we get} \; y_{n} = 2^n - n - 1$

4. Hello, Twig!

Ugh! This is a messy one!

I'll show you a method that I was taught . . .

$\displaystyle y_{n+1} \:=\:2y_n + n \qquad n\geq 0 \qquad y_0 = 2$
Crank out the first few terms . . .

$\displaystyle \begin{array}{ccccccc}& y_0 &=& 2 \\ n=0\!: & y_1 &=& 2(2) + 0 &=& 4\\ n = 1\!: & y_2 &=& 2(4) + 1 &=& 9 \\ n=2\!: & y_3 &=& 2(9) + 2 &=& 20 \end{array}$

We have been given: . .$\displaystyle y_{n+1} \:=\:2y_n + n$. . . . . .[1]

Write the "next" term: .$\displaystyle y_{n+2} \:=\:2y_{n+1} + (n+1)$ .[2]

Subtract [1] from [2]: .$\displaystyle y_{n+2} -y_{n+1} \:=\:2y_{n+1} - 2y_n + 1 \quad \Rightarrow \quad y_{n+2} -3y_{n+1} + 2y_n \:=\:1$

Let $\displaystyle y_n = X^n$
. .
We assume that the general term is an exponential.

Then we have: . . .$\displaystyle X^{n+2} - 3X^{n+1} + 2X^n \:=\:1$ .[3]

"Next" equaton: .$\displaystyle X^{n+3} - 3X^{n+2} + 2X^{n+1} \:=\:1$ .[4]

Subtract [3] from [4]: .$\displaystyle X^{n+3} - 4X^{n+2} + 5X^{n+1} - 2X^n \:=\:0$

Divide by $\displaystyle X^n\!:\;\;X^3 - 4X^2 + 5X - 2 \:=\:0$

This factors: .$\displaystyle (X - 1)(X - 1)(X - 2) \:=\:0$

. . and has roots: .$\displaystyle X \;=\;1,\:1,\:2$

The general form is: .$\displaystyle y(n) \;=\;A + Bn + C\cdot2^n$

Plug in the first three terms:

. . $\displaystyle \begin{array}{ccccc}y(0) = 2\!: & A + C &=& 2 & {\color{blue}[5]}\\ y(1) = 4\!: & A + B + 2C &=& 4 & {\color{blue}[6]}\\ y(2) = 9\!: & A + 2B + 4C &=& 9 & {\color{blue}[7]} \end{array}$

$\displaystyle \begin{array}{cccccc}\text{Subtract {\color{blue}[6] - [5]}:} & B + C &=& 2 & {\color{blue}[8]}\\ \text{Subtract {\color{blue}[7] - [6]}:} & B + 2C &=& 5 & {\color{blue}[9]}\end{array}$

Subtract [9] - [8]: .$\displaystyle C \:=\:3 \quad\Rightarrow\quad B \:=\:-1 \quad\Rightarrow\quad A \:=\:-1$

Therefore: .$\displaystyle \boxed{ y(n) \;=\;-1 - n + 3\!\cdot\!2^n}$

Is there a better way? . . . I hope so!
.

5. ## Hi soroban

Hi!

Yes, this can get quite messy.
I read through your solution and then tried to compare it to mine.
I couldnīt really figure any advantages/disadvantages with a certain method though..
The method I was taught today (I made a post higher up this page) with a different solution. I think itīs correct, and it felt like less steps.
The similarities with differential equations becomes quite clear by doing this.
You are using a "characteristic equation", just as you solve equations like
$\displaystyle y'' + y' + y = f(x)$
Then you look for a particular solution, that satisifies just this equation.
And the general solution becomes:
$\displaystyle y_{n} = y_{h} + y_{p}$

Thanks for your help!