Second order, two-point boundary value problem Solve the BVP
$$\begin{cases}
u''+a^2u=sin\pi x, \quad 0<x<1 \\
u(0)=1,\quad u(1)=-2
\end{cases}$$
for all $a\in\mathbb{R}$. What are the solutions in the cases $a=\pm\pi$?
Here, $'=\frac{du}{dx}$.
I know I need the characteristic function, which I get $r^2+a^2=0\implies r=\pm ai$. Then the complementary solution is,
$$u_c=C_1e^{ai*t}+C_2e^{-ai*t}$$
 A: HINT:
Since the homogeneous solutions to the ODE $u''+\pi^2 u=\sin(\pi x)$ are of the form $u_h=A\sin(\pi x)+B\cos(\pi x)$, try complementary solutions of the form $u_c=Cx\sin(\pi x)+Dx\cos(\pi x)$.

Alternatively, use Laplace Transforms.

Alternatively, find the Green (or Green's) function for the problem
$$G''(x,x')+\pi^2 G(x,x')=\delta(x-x')$$
with $G(0,x')=1$, $G(1,x')=-2$, $G$ is continuous at $x=x'$, and $\left.\frac{\partial G}{\partial x}\right|_{x=x'^+}-\left.\frac{\partial G}{\partial x}\right|_{x=x'^-}=1$ and integrate.
A: If you do not know about integral transforms and Green's functions go and learn it. But Here is the way of avoiding this stuff for your concrete problem:
$$y''+a^{2}y=f(x)$$
You note that
$$y''+a^{2}y=\frac{d}{dt}(y'+iay)-ia(y'+iay)$$
Now let
$$\xi(x)=y'+iay$$
Hence
$$\xi'-ia\xi=f(x)$$
Using the integrating factor 
$$\xi(x)=\frac{d}{dx}y+aiy=e^{aix}\Big\{\int_{0}^{x}f(z)e^{-aiz}dz+\xi_{0}\Big\}$$
Using the integrating factor the second time you get
$$y(x)=e^{-aix}\Big\{\int_{0}^{x}e^{2aiw}\Big\{\int_{0}^{w}f(z)e^{-aiz}dz+\xi_{0}\Big\}dw+x_{0}\Big\}$$
Then do the integrals)
