dx2d2y+4y=x
y(1)=5
y(5)=1
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,
yh(x), (or
yc(x) sometimes called the complementary solution), comes from the homogeneous differential equation and the other is the particular solution
yp(x) which comes from the nonhomogeneous differential equation.
Green function is built into the particular solution. That is:
yp(x)=∫15s g(x,s) ds
where
g(x,s) is the green function and for this problem is defined as:
g(x,s)=⎩⎪⎪⎨⎪⎪⎧−2sin2(5−1)sin2(s−1)sin2(5−x)−2sin2(5−1)sin2(x−1)sin2(5−s)1≤s≤xx≤s≤5
Or
g(x,s)=⎩⎪⎪⎨⎪⎪⎧−2sin8sin2(s−1)sin2(5−x)−2sin8sin2(x−1)sin2(5−s)1≤s≤xx≤s≤5
Substitute Green's function in the particular solution.
yp(x)=−2sin8sin2(5−x)∫1xssin2(s−1) ds−2sin8sin2(x−1)∫x5ssin2(5−s) ds
Solving these integrals gives:
yp(x)=−2sin8sin2(5−x)[4sin2(x−1)−2xcos2(x−1)+2]−2sin8sin2(x−1)[4sin2(x−5)−2xcos2(x−5)+10]
Or
yp(x)=−[8sin8sin2(x−1)sin2(5−x)−2xcos2(x−1)sin2(5−x)+2sin2(5−x)]−[8sin8sin2(x−5)sin2(x−1)−2xcos2(x−5)sin2(x−1)+10sin2(x−1)]
Or
yp(x)=[8sin82xcos2(x−1)sin2(5−x)−2sin2(5−x)]+[8sin82xcos2(x−5)sin2(x−1)−10sin2(x−1)]
Or
yp(x)=[8sin82xsin8−2sin2(5−x)−10sin2(x−1)]
Or
yp(x)=[4sin8xsin8−sin2(5−x)−5sin2(x−1)]
Or
yp(x)=[4x−sin2(5−x)csc8−5sin2(x−1)csc8]
The homogeneous solution is:
yh(x)=c1cos2x+c2sin2x
Applying the boundary conditions
y(1)=5,y(5)=1 give us:
yh(x)=2(cos2+cos6)sin2sin2(x−1)+5sin2(5−x)
dx2d2y+4y=x
y(1)=5
y(5)=1
1<x<5
The solution to the differential equation above is:
y(x)=yh(x)+yp(x)=2(cos2+cos6)sin2sin2(x−1)+5sin2(5−x)+[4x−sin2(5−x)csc8−5sin2(x−1)csc8]
Simplify the expression above by Wolfram Alpha. And you'll get:
y(x)=8(cos2+cos6)csc2[xsin8+sin(2−2x)+19sin(10−2x)]
which matches post
#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
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!
y′′(x)+10y(x)=tanx
y′′(x)+64y(x)=xex
y′′(x)+7y(x)=lnx
y′′(x)+44y(x)=tanx+sinx
y′′(x)+y(x)=x2−x+1
y′′(x)+16y(x)=sin5x+cosx−14x3
y′′(x)+k2y(x)=f(x)
And the list goes on....!
In simple words, the solution is always:
y(x)=c1coskx+c2sinkx+∫abf(s)g(x,s) ds
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!)

I hate mathematics.