How to find recurrence relation of a given solution. Determine values of the constants $A$ and $B$ such that $a_n=An+B$ is a solution of the recurrence relation $a_n=2a_{n-1}+n+5$.
I know that the characteristic equation is $r-2 = 0$ which has the root $r = 2$.
Usually I find constants $A$ and $B$ by $a_n=Ar^n+Br^n$. It
looks like I cannot apply this here because $a_n=An+B$ is given.
The solution is $A = -1$ and $B = -7$. I don't know how to get this answer.
Can anyone help me please.

You have $\forall n ~:~ a_n = 2~a_{n-1} + n + 5$ and $\forall n ~:~ a_n = A~n+B$.  So construct the equations
$$\begin{array} {c|cc}
n & a_n = 2~a_{n-1} + n + 5 & a_n = A~n+B \\ \hline
1 & a_1 = 2~a_{0} + 6 & a_1 = A+B \\ 
2 & a_2 = 2~a_{1} + 7 & a_2 = 2~A+B \\ 
3 & a_3 = 2~a_{2} + 8 & a_3 = 3~A+B \\ 
\end{array}$$
Simple system of 6 linear equations, 6 variables.  Solve for $A$ and $B$.

Or you can be a bit more indirect: Plug $\forall n ~:~ a_n = A~n+B$ into $\forall n ~:~ a_n = 2~a_{n-1} + n + 5$
$$\forall n ~:~ A~n + B = 2~A~(n-1) + 2~B + n + 5$$
Plug $n=0$ in to get
$$B = 2~B - 2A + 5$$
Plug $n=1$ in to get
$$A+B = 2B + 1 + 5$$
So 2 equations, 2 variables.
