Solution (source code)

= Solution

Integrate the two exponentials in $\cos(\alpha x)$ against $e^{-inx}$. For $\alpha\notin\mathbb Z$ there are no zero denominators, and
$$
 c_n=\frac1{2\pi}\left[\frac{\sin\pi(\alpha-n)}{\alpha-n}
 +\frac{\sin\pi(\alpha+n)}{\alpha+n}\right]
 =\boxed{\frac{(-1)^n\alpha\sin(\pi\alpha)}{\pi(\alpha^2-n^2)}}.
$$
Thus the <complex Fourier series> is
$$
 \boxed{\cos(\alpha x)=\frac{\alpha\sin(\pi\alpha)}\pi
 \sum_{n\in\mathbb Z}\frac{(-1)^ne^{inx}}{\alpha^2-n^2},\qquad -\pi\leq x\leq\pi.}
$$
This is the periodic extension, not a globally nonperiodic cosine formula. For each fixed complex $\alpha$, the coefficients are $O(n^{-2})$, giving absolute and uniform convergence. The extension is continuous at the endpoints because the two endpoint values agree; piecewise smooth <pointwise convergence of a piecewise smooth Fourier series> identifies the sum with it, including those endpoints.