$e^{ix}=\cos(x)+i\sin(x)$
$Ae^{4ix}=A(\cos(4x)+i\sin(4x))$
$Be^{-4ix}=B(-\cos(4x)-i\sin(4x))$
What am I doing wrong?
I am trying to find the complimentary function of $\frac{d^2y}{dx^2} +16y=8cos(4x)$
C.F: $x^2+16=0$
$x=4i$ and $x=-4i$
$$Ae^{4ix}+Be^{-4ix}$$
$\phi\pm\beta i$
$$\Rightarrow e^{\phi x}(Asin\beta x+Bcos\beta x) $$
You should get $Be^{-4ix}=B(\cos(-4x)+i\sin(-4x))=B(\cos(4x)-i\sin(4x))$ since $\cos(-a)=\cos a$ and $\sin(-a)=-\sin a$.
By adding
$Ae^{4ix}=A(\cos(4x)+i\sin(4x))$ and
$Be^{-4ix}=B(\cos(4x)-i\sin(4x))$ you get $$Ae^{4ix}+Be^{-4ix}=(A+B)\cos(4x)+i(A-B)\sin(4x).$$
EDIT: (Now that you have added that you were asking because solving a differential equation.)
We have expressed $Ae^{4ix}+Be^{-4ix}$ in the form $C\cos 4x+D\sin 4x$. Notice that we can get arbitrary $C,D\in\mathbb C$ (by choosing appropriate $A$, $B$.) So we have $y(x)=C\cos 4x+D\sin 4x$ as a general solution of $y''+16y=0$.
EDIT 2: To be more precise: For any given $C$, $D$ we can find $A$ and $B$ such that $A+B=C$, $i(A-B)=D$ by solving the system of two linear equations. Namely we get $B=(C+iD)/2$ and $A=(C-iD)/2$.
Basically the thing I am trying to get is explained in different words in kahen's comment.