I'm trying to get a closed form for the non-homogeneous linear recurrence $$f(n)=f(n-1)-9f(n-2)+9f(n-3)+5$$ The initial values are $$f(0) = 1,\ f(1) = 1,\ f(2) = 2$$ But I'm having trouble when I found imaginary numbers.
Let's see: I know there are homogeneous linear recurrences associated to this non-homogeneous one, in this case it is $f(n) = f(n-1) - 9f(n-2) + 9f(n-3)$. Its characteristic equation is $x^3-x^2+9x-9 = 0$.
On the other hand, the non-homogeneous part is $1^n\cdot 5$ so, as I've been told, there is a homogeneous linear recurrence that is similar to the first one (non-homogeneous) and that has the characteristic equation $(x-5)(x^3-x^2+9x-9)$ but, when I find the roots of the second polynomial, I get $(x-1)(x^2+9)$ and this second part has no real roots... so...
I don't know if it is correct to write the homogeneous linear recurrence as: $$f(n) = a + 5^n b + (3i)^n c + (-3i)^n d$$
Actually, I have no idea of how I should do this problem from this moment onward. Could you help me? Thank you!
Using method of generating functions.
Let us write equation for general term: $$ f_n=f_{n-1}-9f_{n-2}+9f_{n-3}+5-4[n=0]-5[n=1]+5[n=2] $$ Make transform to $G(z):$ $$ G=zG-9z^2G+9z^3G+\frac{5}{1-z}-4-5z+5z^2\\ G=\frac{5}{(1-z)(1-z+9z^2-9z^3)}-\frac{4+5z-5z^2}{1-z+9z^2-9z^3} $$ In form of partial fractions: $$ G=\frac{36+81z}{10(1+9z^2)}+\frac{9}{10(1-z)}+\frac{1}{2(1-z)^2}-\frac{36+86z}{10(1+9z^2)}-\frac{4}{10(1-z)}\\ G=\frac{-5z}{10(1+9z^2)}+\frac{5}{10(1-z)}+\frac{1}{2(1-z)^2}\\ G=\frac{-z}{2(1+9z^2)}+\frac{1}{2(1-z)}+\frac{1}{2(1-z)^2} $$
And one more partial fraction for first addendum: $$ G=\frac{3i}{18}\left[\frac{A}{1+3iz}-\frac{A^*}{1-3iz}\right]+\frac{1}{2(1-z)}+\frac{1}{2(1-z)^2}$$
Where $A=A^*=-\frac{1}{2}$ Now apply inverse transform: $$ f(n)=\frac{i}{6}A(-3i)^n-\frac{i}{6}A^*(3i)^n+\frac{1}{2}+\frac{1}{2}(n+1)\\ f(n)=\frac{1}{2}+\frac{1}{2}(n+1)+\frac{i}{12}(3i)^n-\frac{i}{12}(-3i)^n $$ As it can be ssen, you had almost proper equation, with only term $(+5)$ mistreated. Reason: we add it, not multiply. By the way, important property: constants $c$ and $d$ must be self-conjuncted, because $f(n)$ is real-valued sequence.
And finally, let us rewrite expression a bit. $$ f(n)=\frac{1}{2}+\frac{1}{2}(n+1)+\frac{i}{12}(3i)^n\left[1-(-1)^n\right]\\ f(n)= \begin{cases} 1+k,\quad \quad \quad \quad \quad \text{for n=2k} \\ \frac{3}{2}+k-\frac{(-9)^k}{2},\quad \text{for n=2k+1} \end{cases} $$