Green's function for $\frac{d^2}{dx^2} + \frac{1}{4}$ I am trying to solve the following differential equation $$y''+\frac{1}{4}y=\sin(2x)~~~y(0)=y(\pi)=0,$$ using Green's function. I have found the Green's function for the operator $y''+\frac{1}{4}$ to be $$G(x,\xi)= \sin\left(\frac{1}{2}(x-\xi)\right).$$ However, when integrating 
$$y(x)=\int_0^\pi \sin\left(\frac{1}{2}(x-\xi)\right) \cdot \sin(2 \xi)~d\xi =\frac{8}{15}\left(\sin(x/2)+\cos(x/2)\right)$$ which is very different from the actual answer of $$y(x)=-\frac{4}{15} \sin(2x).$$ 
Obviously, I am not doing something right. Where am I going wrong?
 A: Let's start from the beginning.  You want to express the problem as solving for a function $G(x,y)$ that satisfies, for $x \in [0,\pi]$
$$\frac{d}{dx^2} G(x,x') + \frac{1}{4} G(x,x') = \delta(x-x') $$
where $\delta(x-x') = 0 \, \forall \, x \ne x'$ and $\int_0^{\pi} dx' \: \delta(x-x') = 1 $.  The solution you seek, $y(x)$, satisfies the boundary conditions $y(0) = y(\pi) = 0$, and may be expressed in terms of $g$ as
$$ y(x) = \int_0^{\pi} dx' \: G(x,x') \sin{2 x'} $$
To find $G$, we assume $x \ne x'$ and write down the general solution to the homogeneous equation:
$$G(x,x') = A \cos{\frac{x}{2}} + B \sin{\frac{x}{2}} $$
The boundary conditions on the solution may be expressed in terms of the relation of $x$ to $x'$.  For example, the condition on $y(0)$ translates into a condition for $G(x,x') \, \forall \, x < x'$; that is, $G(0,x') = A = 0$ when $x < x'$.  Similarly, the condition $y(\pi) = 0 \implies G(\pi,x') = B = 0$ when $x > x'$.  We may then write
$$G(x,x') = \displaystyle \begin{cases} B \sin{\frac{x}{2}} & x < x' \\ A \cos{\frac{x}{2}} & x > x' \end{cases}$$
(This is where I think you went off the rails.) To find $A$ and $B$, we impose 2 conditions.  The first is that $G(x,x')$ be continuous when $x=x'$.  This leads to the relationship $A = B \tan{\frac{x}{2}}$.  The second is that the derivative of $G(x,x')$ with respect to $x$ is discontinuous at $x=x'$ and satisfies 
$$\lim_{\epsilon \rightarrow 0} \left [ \frac{\partial}{\partial x} G(x'+\epsilon,x') - \frac{\partial}{\partial x} G(x'-\epsilon,x') \right ] = 1$$
This relationship may be seen from integration of the differential equation defining $G$ above.  Plugging in the above expression for $G(x,x')$, we get a second relation for $A$ and $B$: $A \sin{\frac{x'}{2}} + B \cos{\frac{x'}{2}} = -2$.  We may solve for $A$ and $B$ and find that $A = -2 \sin{\frac{x'}{2}}$ and $B = -2 \cos{\frac{x'}{2}}$. (A little manipulation of trig identiies is needed to get this.)  We may now write
$$G(x,x') = \displaystyle \begin{cases} -2 \cos{\frac{x'}{2}} \sin{\frac{x}{2}} & x < x' \\ -2 \sin{\frac{x'}{2}} \cos{\frac{x}{2}} & x > x' \end{cases}$$ 
We are now ready to compute the solution $y(x)$ as written above.  Because of the different functional forms for $G$ about $x=x'$, we need to split the integral defining $y$ into two pieces:
$$y(x) = -2 \cos{\frac{x}{2}} \int_0^x dx' \: \sin{\frac{x'}{2}} \sin{2 x'} -2 \sin{\frac{x}{2}} \int_0^x dx' \: \cos{\frac{x'}{2}} \sin{2 x'}$$
The evaluation of these integrals is made possible through the trigonometric addition formulas $\cos{(a-b)} - \cos{(a+b)} = 2 \sin{a} \sin{b}$ and $\sin{(a+b)} + \sin{(a-b)} = 2 \sin{a} \cos{b}$.  It does get a little messy, but you may verify that the solution you seek,
$$y(x) = - \frac{4}{15} \sin{2 x} $$
is the result of the evaluation of the above integrals.
A: Note that this is not the Green's function of the problem with the given boundary conditions $y(0)=y(\pi)=0$. The general solution of the homogeneous equation $y''+\tfrac14 y=0$ is given by $\alpha \cos(x/2) + \beta \sin(x/2).$ The Green's function $G(x,\xi)$  fulfills the homogeneous equation for $x\neq \xi$ and incorporates the boundary conditions $G(0,\xi)=G(\pi,\xi)=0$, and $\partial_x G(x,\xi)|_{x=\xi^+}-\partial_x G(x,\xi)|_{x=\xi^-}=1$. 
We try with the ansatz
$$G(x,\xi) = \begin{cases} \alpha_1 \cos(x/2) + \beta_1 \sin(x/2), x<\xi, \\
\alpha_2 \cos(x/2) + \beta_2 \sin(x/2), x>\xi.\end{cases} $$


*

*The boundary condition $G(0,\xi)=0$ implies $\alpha_1 =0$.

*The boundary condition $G(\pi,\xi)=0$ implies $\beta_2=0$.

*Continuity at $x=\xi$ demands $$\tag{a}\beta_1 \sin(\xi/2)=\alpha_2 \cos(\xi/2).$$

*The requirement on the first derivative $\partial_x G(x,\xi)|_{x=\xi^+}-\partial_x G(x,\xi)|_{x=\xi^-}=1$ demands
$$\frac12[-\alpha_2 \sin(\xi/2) -\beta_1 \cos(\xi/2)]=1$$ or equivalently $$\tag{b}\beta_1 \cos(\xi/2) + \alpha_2 \sin(\xi/2) =-2.$$

*Combining (a) and (b), we obtain $$\beta_1 = -2 \cos(\xi/2) \qquad \alpha_2 =-2 \sin(\xi/2)$$
and the Green's function $$G(x,\xi) = -2\begin{cases} \cos(\xi/2)\sin(x/2), &x<\xi,\\ \sin(\xi/2) \cos(x/2), &x>\xi. \end{cases}$$

*You obtain the solution of the inhomogeneous equation via integration
$$y(x)= \int_0^\pi d\xi\,G(x,\xi)\sin(2\xi).$$
