2nd order linear differential equation with piece wise continuous in homogeneous term. $y^{ii}=f(x)$ where
$f(x)=\begin{cases}
0 ,& \text{ if } x \in [0,1/2]\\
1, & \text{ if } x \in (1/2,1]
\end{cases} $\
subject to $y'(0)=0,y(1)=1$
We can solve this differential equation by finite difference method.But how can we find exact solution of this differential equation ? Any body please help me.

$y^{''}=f(x)$ where
$f(x)=\begin{cases}
0 ,& \text{ if } x \in [0,\frac{1}{2}]\\
1, & \text{ if } x \in (\frac{1}{2},1]
\end{cases} $\
subject to $y^{'}(0)=0,y(1)=1$

The function must be continuous and differentiable. In $[0,\frac{1}{2}]$ we have $ y^{'} $ is constant: $ y = a + rx $. Then $ y^{'}(0)=0 $ gives: $ y=a , x \in [0,\frac{1}{2}]$.Similarly $  y=b+cx^2+dx , x \in (\frac{1}{2},1] $.
Continuity in $x=\frac{1}{2} \implies a=b+\frac{1}{4}c+\frac{1}{2}d $.
Differentiability in $x=\frac{1}{2} \implies d=-c $.
$y^{''}=1 \in (\frac{1}{2},1] \implies c=\frac{1}{2} $.
$y(1)=1 \implies b=1$. So the solution becomes:

$y=\frac{7}{8}  , x \in [0,\frac{1}{2}] \\ y=1+\frac{1}{2}x^2-\frac{1}{2}x  , x \in (\frac{1}{2},1]$

