Finding Green's function of $y'' + y = f$

I have to find the Green's function for the following problem:

\begin{cases} y'' + y = f,\ 0 < x < \pi, \\ y(0) = 0,\ y'(\pi) = 0. \end{cases}

Here is my approach: First I found the general solution of $y'' + y = f$, giving us so far $$G(x,s) = \begin{cases} c_1 \cos(x) + c_2 \sin(x) & \text{if } 0 \leq x \leq s\\ c_3 \cos(x) + c_4 \sin(x) & \text{if } s \leq x \leq \pi\end{cases}$$ Where $c$'s are constants. Plugging in the first boundary condition $y(0) = 0$ gives $c_1 = 0$. Plugging in the second boundary condition $y'(\pi) = 0$ gives $c_4 = 0$. So now we have $$G(x,s) = \begin{cases} c_2 \sin(x) & \text{if } 0 \leq x \leq s\\ c_3 \cos(x) & \text{if } s \leq x \leq \pi\end{cases}$$ Now, requiring that $\lim_\limits{x \downarrow s} \frac{dG}{dx}(x,s) - \lim_\limits{x \uparrow s} \frac{dG}{dx}(x,s) = 1$, we get $-c_3 \sin(s) -c_2\cos(s) = 1$.

Requiring that $G(x,s) = G(s,x)$, we get $c_2\sin(s) = c_3\cos(s)$.

Combining the last two gives $c_3 = \frac{-1 - c_2\cos(s)}{\sin(s)}$ and $c_3 = \frac{c_2\sin(s)}{\cos(s)}$ so $$-\cos(s)-c_2\cos^2(s) = c_2\sin^2(s)$$ giving $$c_2 = -\cos(s), c_3 = -\sin(s)$$ Resulting in the Green's function

$$G(x,s) = \begin{cases} -\cos(s) \sin(x) & \text{if } 0 \leq x \leq s\\ -\sin(s) \cos(x) & \text{if } s \leq x \leq \pi\end{cases}$$

Can someone here confirm that my attempt is indeed correct? Many thanks in advance!

• The equation in the title and in the description are different. Is it $\lambda y'$ or $\lambda y$? – Dylan Apr 9 '18 at 13:44
• @Dylan my apologies, I accidentally mistyped the initial problem. The solution is unchanged. – MathMan12345 Apr 9 '18 at 13:55
• Your solution looks correct to me – Dylan Apr 9 '18 at 13:57
• Your solution also looks correct to me. – DisintegratingByParts Apr 9 '18 at 18:17