I had this Recurrence Relation problem:
$a_{n+2} + a_{n+1} - 12a_n = 0$
And I solved in a form like this $a_n = A(r_1)^n + B(r_2)^n$
$r^{n+2} + r^{n+1} - 12r^n = 0$ -> Divided the hole eqation by the lowest $r$
Result of this:
$r^2+r -12 = 0$
And then i found the roots: $r_1 = 3$ and $r_2=-4$
And the solution of this problem is: $a_n = 2/7*(3)^n -7/2*(-4)^n $
The next one, is what i don´t get. It is exact like this one in stead it is equal to $3^n$, like is: $a_{n+2} + a_{n+1} - 12a_n = 3^n$
How do I solve this one ?
You didn't mentioned the initial conditions of the recurrence relation, but by the solution that you obtained $$a_n = \frac{2}{7}(3)^n − \frac{7}{2}(−4)^n$$ one can infer the initial conditions $$a_0 = -\frac{45}{14} \;\;\;\;\;\;\;\; a_1 = \frac{104}{7}$$ That made me think that maybe there is a typo and you intended $$a_n = \frac{2}{7}(3)^n − \frac{2}{7}(−4)^n$$ so $$a_0 = 0 \;\;\;\;\;\;\;\; a_1 = 2$$ I'll solve both cases just in case.
What you are trying to do is to solve a non-homogeneous linear recurrence relation. $$ a_{n+2} + a_{n+1} - 12a_{n} = 3^n = f(n)$$ The first step is to solve the the associated homogeneous linear recurrence: $$ a_{n+2} + a_{n+1} - 12a_{n} = 0 $$ The associated characteristic polynomial is $$r^2 + r - 12$$ with roots $r_1 = 3$ and $r_2 = -4$.
Hence the homogeneous solution is of the form $$h_n = A 3^n + B(-4)^n$$
Instead to plug-in the initial conditions, we now need to find a particular solution to the non-homogeneous equation.
As $f(n) = 3^n$, we would guess a solution of the form $g_n = C 3^n$, where $C$ is a constant. But $3$ is a root of characteristic polynomial of the homogeneous part, hence the correct guess is $g_n = C n 3^n$. We now find $C$ by plugging it on the recurrence:
$$ C(n+2)3^{n+2} + C(n+1)3^{n+1} - 12Cn3^n = 3^n$$ $$ 9C(n+2) + 3C(n+1) - 12Cn = 1 $$
have to hold for all $n$, in particular for $n = 0$, hence:
$$ 18 C + 3 C = 1 \Rightarrow C = \frac{1}{21} $$
Hence we have the particular solution $g_n = \frac{1}{21} n 3^n$.
Therefore, the final solution is of the form: $$ a_n = h_n + g_n = \left( A + \frac{n}{21} \right) 3^n + B(-4)^n$$ where the constants $A$ and $B$ are to be determined from the initial conditions through the linear system:
$$\begin{cases} a_0 = A + B \\ a_1 = 3A - 4B + \frac{1}{7} \end{cases}$$
Using $a_0 = -\frac{45}{14}$ and $a_1 = \frac{104}{7}$ we have: $A = \frac{13}{49}$ and $B = - \frac{341}{91}$ hence the solution:
$$ a_n = \left( \frac{13}{49} + \frac{n}{21} \right) 3^n - \frac{341}{91}(-4)^n $$
Using $a_0 = 0$ and $a_1 = 2$ we have: $A = \frac{13}{49}$ and $B = - \frac{13}{49}$ hence the solution:
$$ a_n = \left( \frac{13}{49} + \frac{n}{21} \right) 3^n - \frac{13}{49}(-4)^n $$
If you had another set of initial values in mind, you can just plug in and find $A$ and $B$.