# Finding what value(s) of $a$ such that $u''+9u=a-x$ has a solution with $u(0)=u(\pi)=0$

I am trying to find what value(s) of $$a$$ the ODE $$u''+9u=a-x, \ \ \ 0 has a solution with boundary conditions $$u(0)=u(\pi)=0$$.

The homogeneous ODE, $$\ u''+9u=0,\$$ has solution $$u_H(x)=A\cos(3x)+B\sin(3x), \ \ A,B\in\mathbb{R}.$$ For a particular solution, I used the method of undetermined coefficients to guess that $$u_p(x)=C_1x+C_2, \ \ C_1,C_2\in\mathbb{R}$$. Hence a particular solution is $$u_p(x)=-\frac{x}{9}+\frac{a}{9}.$$ So $$u(x)=u_H(x)+u_P(x)=A\cos(3x)+B\sin(3x)-\frac{x}{9}+\frac{a}{9}.$$ Applying the boundary conditions $$u(0)=\pi\implies A=-\frac{a}{9}.$$ However $$u(\pi)=0$$ leaves $$B$$ undetermined as $$\sin(3\pi)=0$$. What am I missing here?

You don't need to determine the value of $$B$$; $$u(\pi)=-\frac{a}9\cos{(3\pi)}+B\sin{(3\pi)}-\frac\pi9+\frac{a}9=\frac{2a}{9}-\frac\pi9=0$$ $$\therefore \boxed{a=\frac\pi2}$$