I want to solve the following recurrence relation, But I can't get rid of the complex numbers appearing.
$a_n - 2a_{n-1} + 2a_{n-2} = 0, a_0 =1, a_1 = 2$
First, I let $a_n = cr^n$, then I find the characteristic equation that is $r^2-2r +2 = 0$ Now this is the same as $(r-1)^2 + 1 = 0$ and so we have two complex roots $r=1-i,1+i$
So $a_n = A(1-i)^r + B(1+i)^n$. Now I convert these two complex numbers two polar coordinates because they are easier to work with and so $$1-i = \sqrt{2}(\cos(\frac{-\pi}{4}) + i\sin(\frac{\pi}{4}))$$ and $$1+i =\sqrt{2}(\cos(\frac{\pi}{4}) + i\sin(\frac{\pi}{4}))$$
Now I have that $$a_n=A(\sqrt{2}(\cos(\frac{-\pi}{4}) + i\sin(\frac{\pi}{4}))^r + B\sqrt{2}(\cos(\frac{\pi}{4}) + i\sin(\frac{\pi}{4}))^r$$
Which is $$\sqrt{2}^nA(\cos(\frac{-\pi}{4}) + i\sin(\frac{\pi}{4}))^r + \sqrt{2}^nB(\cos(\frac{\pi}{4}) + i\sin(\frac{\pi}{4}))^r$$
But Now I get stuck on how to find $A$ and $B$, ... I don't know how to tackle it here.
Hint:
The general solution can be written
$$a_n=(A\cos(n\frac\pi4)+B\sin(n\frac\pi4))\sqrt2^n.$$
Plugging the initial conditions, you get
$$a_0=A=1.$$
$$a_1=(\frac A{\sqrt2}+\frac B{\sqrt2})\sqrt2=2.$$