How does $Ae^{4ix}+Be^{-4ix}=A\cos(4x)+B\sin(4x)$? $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) $$
 A: Well in the third line the negative sign should actually be part of the argument of the trigonometric functions but in answer to the larger question, I would say that the A and B on the left hand side are not the same as the A and B on the right hand side but rather two new complex constants (that will depend on the old A and B). This is a bit sloppy notation but some people do it.
A: Your mistake is in $Be^{-4i x} = B(\cos(-4x)+i\sin(-4x)) = B(\cos(4x)-i\sin(4x))$.
A: This is not true 
for $x=0$ we have $A+B= A$ which is not true in general.
A: 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.
A: $Be^{-4ix}=B(\cos(-4x)+i\sin(-4x))=B(\cos 4x-i\sin4x)$
