<s>[INST] Solving the recurrence relation with repeated roots (2 in $a_g$ and same root in $a_p$) $$a_{n+2} - 6a_{n+1} + 9a_n = 3^n$$
Solving for this recurrence can be done by the following:
1) solve for the recurrence relation $a_g$ such that: $a_{n+2} - 6a_{n+1} + 9a_n = 0$
then,
2) $a_h$ such that: $a_{n+2} - 6a_{n+1} + 9a_n = 3^n$
then,
3) $a_n = a_g + a_p$
Solving for the $a_g$ I have the solution: $C_1(3)^n + C_2n(3)^n$, where the extra $n$ is due to the repeated root.
Now, solving for $a_p$ I use the trial solution $a_n = A(3^n)\cdot(n^2)$, where $n^2$ is due to the third root.
This is the part I'm having trouble with now: when i substitute for $a_{n+2}$ is it $A\cdot3^{n+2}\cdot(n+2)^2$ and then similarly I would substitute for $6a_{n+1}$ which should be $6A\cdot3^{n+1}\cdot(n+1)^2$ and $9a_n$ should be $9A\cdot 3^n \cdot n^2$
Then, I need to solve:
$$(A\cdot3^{n+2}\cdot(n+2)^2) - (6A\cdot 3^{n+1} \cdot (n+1)^2) + (9A\cdot 3^n \cdot n^2) = 3^n$$
Would this be the correct approach to solve for $a_p$?
 [/INST] Writing, as you did,
$$(A\cdot3^{n+2}\cdot(n+2)^2) - (6A\cdot 3^{n+1} \cdot (n+1)^2) + (9A\cdot 3^n \cdot n^2) = 3^n$$ Expanding the lhs, you should end with $$2 A\, 3^{n+2}=3^n\implies 18 A=1\implies A=\frac 1 {18}$$ But, as said in comments, there is a faster way to solve the problem.
</s>