Solving ODE involving piece-wise function This question may sound very trivial but I really can't figure out how to solve this.
It has been a while since I solved ODEs and I need to solve an equation similar to one given below for some application.
Basically it's an ODE with a piece wise definition.
$$ \frac{d^{2}u}{dx^{2}}+Q(x)=0 \quad \text{For} \; 0<=x<=1\\
Q(x) = 
\begin{cases}
0,  & 0<=x<=0.5 \\
20 – 40x, & 0.5<x<=0.75  \\
40x – 40, & x>0.75  \\
\end{cases}\\
\text{with boundary conditions}\\
u(0)=0\\
u(1)=0
$$
How do I go about solving it? Of course I can't just integrate it.
I don't need someone to solve entire problem for me. Just shepherding me in right direction should be enough.
 A: Solve the equation three times: one in each of the regions singled out by the definition of $Q(x)$. There will be six constants of integration (three second-order differential equations) and you will want to enforce continuity of $u(x)$ and $u'(x)$, as well as the given boundary conditions.
A: You actually can just integrate it. The integral of $-Q(x)$ is given by
$$R(x) = 
\begin{cases}
0,  & 0<=x<=0.5 \\
20x^2-20x, & 0.5<x<=0.75  \\
40x-20x^2, & x>0.75  \\
\end{cases}\\
$$
The way I got that should be pretty obvious. Make sure that when you evaluate it, you end up evaluating each section only over it's domain.
A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left( #1 \right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$$
{\rm u}'\pars{x}={\rm u}'\pars{0} - \int_{0}^{x}{\rm Q}\pars{t}\,\dd t
$$

\begin{align}
{\rm u}\pars{x}&=\overbrace{{\rm u}\pars{0}}^{\ds{=\ 0}}\ + {\rm u}'\pars{0}x - \int_{0}^{x}\dd t\int_{0}^{t}{\rm Q}\pars{s}\,\dd s
=\overbrace{{\rm u}\pars{0}}^{\ds{=\ 0}}\ + {\rm u}'\pars{0}x
-\int_{0}^{x}\dd s\,{\rm Q}\pars{s}\int_{s}^{x}\dd t
\\[3mm]&={\rm u}'\pars{0}x - \int_{0}^{x}\pars{x - s}{\rm Q}\pars{s}\,\dd s
\end{align}

$$
0 = {\rm u}\pars{1} =
{\rm u}'\pars{0} -\int_{0}^{1}\pars{1 - s}{\rm Q}\pars{s}\,\dd s
\quad\imp\quad
{\rm u}'\pars{0} = \int_{0}^{1}\pars{1 - s}{\rm Q}\pars{s}\,\dd s
$$

$$
{\rm u}\pars{x} = x\int_{0}^{1}\pars{1 - s}{\rm Q}\pars{s}\,\dd s
- \int_{0}^{x}\pars{x - s}{\rm Q}\pars{s}\,\dd s
$$

$$
\color{#00f}{\large{\rm u}\pars{x}
=\pars{1 - x}\int_{0}^{x}{\rm Q}\pars{s}\,\dd s
+ x\int_{x}^{1}\pars{1 - s}{\rm Q}\pars{s}\,\dd s}
$$
$\large\tt\mbox{Replace}$ ${\large {\rm Q}\pars{s}}$
$\large\tt\mbox{and integrate it !!!}$.
