# Find the $n$th term of sequence in the form of $a_{n+2}=ba_{n+1}+ca_n+d$ [duplicate]

$$a_1=1$$, $$a_2=3$$, $$a_{n+2}=a_{n+1}-2a_n-1$$

How do you solve this? I only solve the sequence in the form $$a_{n+2}=ba_{n+1}+ca_n$$ before by writing it in $$x^2-bx-c=0$$ but for this I don't know how to. Please help

• it might also be fun/ helpful to find the generating series of it and develop a closed form using that – Control May 24 at 9:50

The method is fairly similar, you suppose the solution is composed of 2 parts, namely the particular solution (which takes care of the constant and the homogenous solution which is the case you know how to solve. $$a_{n} = a^{p}_{n} + a^{h}_{n}$$ To solve for $$a_{n}^{p}$$ say it is some constant $$c$$ and plug it in to the reccurence relation. $$c = c - 2c - 1$$ $$2c = -1$$ $$c = -\frac{1}{2}$$ For the homogenous solution suppose the $$-1$$ isn't there, you get the following reccurence relation: $$a_{n+2} = a_{n+1} -2a_{n}$$ Which has the characteristic polynomial: $$x^2 - x + 2 = 0$$ $$x_{1, 2} = \frac{1 \pm \sqrt{1 - 8}}{2} = \frac{1 \pm i \sqrt{7}}{2}$$ Then our solution has the following form: $$a_{n} = \alpha(\frac{1 - i \sqrt{7}}{2})^n + \beta(\frac{1 + i \sqrt{7}}{2})^n - \frac{1}{2}$$ All that remains is to solve for $$\alpha, \beta$$ by evaluating it at $$n=1, 2$$.