First, I found the homogeneous solution: $$r^n - r^{n-1} = 0$$ $$\Rightarrow r = 1$$ So the homogeneous solution is of the form: $$c(1)^n = c$$ Then, to find a particular solution, I "guessed" the form $An+B$, then plug it into the equation: $$An+B = A(n-1)+B+7n$$$$\Rightarrow A = 7n$$ So I assumed the solution would be $c + 7n^2$, then plugging in $a_0 = 4$ gives c =4, so the final solution (incorrect) is $$4 + 7n^2$$
But after comparing with some values, the solution is obviously wrong.
I recently started learning how to solve these linear recurrence relations, and it's really confusing, so hopefully someone can tell me what I'm doing wrong here.
Let $R$ be the right-shift operator:
Then your equation is:
Apply $(R-1)$ to both sides repeatedly until the right-hand side vanishes!
Now we can use the general solution for homogenous linear recurrence relations:
Note that if the right-hand side had a term of the form $n^k c^n$, apply $(D-c)$ to both sides repeatedly and it will vanish.
As for why your attempt is invalid, it is because you made a logical error; if you guess that $a_n = An+B$ for some constant $A,B$, and you get $A = 7n$, which is not a constant, it implies that your guess is wrong. If you guessed $a_n$ is a quadratic in $n$, you would be able to solve for the coefficients. Why you need a quadratic in general is explained completely by the above solution.