Solution (source code)

= Solution

For $\alpha\ne0$, the <Fredholm alternative> gives a unique solution exactly when $\alpha\ne-\lambda_n$ for all $n\geq0$, unless a resonant problem could exceptionally be compatible. Here none is: with $\kappa_n=n+1/2$,
$$
\int_0^\pi\cos x\cos(\kappa_nx)\,dx=\frac{(-1)^{n+1}\kappa_n}{\kappa_n^2-1}\ne0.
$$
At every resonance the compatibility condition therefore fails.

The case $\alpha=0$ must be checked separately because $L$ is a compact first-kind <integral operator>. For every admissible $y$, $Ly$ is continuous and $(Ly)(\pi)=0$, whereas $\cos\pi=-1$. Hence $Ly=\cos x$ has no solution. Combining these cases,
$$
\boxed{\text{A unique solution exists exactly for }\alpha\in\mathbb R\setminus\left(\{0\}\cup\left\{\frac4{4n^2+4n-3}:n\geq0\right\}\right).}
$$
In the nonresonant nonzero case the shifted eigenvalues stay away from zero, since $\lambda_n\to0$ and $\alpha\ne0$, so inversion is bounded on the Hilbert space.