I am trying to solve the BVP $$u_{xx}+a^2u=\sin(\pi x), \ \ \text{for} \ \ 0<x<1$$ with $u(0)=1$ and $u(1)=-2$, $\forall a\in\mathbb{R}$.
I begin by solving the homogeneous equation $u_{xx}+a^2u=0$. The roots of the characteristic equation of this ODE are $\pm ai$ and so the general solution of the homogeneous equation is $$u_H(x)=A\cos(ax)+B\sin(ax), \ \ A,B\in\mathbb{R}.$$ Searching for a particular solution, I guessed that $u_p(x)=x(C_1\cos(\pi x)+C_2\sin(\pi x))$ where $C_1,C_2\in\mathbb{R}$. So, \begin{align} u'_p(x)&=-C_1x\pi\sin(\pi x)+C_1\cos(\pi x)+C_2x\pi\cos(\pi x)+C_2\sin(\pi x) \\ u''_p(x)&=-C_1\pi^2 x\cos(\pi x)-2C_1\pi\sin(\pi x)-C_2\pi x\sin(\pi x)+2C_2\pi\cos(\pi x). \end{align} Substitution into the original ODE gives $C_1=-\frac{1}{2\pi}$ and $C_2=0$ and so $$u_p(x)=-\frac{x}{2\pi}\cos(\pi x).$$ Thus, $$u(x)=u_H(x)+u_P(x)=A\cos(ax)+B\sin(ax)-\frac{x}{2\pi}\cos(\pi x).$$ The boundary condition $u(0)=1$ implies $A=1$. The boundary condition $u(1)=-2$ implies \begin{align} -2&=\cos(a)+B\sin(a)-\frac{1}{2\pi}\cos(\pi) \\ \implies B&=\frac{1}{\sin(a)}\left(-2-\frac{1}{2\pi}-\cos(a)\right). \end{align} Hence, $$u(x)=\cos(ax)+\frac{1}{\sin(a)}\left(-2-\frac{1}{2\pi}-\cos(a)\right)\sin(ax)-\frac{x}{2\pi}\cos(\pi x).$$ But the resource I found this question states that this is not the correct answer. Have I made an error in logic?