Abstract
If you are like me, and use advanced math every day or so, you may find yourself struggling with the Green Function. In my case, it's because Green Function is largely introduced with Physics related concepts, and I don't really like physics. Tough luck. However, the whole thing boils down to the fact that you can find plenty of books explaining the theory, but few attacking the problem in a neat way. So, here we go. I am giving a couple of examples, trying to explain clearly as much as I can what I do. I will avoid giving further theory, here.
Some Bureaucracy
Do you remember when I said I would have not touched any theory. Well, I lied. But not too much. Here I will give some "useful facts" that should help you understanding the reason behind some choices. I tried to keep the part as easy and short as I can.
Fact 1: Dirac's delta primitive: the Heaviside function
The following is a well-known result regarding the Dirac Delta function:
$$\int_{u-\epsilon}^{u+\epsilon}\delta(x-u)f(x)\,dx=f(u)$$
Now take the function being the unit function:
$$f(x)=1\quad\forall x\in\mathbb{R}$$
and evaluate the integral
$$\int_{-\infty}^{t}\delta(x-u)\,dx=\begin{cases} 0\quad tu \end{cases}=H(x-u)$$
Observe that the Heaviside function is not continuous in
$$x=u$$
Fact 2: the derivative of a non-continuous function
Assume you have a function not continuous on a given point of its domain:
$$d(x) \text{ not continuous in }x=u$$
Then it is easy to show that this function can be expressed like the sum of a continuous function with the product of the Heaviside function multiplied by the "leap":
$$d(x)=c(x)+h\cdot H(x-u)$$
deriving both sides, this gives:
$$\begin{align} d'(x)&=c'(x)+h\cdot H'(x-u)\\ &=c'(x)+h\cdot \delta(x-u) \end{align}$$
A basic exercise
Consider the boundary value problem defined by the ODE:
$$\frac{d^2}{dx^2}y=f(x)$$
with the boundary conditions:
$$\text{BC1:}\quad\quad y(0)=y'(0)$$
$$\text{BC2:}\quad\quad y(1)=y'(1)$$
It is useful to solve the associated homogeneous differential equation with inhomogeneous constraints. The solution of the given BVP will follow by linearity.
By definition, the Green function solving this Boundary Value problem will satisfy the relation
$$\text{D1:}\quad\quad\frac{d^2}{dx^2}G(x,\xi)=\delta(x-\xi)$$
So the solution of the homogeneous ODE is
$$y(x)=c_0x+c_1,\quad c_0,c_1\in\mathbb{R}$$
This dictates the structure of the Green function as follows:
$$G(x,\xi)=\begin{cases} Ax+B\quad\text{if } x\in[0,\xi[\\ Cx+D\quad\text{if } x\in]\xi,1] \end{cases}$$
However the parameters depend on the value of the other variable, so we express this function as
$$G(x,\xi)=\begin{cases} A(\xi)x+B(\xi)\quad\text{if } x\in[0,\xi[\\ C(\xi)x+D(\xi)\quad\text{if } x\in]\xi,1] \end{cases}$$
Therefore
$$\frac{d}{dx}G(x,\xi)=\begin{cases} A(\xi)\quad\text{if } x\in[0,\xi[\\ C(\xi)\quad\text{if } x\in]\xi,1] \end{cases}$$
Observe that from D1 we see that G' and G'' are not continuous in x=u. Further:
$$\text{C1:}\quad\quad\lim_{\epsilon\to 0}\left[ \frac{d}{dx}G(x,\xi) \right]_{x=\xi-\epsilon}^{\xi+\epsilon}=1$$
Finally we want the Green function to be continuous in x=u, so:
$$\text{C2:}\quad\quad\xi A(\xi)+B(\xi)=\xi C(\xi)+D(\xi)$$
Time to play a bit with the constraints. Take in consideration BC1:
$$\text{BC1_bis:}\quad\quad y(0)=y'(0)\Rightarrow\left[A(\xi)x+B(\xi)\right]_{x=0}=A(\xi)\Rightarrow A(\xi)=B(\xi)$$
Now analyse BC2:
$$\text{BC2_bis:}\quad\quad y(1)=y'(1)\Rightarrow \left[C(\xi)x+D(\xi)\right]_{x=1}=C(\xi)\Rightarrow D(\xi)=0$$
From C1 we obtain:
$$\text{C1_bis:}\quad\quad C(\xi)-A(\xi)=1\Rightarrow C(\xi)=A(\xi)+1$$
So far:
$$\begin{align} G(x,\xi)=\begin{cases} A(\xi)x+B(\xi)\quad\text{if } x\in[0,\xi[\\ C(\xi)x+D(\xi)\quad\text{if } x\in]\xi,1] \end{cases} &\underset{\text{BC2_bis}}{\Rightarrow} G(x,\xi)=\begin{cases} A(\xi)x+B(\xi)\quad\text{if } x\in[0,\xi[\\ C(\xi)x\quad\quad\quad\quad\text{if } x\in]\xi,1] \end{cases} \\ &\underset{\text{C1_bis}}{\Rightarrow} G(x,\xi)=\begin{cases} A(\xi)x+B(\xi)\quad\text{if } x\in[0,\xi[\\ \left( A(\xi)+1 \right) x\quad\quad\text{if } x\in]\xi,1] \end{cases} \\ &\underset{\text{BC1_bis}}{\Rightarrow} G(x,\xi)=\begin{cases} A(\xi)x+A(\xi)\quad\text{if } x\in[0,\xi[\\ \left( A(\xi)+1 \right) x\quad\quad\text{if } x\in]\xi,1] \end{cases} \end{align}$$
Now apply C2 to obtain:
$$\xi A(\xi)+A(\xi)=\xi A(\xi)+\xi\Rightarrow A(\xi)=\xi$$
To recap
$$G(x,\xi)=\begin{cases} \xi\cdot x+\xi\quad\text{if } x\in[0,\xi]\\ \left( \xi+1 \right) x\quad\text{if } x\in[\xi,1] \end{cases} = \begin{cases} \left( x+1\right)\xi\quad\text{if } x\in[0,\xi]\\ \left( \xi+1 \right) x\quad\text{if } x\in[\xi,1] \end{cases}$$
And this closes the first part of this exercise.
An application
Suppose now we want to find the solution of the DE
$$\frac{d^2}{dx^2}y=x^2$$
within the constraints:
$$y(0)=y'(0)+1$$
and
$$y(1)=y'(1)+2$$
Establish
$$\varphi(x)=x^2$$
We want to use the Green function we found to solve
$$\frac{d^2}{dx^2}y=\varphi(x)$$
and it is a very well-known result that the solution is given by
$$\int_{[0,1]}G(x,\xi)\varphi(\xi)\,d\xi$$
being P a given interval of the real numbers. The Green function is piecewise, so the integral must be split into two integrals, combined together. Linearity then would grant the fact that the solution works in the general case.
Then we will have
$$\int_{[0,1]}G(x,\xi)\varphi(\xi)\,d\xi=\int_{[0,x]}G(x,\xi)\xi ^2\,d\xi+\int_{[x,1]}G(x,\xi)\xi ^2\,d\xi=:\mathcal{I}_1+\mathcal{I}_2$$
Now:
$$\xi\in[0,x]\Rightarrow\xi\leq x\Rightarrow G(x,\xi)=\left( \xi+1 \right) x$$
therefore
$$\mathcal{I}1=\int{[0,x]}\left( \xi+1 \right) x\xi^2\,d\xi=x\int_{[0,x]}\left( \xi^3+\xi^2 \right)\,d\xi$$
and similarly
$$\xi\in[x,1]\Rightarrow\xi\geq x\Rightarrow G(x,\xi)=\left( x+1 \right) \xi$$
$$\mathcal{I}2=\int{[x,1]}(x+1)\xi^3\,d\xi=(x+1)\int_{[x,1]}\xi^3\,d\xi$$
Now:
$$\mathcal{I}1= x\left[\frac{\xi^4}{4}+\frac{\xi^3}{3}\right]{\xi=0}^{\xi=x}=\frac{x^5}{4}+\frac{x^4}{3}$$
and
$$\mathcal{I}2=(x+1)\left[\frac{\xi^4}{4}\right]{\xi=x}^{\xi=1}=(x+1)\cdot\frac{1}{4}(1-x^4)=\frac{1+x-x^4-x^5}{4}$$
Therefore
$$\mathcal{I}= \mathcal{I}_1+\mathcal{I}_2=\frac{x^5}{4}+\frac{x^4}{3}+\frac{1}{4}+\frac{x}{4}-\frac{x^4}{4}-\frac{x^5}{4}=\frac{3+3x+x^4}{12}$$
Now observe that the problem is linear and its the solution can be written as the sum of the solution to the homogeneous equation with inhomogeneous boundary conditions and the inhomogeneous equation with homogeneous boundary conditions.
Clearly, the Green function would solve the latter.
We also need to solve the homogeneous differential equation associated with this system imposing the inhomogeneous constraints, thus obtaining a solution. If we call the solutions respectively
$$y_H\text{ and } y_I$$
by linearity we obtain
$$y=y_H+y_I$$
So we find the the second solution, which is the solution to the system
$$\frac{d^2}{dx^2}y=0;\quad y(0)=y'(0)+1; \quad y(1)=y'(1)+2$$
We have already shown that the solution to the differential equation is
$$y=c_0x+c_1$$
whose derivative is
$$\frac{d}{dx} y=c_0$$
Now
$$y(0)=y'(0)+1\Rightarrow c_1=1+c_0$$
$$y(1)=y'(1)+2\Rightarrow c_0+c_1=c_0+2\Rightarrow c_1=2$$
Thus
$$2=1+c_0\Rightarrow c_0=1$$
and hence
$$y_I(x)=x+2$$
Finally
$$y=y_H+y_I=\frac{3+3x+x^4}{12}+x+2=\frac{x^4}{12} + \frac{5x}{4} + \frac{9}{4}$$
as requested.