Annoying Green's Function I'm attempting to solve the equation $$\frac{d^2y}{dx^2}-y(x)=f(x)$$ on $0\le x\le a$ s.t. $y(0)=y(a)=0.$  
Note that $f(x)$ is given by 
$$
   f(x) = \left\{
     \begin{array}{lr}
       1 & : 0 \le x \le b\\
       -1 & : b<x\le a
     \end{array}
   \right.
$$
where $0\le b \le a$.  
In particular, I'm hoping to show that in the subregion $0 \le x \le b$,
$$y(x)=\frac{2}{\sinh (a)}[\sinh(a-x)-\sinh(x)-\cosh(x)\sinh(a-x)-\sinh(x)\cosh(a-x)+2\sinh(x)\cosh(a-b)].$$
So, I tried to proceed by finding the Green's function of $D=d^2/dx^2-1$ but I was unable to get the answer to appear as given.  Can anyone help me out?
 A: The Green's function can be found by a standard exercise.
Here is an answer to another problem where the steps are worked out in detail.
The Green's function for this problem is
$$G(x,y) =
\frac{1}{\sinh a}
\begin{cases}
\sinh x\sinh(y-a), & x<y \\
\sinh y\sinh(x-a), & x>y.
\end{cases}$$
The first calculation below is based on the original problem.
I. For
$$f(x) = \begin{cases}
1, & 0\le x\le b \\
0, & b< x\le a
\end{cases}$$
we have
$$\begin{eqnarray*}
y(x) &=& \int_0^a dy\, G(x,y)f(y) \\
&=& \int_0^b dy\, G(x,y) \\
&=& \int_0^x dy\, G(x,y) + \int_x^b dy\, G(x,y) \\
&=& \frac{1}{\sinh a}
\left(
\int_0^x dy\,  \sinh y\sinh(x-a)
+ \int_x^b dy\, \sinh x\sinh(y-a)
\right) \\
&=& \frac{\cosh(a-b)-\cosh a}{\sinh a}\sinh x
+ \cosh x
-1
\qquad (0<x<b).
\end{eqnarray*}$$
The solution for $b<x$ can be found similarly.
II.
For
$$f(x) = \begin{cases}
1, & 0\le x\le b \\
-1, & b< x\le a
\end{cases}$$
in the revised question we simply subtract the integral 
$$\frac{1}{\sinh a} \int_b^a dy\, \sinh x\sinh(y-a)$$ 
from the result in I. 
We find 
$$y(x) = \frac{2\cosh(a-b)-\cosh a -1}{\sinh a}\sinh x + \cosh x - 1
\qquad (0<x<b).$$
This is the solution quoted in the question statement without the overall factor of 2.
