ODE with modulus I want to solve the following ODE:
$$y''=|y|$$
However I don't really know how to deal with this modulus!
I tried to mess with the particular cases for $y>0$ and $y<0$ which have simple solutions.
Well, of course if $y\geq 0$ then $y(x)=Ae^x+Be^{−x}$ is an solution and if $y<0$ $y(x)=C\cos x+D\sin x$ is an solution. But I couldn't find constraints on these constants and neither could I find a general solution
I would appreciate any help.
 A: As the second derivative is positive, the function is convex. Also note that the equation is autonomous, so that the independent variable can be shifted arbitrarily.
The function can take negative values, and if it does so it follows a sinusoid in the negative $y$ region. In fact, we can reduce it to the single expression
$$y=-\cos x$$ by choosing the origin of $x$ suitably and adjusting the amplitude. Then when reaching the positive region, we switch to exponentials, and we must ensure continuity of the function and its first derivative,
$$y\left(-\frac\pi2\right)=0,y'\left(-\frac\pi2\right)=-1,$$
$$y\left(\frac\pi2\right)=0,y'\left(\frac\pi2\right)=1.$$
By the method of indeterminate constants, this gives us
$$y(x)=-\frac{e^{x+\pi/2}-e^{-\pi/2-x}}2=-\sinh\left(x+\frac\pi2\right),$$
$$y(x)=\frac{e^{x-\pi/2}-e^{\pi/2-x}}2=\sinh\left(x-\frac\pi2\right),$$ on the left and on the right.
The points where the curve crosses the axis are of the undulation type (zero curvature but no change of concavity).
If the function doesn't take negative values, the solution is an "ordinary" hyperbolic cosine (to an horizontal shift and a scaling). So there are essentially two solutions (which implicitly include $y=0$).

A: Recasting the differential equation as the first-order ODE system
\begin{aligned}
{X}' &= Y \\
{Y}' &= |X|
\end{aligned}
where $X = y$ and $Y = y'$, one obtains the following phase plot in the $X$-$Y$ plane:

First of all, we can observe that $y'' = |y| \geq 0$. Therefore, $y'$ is a non-decreasing function, i.e. all the trajectories in the $X$-$Y$ plane are going upwards. We restrict the analysis to $x\in \Bbb{R}_+$ and consider an initial-value problem. Several cases arise:
If $y'(0)\geq 0$, i.e. we start a trajectory in the upper-part of the phase plane, then we know that $y'(x) \geq 0$ for all $x \geq 0$. Therefore, $y$ is non-decreasing on $\Bbb R_+$, i.e. the trajectory goes to the right in the phase plane.


*

*if $y(0) \geq 0$ as well, then the solution to an initial-value problem is $y(x) = y(0) \cosh x + y'(0)\sinh x$.

*if $y(0)<0$, then the solution is $y(x) = y(0) \cos x + y'(0)\sin x$ until $y$ becomes positive, i.e. until $x=x^*$, where
$$
x^* = \left\lbrace
\begin{aligned}
&\frac{\pi}{2} &&\text{if}\quad y'(0) = 0 \, , \\
&-\arctan\left(\frac{y(0)}{y'(0)}\right) &&\text{if}\quad y'(0) > 0 \, .
\end{aligned}\right.
$$
In both cases, we have $y(x^*)= 0$ and $y'(x^*) \geq 0$, which corresponds to the first bullet point. Therefore, the solution is $y(x) = y'(x^*) \sinh(x-x^*)$ for $ x\geq x^*$, with 
\begin{aligned}
y'(x^*) &= -y(0)\sin x^* + y'(0) \cos x^* \\
&= -\left(y(0) + \frac{y'(0)^2}{y(0)}\right)\sin x^* .
\end{aligned}


It remains to solve the case $y'(0) < 0$ in a similar manner.
