Solution (source code)

= Solution

Use the <mixed Dirichlet-Neumann modes on an interval>. To justify their <Fourier series>, extend $y$ evenly across $x=1$ to $[0,2]$, then oddly across $x=0$, and repeat with period four. The condition $y(0)=0$ makes the odd extension <continuous>, and $y'(1)=0$ makes the even reflection continuously differentiable. The resulting periodic function has a convergent <Fourier sine series>. Reflection about $x=1$ eliminates the even <sine> harmonics, leaving
$$
\boxed{\lambda_n=(n+1/2)\pi,\qquad n=0,1,2,\ldots.}
$$
Alternatively these values follow directly from $\sin\lambda_n0=0$ and $\lambda_n\cos\lambda_n=0$. <Fourier orthogonality> gives
$$
\int_0^1\sin\lambda_nx\sin\lambda_mx\,dx=\frac12\delta_{nm},\qquad
\boxed{a_n=2\int_0^1y(x)\sin\lambda_nx\,dx.}
$$
The extension argument also supplies completeness, not merely orthogonality, of this <Fourier sine basis>.

Expand the forcing as $x\cos\pi x=\sum b_n\sin\lambda_nx$. Product-to-sum and <integration by parts> give
$$
\begin{aligned}
b_n&=2\int_0^1x\cos\pi x\sin\lambda_nx\,dx\\
&=\int_0^1x[\sin((\lambda_n+\pi)x)+\sin((\lambda_n-\pi)x)]\,dx\\
&=-(-1)^n\left[\frac1{(\lambda_n+\pi)^2}+\frac1{(\lambda_n-\pi)^2}\right].
\end{aligned}
$$
Each mode of the differential operator has <eigenvalue> $-(\lambda_n^2+\alpha^2)$. Hence, for real $\alpha$, the solution is
$$
\boxed{y(x)=\sum_{n=0}^\infty
\frac{(-1)^n}{\lambda_n^2+\alpha^2}
\left[\frac1{(\lambda_n+\pi)^2}+\frac1{(\lambda_n-\pi)^2}\right]
\sin\lambda_nx.}
$$
The coefficients are $O(n^{-4})$, so the series and its first two differentiated series converge uniformly. Therefore it solves the equation and the <boundary conditions> term by term. Uniqueness follows by multiplying the homogeneous equation by its real solution and integrating: the boundary terms vanish and $\int_0^1[(y')^2+\alpha^2y^2],dx=0$, forcing $y=0$.