I want to find $c_n$ satisfying
$$\sum_{n\in\mathbb Z}c_ne^{inx}=\cos(3x)$$
Noting that $\langle e^{inx},e^{-imx}\rangle=0$ for $n\neq m$ in $[0,2\pi]$, I have
$$c_m\int_0^{2\pi}e^{i(m-m)x}\,dx=\int_0^{2\pi}\cos(3x)e^{-imx}\,dx$$
but the RHS evaluates to
$$\int_0^{2\pi}\cos(3x)e^{-imx}\,dx=\frac{i(1-e^{-2i\pi m})}{9-m^2}$$
with $e^{-2i\pi m}=1$ since $m\in\mathbb Z$. Thus $c_m=0$, which doesn't seem right. What am I missing?