I'm trying to freshen up my knowledge about inhomogeneous recurrence relations.
Im currently trying to solve $$a_n-3a_{n-1}=2n-7$$ $$\forall n>1, a_1=4$$
I have a question regarding a specific step in my solution, and that is the second term in the inhomogeneous part: $-7$, and how to solve it.
From what I learned, when dealing with constant term, I simply set $$a_n=D$$ where $$D \in \mathbb R$$ as long as $1$ is not a root in our homogenous part, where it is not in my case.
This gives me following $$a_n-3a_{n-1}=-7 \Rightarrow D-3D=-7$$
However, this ends up in the wrong answer, which is 2.
Would anyone mind helping me out, what part of the solution I'm not getting?
The part that seems strange to me is that when dealing with constant, and solving it how I learned, it does not take into consideration if we have $a_n$ or $a_{n-1}$ and so on, since the constant does not depend on $n$?
$\textbf{EDIT: My solution below}$
$\bullet$ Homogenous part
$$a_n-3a_{n-1}=0$$ $$r-3=0$$ $$r=3$$
$$\Rightarrow a_{n,h}=A \cdot (3)^n$$
$\bullet$ Inhomogeneous part: $2n$
$2n$ polynomial of degree 1 so we set $a_n=Bn+C$ to solve for this part.
$$a_{n}=Bn+C$$
$$\Rightarrow a_n-3a_{n-1}-2n=Bn+C-3[B(n-1)+C]-2n$$
$$\Rightarrow B=-1, C=0$$
$$\Rightarrow a_{n,p1}=-n$$
$\bullet$ Inhomogeneous part: $-7$
$-7$ polynomial of degree 0 so we set $a_n=D$
$$a_n=D$$
$$\Rightarrow D-3D=-7$$ $$\Rightarrow D=\frac{7}{2}$$
$$\Rightarrow a_{n,p2}=\frac{7}{2}$$
So $a_n = A \cdot (3)^n - n + \frac{7}{2}$
Which is wrong.
Is it wrong handle these inhomogeneous part by themself? Is that where it fails? Please, explain to me what I'm doing wrong...
Thanks!
$a_n = Cn + D + A\cdot 3^n$
$a_{n-1} = C(n-1) + D + A\cdot 3^{n-1}$
The constant term of $a_n - 3a_{n-1}$ is $D - 3D + 3C$, not $D - 3D$
For another example with constant term, $a_n -3 a_{n-1}=-2$ with $a_1 =4$.
Since the inhomogeneous part is a constant term, you can substitute $a_{n,p} =D$ to get the particular solution $a_{n,p}=1$ and $a_n=1+3^n$.
Edited for your last update
To find the general solution of $a_n-3a_{n-1}=2n-7$, decompose $a_n$ into the sum of homogenous and particular solution. $$a_n = a_{n,h} + a_{n,p}$$
The particular solution is required to satisfy the relation (2).
Using your "Inhomogeneous part: 2n", $\Rightarrow a_n-3a_{n-1}-2n=Bn+C-3[B(n-1)+C]-2n = (-2B-2)n + (3B-2C)$
From (2), we get \begin{cases} -2B-2 &= 0\\ 3B-2C &= -7 \end{cases} $$B=-1, C=2$$
So $a_{n,p}= - n +2$.
Then continuing using $a_1=4$ and $a_{n,h}= A\cdot 3^n$, you get $a_{1,p}= - 1 +2=1$, $a_{1,h}= 3A$.
Since $a_1=a_1^h+a_1^p$, $$4=3A+1 \implies A=1$$
the general solution is $a_n= 3^n - n +2$.
Your approach
Now to split up the particular solution into two part $$a_n = a_{n,h} + a_{n,p1} + a_{n,p2}$$
In your "Inhomogeneous part: 2n", you make a minor mistake. $\Rightarrow a_n-3a_{n-1}-2n=Bn+C-3[B(n-1)+C]-2n= (-2B-2)n +(3B-2C)$
From (2), \begin{cases} -2B-2 &= 0\\ 3B-2C &= 0 \end{cases} $$B=-1, C=\frac{-3}{2}$$
So $a_{n,p}=a_{n,p1}+a_{n,p2}=(-n+\frac{-3}{2})+\frac{7}{2} =-n+2$.