I am trying to solve one recurrence relation
$a_n - 2a_{n-1} + 2a_{n-2} = 0, a_0 =1, a_1 = 2$
Now I was able to get the characteristic equation $r^2 -2r + 2 = 0$ , I get that $r=1 \pm i$ and everything and now I got that
$$\sqrt{2}^nA(\cos(\frac{-\pi}{4}) + i\sin(\frac{-\pi}{4}))^n + \sqrt{2}^nB(\cos(\frac{\pi}{4}) + i\sin(\frac{\pi}{4}))^n$$
which should be the same as
$$\sqrt{2}^nA(\cos(\frac{-n\pi}{4}) + i\sin(\frac{-n\pi}{4})) + \sqrt{2}^nB(\cos(\frac{n\pi}{4}) + i\sin(\frac{n\pi}{4}))$$
Now How do I go from here and make this imaginaring number $i$ disappear to get ? I feel I missing one manipulation to get the result.
$$a_n=(A\cos(n\frac\pi4)+B\sin(n\frac\pi4))\sqrt2^n.$$
Using the initial conditions $$a_0 =1 = \sqrt{2}^0A(\cos(0) + i\sin(0)) + \sqrt{2}^0B(0) + i\sin(0))$$
Which is equal to
$$a_0 =1 = A(1 + 0) + B(1 + 0)$$
and so
$$1 = A + B$$
Now using $a_1 = 2$ we get that
$$a_1 =2 = \sqrt{2}A(\frac{1}{\sqrt{2}} -\frac{1}{\sqrt{2}}) + \sqrt{2}B(\frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}})$$
which is $2 = 2B$ and hence $B = 1$
Now going back to $1 = A + B$ we get that $A=0$ right ?
and then we have $A=0, B=1$
Then what ?
You don't make them disappear, they should disappear on their own once you use the initial conditions $a_0=1,a_1=2$ to find $A$ and $B$. If everything is done correctly the imaginary terms will cancel at that point.
To make things easier for yourself in this specific case, you might note that $\frac{7n\pi}{4}$ is the same angle as $-\frac{n\pi}{4}$, at least as far as $\sin$ and $\cos$ is concerned.
Full solution:
You've figured out the characteristic equation and its solutions $1 \pm i$. That means that the general solution is of the form $$ a_n = A(1+i)^n + B(1-i)^n\\ = \sqrt2^nA\left(\cos\left(\frac{n\pi}4\right) + i\sin\left(\frac{n\pi}4\right)\right) + \sqrt2^nB\left(\cos\left(\frac{n\pi}4\right) - i\sin\left(\frac{n\pi}4\right)\right) $$ I prefer the top one, personally, without the $\sin$ and $\cos$. However, if you were told to find $a_{100}$ or some such, the trigonometric solution is superior in calculation complexity; since nothing is raised to any power, there are no binomial coefficients or cancelling terms to keep track of. There is also the simplification we do at the end of this answer which is possible because of the real-valued initial conditions; it is a lot simpler in the trigonometric case.
At this point we need to use the initial conditions in order to find our specific solution. We had $a_0 = 1$ and $a_1 = 2$. The first one gives us $$ 1 = a_0 = A + B $$ while the second one gives us $$ 2 = A(1 + i) + B(1 - i) = A+B + i(A - B) $$ Here it is tempting to say that it clearly has no solutions, since $A + B$ cannot be both $1$ and $2$ at the same time. (I was perplexed myself for a minute.) However, there is no problem if we allow $A$ and $B$ to be complex. We solve is as we would any system of two unknowns. The first equation says that $A = 1-B$, so we insert that into the second equation and get $$ 2 = 1-B + B + i(1-B-B)\\ 1 = (1-2B)i\\ i = 2B-1\\ \frac12 + \frac i2 = B $$ which gives $A = \frac12 - \frac i2$.
The solution to your problem is therefore $$ a_n = \left(\frac12 - \frac i2\right)(1+i)^n + \left(\frac12 + \frac i2\right)(1-i)^n\\ = \sqrt2^n\left(\frac12 - \frac i2\right)\left(\cos\left(\frac{n\pi}4\right) + i\sin\left(\frac{n\pi}4\right)\right) + \sqrt2^n\left(\frac12 + \frac i2 \right)\left(\cos\left(\frac{n\pi}4\right) - i\sin\left(\frac{n\pi}4\right)\right) $$ and if we multiply out the last expression, and gather the real and imaginary parts, we get $$ \sqrt2^n\left(\cos\left(\frac{n\pi}{4}\right) + \sin\left(\frac{n\pi}{4} \right)\right) $$ which is to say, the imaginary terms cancel out (this would've been difficult if we used $\frac{7n\pi}4$ as the angle of the second characteristic solution instead of $-\frac{n\pi}{4}$). If the initial conditions had been complex values, then $A$ and $B$ would've been such that we couldn't have cancelled the imaginary terms from this expression.
As to the comments by kmitov below: Yes, I am aware that there are ways of solving this that do not dabble into complex numbers at all, but as long as you're used to complex numbers, you don't really gain any simplicity by those methods, and you lose transparency. It also breaks completely apart should you happen to get a complex initial condition in a problem. That is why I do not follow such a solution.