# Solve the boundary value problem $y''+y= -1$, $\,y(0)=y(\pi/2)=0$ with the Green's function method

Using the Green's Function method solve the boundary value problem:

$$y''+ y= -1,$$

with boundary conditions

$$y(0)=0, \quad y(\pi/2)=0.$$

Verify the result by elementary technique.

Approach 1: Homogeneous and Complementary

We solve $y'' + y = 0$, which yields:

$$y_h(x) = c_1 \cos x + c_2 \sin x$$

We choose a particular solution as $y_p = a$, which yields:

$$y_p(x) = -1$$

We now solve for the constants using the boundary conditions and get:

$$y(x) = y_h(x) + y_p(x) = \cos x + \sin x - 1$$

Approach 2: Green's Function Method

From the complementary solution above, we have:

$u_1 = \sin x$, $u_2 = \cos x$

We need to satisfy $B_0[y] = y(0) = 0 \rightarrow y_1(x) = \sin x$.

We now need to satisfy $B_1[y] = y\left(\frac{\pi}{2}\right) = 0 \rightarrow y_2(x) = \sin(x -\pi/2) = -\cos x$.

The Wronskian of $(\sin x, -\cos x) = 1$.

This gives a Green function of:

• $G(x,s) = \dfrac{y_1(s)y_2(x)}{W(y_1,y_2)(s)}$ if $a \le s \le x \le b$
• $G(x,s) = \dfrac{y_1(x)y_2(s)}{W(y_1,y_2)(s)}$ if $a \le x \le s \le b$

We are now able to find:

$$\int_a^b~G(x,s)f(s)~ds$$

We get:

• $G(x,s) = -\sin s \cos x$ if $0 \le s \le x$
• $G(x,s) = -\sin x \cos s$ if $x \le s \le \frac{\pi}{2}$

$\displaystyle y(x) = \int_0^x -\sin s (-1)~ds \cos x + \int_x^{\frac{\pi}{2}} -\cos s (-1)~ds \sin x$

$= \cos x(1 - \cos x) + \sin x(1 - \sin x) = \cos x + \sin x -1$

This agrees with Approach 1.

Excuse my sloppiness, but in a rush.

• Now'd this go neglected? Deserves a TU! +1 – Namaste Nov 29 '13 at 0:07


The solution is given by $${\rm y}\pars{x} = {\rm y_{p}}\pars{x} + \int_{0}^{\pi/2}{\rm G}\pars{x,x'}\pars{-1}\,\dd x'$$ where ${\rm y_{p}}\pars{x}$ is a $\it\mbox{particular solution}$ $\ds{\pars{~{\rm y}''_{\rm p}\pars{x} + {\rm y_{p}}\pars{x} = 0~}}$ which satisfies the boundary conditions $\ds{{\rm y}\pars{0} = {\rm y}\pars{\pi \over 2} = 0}$. Obviously, $\ds{{\rm y_{p}}\pars{x} = 0\,,\forall x}$. Then \begin{align} {\rm y}\pars{x} &= -\int_{0}^{\pi/2}{\rm G}\pars{x,x'}\,\dd x' \\[3mm] -1 = {\rm y}''\pars{x} + {\rm y}\pars{x} &= -\int_{0}^{\pi/2}\pars{\partiald[2]{}{x} + 1}{\rm G}\pars{x,x'}\,\dd x \end{align} $$\pars{\partiald[2]{}{x} + 1}{\rm G}\pars{x,x'} = \delta\pars{x - x'}\,,\qquad \left\vert% \begin{array}{rcl} {\rm G}\pars{0,x'} & = & 0 \\ {\rm G}\pars{{\pi \over 2},x'} & = & 0 \end{array}\right.\tag{1}$$ $\pars{1}$ and the continuity at $x = x'$ are equivalent to $$\!\!\!\!\!\!\!\!\!\!{\rm G}\pars{x,x'} = \braces{% \begin{array}{rcl} A\sin\pars{x} & \mbox{if} & x < x' \\[1mm] B\cos\pars{x} & \mbox{if} & x > x' \end{array}} \quad\mbox{and}\quad\left\lbrace% \begin{array}{rcl} {\rm G}\pars{x'^{-},x'} & = & {\rm G}\pars{x'^{+},x'} \\[2mm] \left.\partiald{{\rm G}\pars{t,t'}}{t}\right\vert_{x\ =\ x'^{-}}^{x\ =\ x'^{+}} & = & 1 \end{array}\right.\tag{2}$$ With $\pars{2}$, we get: $$\left\lbrace% \begin{array}{rcrcl} \sin\pars{x'}A & - & \cos\pars{x'}B & = & 0 \\ -\cos\pars{x'}A & - & \sin\pars{x'}B & = & 1 \end{array}\right. \quad\imp\quad \left\lbrace% \begin{array}{rcl} A & = & -\cos\pars{x'} \\ B & = & -\sin\pars{x'} \end{array}\right.$$ \begin{align} {\rm y}\pars{x}&=-\int_{0}^{x}\bracks{-\sin\pars{x'}\cos\pars{x}}\,\dd x' -\int_{x}^{\pi/2}\bracks{-\cos\pars{x'}\sin\pars{x}}\,\dd x' \\[3mm]&=\cos\pars{x}\bracks{-\cos\pars{x} + 1} + \sin\pars{x}\bracks{1 -\sin\pars{x}} \end{align}

$$\color{#0000ff}{\large% {\rm y}\pars{x} = \sin\pars{x} + \cos\pars{x} - 1}$$