# Second order difference equation with initial conditions

I have been given this difference equation and asked to solve it:

$$y_{n+2} + 2y_{n+1} -3y_{n} = 5 \cdot 2^n + 12$$

where $y_{0} = 7$ and $y_{1} = -9$

I know it sounds weird but we have never actually been taught difference equations. I've looked on the internet and from what I've read i think it's a second order equation but apart from that I have no idea where to even start. Can anyone help me?

-

Follow Wilf's "generatingfunctionology". Define the ordinary generating function: $$Y(z) = \sum_{n \ge 0} y_n z^n$$ Using the properties of the generating function: \begin{align*} \frac{Y(z) - y_0 - y_1 z}{z^2} + 2 \frac{Y(z) - y_0}{z} - 3 Y(z) &= 5 \cdot \frac{1}{1 - 2 z} + 12 \cdot \frac{1}{1 - z} \\ Y(z) &= \frac{1}{1 - 2 z} - 2 \cdot \frac{1}{1 - z} + 3 \cdot \frac{1}{(1 - z)^2} + 5 \cdot \frac{1}{1 + 3 z} \end{align*} Thoses are mostly geometric series: \begin{align*} y_n &= 2^n - 2 + 3 \binom{-2}{n} + 5 \cdot (-3)^n \\ &= 2^n + 5 \cdot (-3)^n + 3 n + 1 \end{align*}
Start by solving homogenous equation $y_{n+2}+2y_{n+1}-3y_n=0$. To do so, write the characteristic polynomial (it will also be of order two), and its roots $\lambda_1$ and $\lambda_2$ will give you the idea of the answer, $y_n= c_1(\lambda_1)^n+c_2(\lambda_2)^n +$ something, which can be guessed from the expression on the RHS. The initial conditions are used to identify the coefficients.