I am self-studying this topic from a textbook and am stuck with trying work through one example.
Suppose we are solving the recurrence equation, $u_n = 2u_{n-1} - 2u_{n-2}$.
This has the characteristic equation $r^2 - 2r + 2 = 0$, which has two characteristic complex roots $1\pm i$. (assume this is correct)
The complex roots can be written in three forms (modulus = $\sqrt{2}$, arguments = $\pm\frac{\pi}{4}$).
\begin{align*} \text{Rectangular: }&1 \pm i \\ \text{Polar: }&\sqrt{2}\left(\cos\frac{\pi}{4} \pm i\sin\frac{\pi}{4}\right) \\ \text{Exponential: }&\sqrt{2}e^{\pm\frac{\pi i}{4}} \end{align*}
The general solution to this recurrence relation with two roots is: $u_n = A(\text{root}_1)^n + B(\text{root}_2)^n$, where $A$ and $B$ are arbitrary constants (assume this is correct).
I imagine the complex roots can be used in any of their three forms in the general solution, but am having particular trouble with the polar form.
\begin{align*} u_n &= A\left(\sqrt{2}\left(\cos \frac{\pi}{4} + i\sin \frac{\pi}{4}\right)\right)^n + B\left(\sqrt{2}\left(\cos \frac{\pi}{4} - i\sin \frac{\pi}{4}\right)\right)^n && \\ &= A (\sqrt{2})^n\left( \cos\frac{n\pi}{4} + i\sin\frac{n\pi}{4} \right) + B (\sqrt{2})^n\left( \cos\frac{n\pi}{4} - i\sin\frac{n\pi}{4} \right) && \text{Using De Moivre's theorem} \\ &= (\sqrt{2})^n\left( (A+B)\cos\frac{n\pi}{4} + (A-B)i\sin\frac{n\pi}{4} \right) && \text{Switching $A\pm B$ for other arbitrary constants} \\ &= (\sqrt{2})^n\left( C\cos\frac{n\pi}{4} + D\begingroup\color{red}i\endgroup\sin\frac{n\pi}{4} \right) \end{align*}
I am not sure where I went wrong, but this result does not agree with the result in the textbook I am studying from, in that the imaginary number (colored in red) is absent from the textbook result. I might have thought that is a texbook error, but it explicitly draws attention to the fact that using the general solution in polar form includes only real numbers!
The textbook example does not show the derivation in steps and seems to assume this is straightforward. Also it does not explicitly show that complex roots in exponential form can be used (can they?).