Green Function for a Segment in $\mathbb{R}$ Besides just plugging and seeing that it works, is there a neat way to find the green function for Poisson's equation (Dirichlet BC) on a segment $[0,L]$?
I know it supposed to be of the form:
$$
G(x,y)=\left\{\begin{array}{cc}
-\frac{y}{L}\left(x-L\right) & x>y \\
\left(1-\frac{y}{L}\right)x & x\leq y
\end{array}\right.
$$
But I'd like to learn how to derive it.
 A: A Greens function $G(x,y)$ is a continuous function such that for each $x$, 
$$ -\partial_y^2 G(x,y) = \delta_x,\\ G(x,y)|_{y\in\{0,L\}}=0$$
These two conditions are enough to show that $f(x)=\int_0^L g(y)G(x,y) dy$ solves $-f''=g$ with Dirichlet boundary data.
If you do not know what the first equation means, you can take it to mean that $\partial_yG$ is a function such that 
\begin{align} y\neq x &\implies \partial^2_y G(x,y) = 0, \tag{A}\\
 \epsilon>0 &\implies \partial_y G(x,x+\epsilon) - \partial_y G(x,x-\epsilon) = -1 \tag{B}
\end{align}
(A) means that $\partial_y G$ is locally constant in $y$, away from $y=x$. (B) means that for each $x$, there is a single jump discontinuity in $\partial_y G$ at $y=x$. Hence, for each $x$, $G(x,y)$ is two line segments, one from $y=0$ to $y=x$ and another from $y=x$ to $y=L$. Therefore, there are $A(x),B(x),C(x),D(x)$ such that 
$$G(x,y) = \begin{cases}A(x)y+B(x) & y<x \\ C(x)y + D(x) & y \ge x   \end{cases}$$
with the constraints
\begin{align}
 G(x,0) = 0  &\implies B(x) = 0 \tag{1}
\\ G(x,L) = 0 &\implies D(x) = -C(x)L \tag{2}
\\ G(x,y) \text{ is $C^0$ at $y=x$} &\implies A(x)x = C(x)(x-L)  \tag{3}
\\ \partial_y G(x,y+) - \partial_y G(x,y-) = -1 &\implies C(x) = A(x)-1 \tag{4} \end{align}
(4) into (3) gives
$$A(x)x=(A(x)-1)(x-L)=A(x)x-x+L-LA(x) \\ \implies A(x)=-(x-L)/L $$
in summary
\begin{align} A(x)&=-(x-L)/L \\ B(x) &= 0 \\ C(x) &=-x/L \\ D(x) &= x 
\end{align}
giving the formula.
