\(\displaystyle \frac{d^2y}{dx^2} + 4y = x\)
\(\displaystyle y(1) = 5\)
\(\displaystyle y(5) = 1\)
\(\displaystyle 1 < x < 5\)
Now I will explain how to use Green's function to solve this problem!
We know that when the differential equation is non-homogeneous, it has two solutions. One solution, \(\displaystyle y_h(x)\), (or \(\displaystyle y_c(x)\) sometimes called the complementary solution), comes from the homogeneous differential equation and the other is the particular solution \(\displaystyle y_p(x)\) which comes from the nonhomogeneous differential equation.
Green function is built into the particular solution. That is:
\(\displaystyle y_p(x) = \int_{1}^{5} s \ g(x,s) \ ds\)
where \(\displaystyle g(x,s)\) is the green function and for this problem is defined as:
[imath]\large g(x,s) =\begin{cases} -\frac{\sin 2(s - 1)\sin 2(5 - x)}{2\sin 2(5-1)} & 1 \leq s \leq x\\[2ex] -\frac{\sin 2(x - 1)\sin 2(5 - s)}{2\sin 2(5-1)} & x \leq s \leq 5\end{cases}[/imath]
Or
[imath]\large g(x,s) =\begin{cases} -\frac{\sin 2(s - 1)\sin 2(5 - x)}{2\sin 8} & 1 \leq s \leq x\\[2ex] -\frac{\sin 2(x - 1)\sin 2(5 - s)}{2\sin 8} & x \leq s \leq 5\end{cases}[/imath]
Substitute Green's function in the particular solution.
\(\displaystyle y_p(x) = -\frac{\sin 2(5 - x)}{2\sin 8}\int_{1}^{x} s \sin 2(s - 1) \ ds - \frac{\sin 2(x - 1)}{2\sin 8}\int_{x}^{5} s \sin 2(5 - s) \ ds\)
Solving these integrals gives:
\(\displaystyle y_p(x) = -\frac{\sin 2(5 - x)}{2\sin 8}\bigg[\frac{\sin 2(x - 1) - 2x\cos 2(x - 1) + 2}{4}\bigg] - \frac{\sin 2(x - 1)}{2\sin 8}\bigg[\frac{\sin 2(x - 5) - 2x\cos 2(x - 5) + 10}{4}\bigg]\)
Or
\(\displaystyle y_p(x) = -\bigg[\frac{\sin 2(x - 1)\sin 2(5 - x) - 2x\cos 2(x - 1)\sin 2(5 - x) + 2\sin 2(5 - x)}{8\sin 8}\bigg] - \bigg[\frac{\sin 2(x - 5)\sin 2(x - 1) - 2x\cos 2(x - 5)\sin 2(x - 1) + 10\sin 2(x - 1)}{8\sin 8}\bigg]\)
Or
\(\displaystyle y_p(x) = \bigg[\frac{2x\cos 2(x - 1)\sin 2(5 - x) - 2\sin 2(5 - x)}{8\sin 8}\bigg] + \bigg[\frac{2x\cos 2(x - 5)\sin 2(x - 1) - 10\sin 2(x - 1)}{8\sin 8}\bigg]\)
Or
\(\displaystyle y_p(x) = \bigg[\frac{2x\sin 8 - 2\sin 2(5 - x) - 10\sin 2(x - 1)}{8\sin 8}\bigg]\)
Or
\(\displaystyle y_p(x) = \bigg[\frac{x\sin 8 - \sin 2(5 - x) - 5\sin 2(x - 1)}{4\sin 8}\bigg]\)
Or
\(\displaystyle y_p(x) = \bigg[\frac{x - \sin 2(5 - x)\csc 8 - 5\sin 2(x - 1)\csc 8}{4}\bigg]\)
\(\displaystyle \textcolor{red}{\bold{The \ homogeneous \ solution \ is}}\):
\(\displaystyle y_h(x) = c_1\cos 2x + c_2\sin 2x\)
Applying the boundary conditions \(\displaystyle y(1) = 5, y(5) = 1\) give us:
\(\displaystyle y_h(x) = \frac{\sin2(x - 1) + 5 \sin 2(5 - x)}{2(\cos 2 + \cos 6)\sin 2}\)
\(\displaystyle \frac{d^2y}{dx^2} + 4y = x\)
\(\displaystyle y(1) = 5\)
\(\displaystyle y(5) = 1\)
\(\displaystyle 1 < x < 5\)
The solution to the differential equation above is:
\(\displaystyle y(x) = y_h(x) + y_p(x) = \frac{\sin2(x - 1) + 5 \sin 2(5 - x)}{2(\cos 2 + \cos 6)\sin 2} + \bigg[\frac{x - \sin 2(5 - x)\csc 8 - 5\sin 2(x - 1)\csc 8}{4}\bigg]\)
Simplify the expression above by Wolfram Alpha. And you'll get:
\(\displaystyle y(x) = \frac{\csc 2\bigg[x\sin 8 + \sin(2-2x) + 19\sin(10 - 2x)\bigg]}{8(\cos 2 + \cos 6)}\)
which matches post \(\displaystyle \# 4\).
Here is a screen shot.
Now is the most important question which is why do we use this method when it is very complicated? Yes, I agree that it is very difficult but the main goal is you spend a lot of time to solve one differential equation but then you use its solution to solve \(\displaystyle 1000\) differential equations in a few minutes using the same green function but different force functions and different boundary conditions. And you don't have to simplify as we did in this problem!
What do I mean by that?
Now we can solve all of these differential equations in less than 5 minutes!
\(\displaystyle y''(x) + 10y(x) = \tan x\)
\(\displaystyle y''(x) + 64y(x) = xe^x\)
\(\displaystyle y''(x) + 7y(x) = \ln x\)
\(\displaystyle y''(x) + 44y(x) = \tan x + \sin x\)
\(\displaystyle y''(x) + y(x) = x^2 - x + 1\)
\(\displaystyle y''(x) + 16y(x) = \sin 5x + \cos x - 14x^3\)
\(\displaystyle y''(x) + k^2y(x) = f(x)\)
And the list goes on....!
In simple words, the solution is always:
[imath]\large y(x) = c_1\cos kx + c_2\sin kx + \int_{a}^{b}f(s)g(x,s) \ ds[/imath]
And just remember that once you obtain the Green's function for any second order differential equation, you don't have to solve the integral by hand as I did! (This will save you a lot of time but you lose the enjoyment in return!)


\(\displaystyle {\color{green}\huge \bold{I \ hate \ mathematics.}}\)