<s>[INST] Solve a non-homogeneous recurrence relation I need to solve this equation. I know how to solve the homogeneous side, but when I get to the non-homogeneous it becomes a problem.
$$ a_n = 7a_{n-1}- 10a_{n-2}+5^n-6$$
So far I have this
$$ a_n = 7a_{n-1}- 10a_{n-2}$$
$$ \frac{r^n}{r^{n-2}} = \frac{7r^{n-1}}{r^{n-2}}- \frac{10r^{n-2}}{r^{n-2}}$$
Then the characteristic equation for the homogeneous part is
$$ r^2 = 7r - 10 $$ where $  r_1=2, r_2=5$.
So the homogeneous part is
$$ a_n^h=\alpha_1r_1^n + \alpha_2r_2^n = \alpha_1(2)^n+\alpha_2(5)^n$$
and I think the equation of the non-homogeneous part should be
$$ a_n^p = A(5^n)n+B$$
$$An(5^n)+B = 7(A(5^{n-1})(n-1)+B) -10(A(5^{n-2})(n-2)+B)$$
$$An(5^n)+B = 7(A(5^{n-1})(n-1))+7B-10(A(5^{n-2})(n-2))-10B$$
And I know there's a way to find $A$ and $B$ easily with like terms, but I don't know if I can use it here or how to use it.
 [/INST] The original recurrence relation is
$$a_n = 7a_{n-1} - 10a_{n-2} + 5^n - 6 \tag1$$
Assume particular solution
$$a_n^p = An5^n + B \tag2$$
Substitute $(2)$ into $(1)$:
\begin{align}
An5^n + B &= 7(A(n-1)5^{n-1} + B) - 10(A(n-2)5^{n-2} + B) + 5^n - 6 \\
&= 7An5^{n-1} - 7A5^{n-1} + 7B - 10An5^{n-2} + 20A5^{n-2} -10B + 5^n - 6 \\
&= \left(\frac{7}{5}-\frac{10}{25}\right)An5^n + \left(-\frac{7}{5}+\frac{20}{25}\right)A5^n -3B + 5^n - 6 \\
&= An5^n + \left(1-\frac{3A}{5}\right)5^n - 3B - 6
\end{align}
Comparing like terms yields:
\begin{align}
0 &= 1-\frac{3A}{5} \\
B &= -3B - 6 
\end{align}
So $A=5/3$ and $B=-3/2$, which implies particular solution
$$a_n^p = \frac{5}{3}n5^n - \frac{3}{2} = \frac{n5^{n+1}}{3} - \frac{3}{2}$$
and general solution
$$a_n = a_n^h + a_n^p = \alpha_1 2^n+\alpha_2 5^n + \frac{n5^{n+1}}{3} - \frac{3}{2}$$
Use any two provided initial conditions (which you did not specify) to solve for $\alpha_1$ and $\alpha_2$.
</s>