Solving an ODE with a sign function Is there a way to solve differential equations of the form
$$\frac{d^{2}x}{dt^{2}} + x = -\mathrm{sgn}(\frac{dx}{dt})?$$ I've never seen these types of differential equations before and I have no idea how to start.
 A: The solutions to this ODE are rather interesting. In outline, general solution oscillates with linearly decreasing amplitude until the amplitude decays to zero. If the solution is non-zero at that point it just stops, and cannot be continued to more positive $t$. Otherwise it remains zero for ever.
More precisely, we must construct the solutions piecewise. Each piece covers a part of the solution where $\frac{dx}{dt}$ is either always positive or always negative, or always zero.


*

*If $\frac{dx}{dt}$ is positive, the equation simplifies to


$$\frac{d^2x}{dt^2} + x = -1$$
which has solutions of the form
$$x = A\sin(t-B) - 1$$
for $A>0$. Such a solution covers the range $B - \pi/2 < t < B + \pi/2$. 


*

*Similarly, if $\frac{dx}{dt}$ is negative, the possible solutions have the form


$$x = 1 - A\sin(t-B)$$
If we try to join these up to make a continuous function, we find that the two types of piece must alternate, and that each new piece decreases $A$ by 2 (and increases $B$ by $\pi$). Once $A$ decreases below 2, it is not possible to add on any more pieces, and the solution stops dead.
There is one more case possible: $x = 0$. It is valid for all $t$. It also joins cleanly onto solutions of the other two types if $A = 2$.
