I have two problems that I've been working on, and I want to make sure that my work is correct. I'm simply finding unique solutions to non-homogeneous equations, as shown below.
(1) an - 2an - 1 = 5 with a0 = 1
(2) an - 2an - 1 = 2n with a0 = 1
My work:
(1) For our general solution, we use an - 2an - 1 = 0.
This gives us r - 2 = 0, where r = 2, and so our root is 2. Our general function is h(n) = k(2)n where k is a constant.
Try p(n) = c. So we need p(n) - 2p(n-1) = 5.
c - 2c = 5
-c = 5
c = -5
So our general solution an = h(n) + p(n) is:
an = k(2)n + (-5). Our initial condition is a0 = 1.
1 = k(2)0 + (-5)
1 = k + (-5). So our k = 6.
Our unique solution is an = 6(2)n + (-5).
(2) The general solution is is the same as above, with root 2 and h(n) = k(2)n.
But for p(n), trying c2n gives us 0 = 2n, and so we add n.
p(n) = cn2n
cn2n - c(n-1)2n = 2n
c = 1
So we now have h(n) + p(n) = k(2)n + 1.
1 = a0 = k(2)0 + 1
1 = k + 1. So our k = 0. Our unique solution should be:
an = 0(2)n + 1.
You could make life simpler for the first case.
Consider $$a_n-2a_{n-1}=b\qquad \text{with}\qquad a_1=c$$ and rewrite the recurrence as $$(a_n-b)-2(a_{n-1}-b)=0$$ So, define $d_n=a_n-b$ to get $$d_n-2d_{n-1}=0\qquad \text{with}\qquad d_1=c+b$$ and you know how to solve it.