An integer sequence is defined by $$a_n = 2 a_{n-1} + a_{n-2}$$ $\quad (n > 1) \quad a_0 = 0,a_1 = 1$. Find a closed form expression for this sequence.
I got the characteristic equation to be $$x^2-2x-1=0$$ which has the roots $1+\sqrt{2},1 - \sqrt{2}$. I'm not sure, how to get the actual formula from this information afterwards, please help.
The main idea how the characteristic polynomial is derived is finding the solution as a power function: $$a_n=r^n$$ Then substitute into the recurrence relation: $$a_n =2a_{n-1}+a_{n-2} \Rightarrow r^n = 2r^{n-1} + r^{n-2}$$ $$r^{n-2}\left(r^2 - 2r - 1\right)=0 \Rightarrow r = 1\pm\sqrt{2}$$ The next idea is to find out that if $a_n=r_1^n$ is a solution and $a_n=r_2^n$ is also a solution then their linear combination $a_n=C_1r_1^n+ C_2r_2^n$ is a solution too. Here we have $r_{1,2} = 1\pm \sqrt{2}$. The coefficients $C_1$ and $C_2$ can be obtained from $a_0$ and $a_1$ values: $$a_0 = C_1 + C_2=0$$ $$a_1=C_1\left(1-\sqrt{2}\right) + C_2\left(1+\sqrt{2}\right) = 1$$ Solving this linear system we get: $$C_1 = -\frac{\sqrt{2}}{4}, C_2 = \frac{\sqrt{2}}{4}$$ Now we get the answer: $$a_n = \frac{\sqrt{2}}{4}\left[\left(1+\sqrt{2}\right)^n - \left(1-\sqrt{2}\right)^n\right]$$