# Plot solution of ODE with singularity

I wish to plot the solution of the following ODE:

T = 1;
Y = ParametricNDSolveValue[{X'[t] == Boole[X[t]<= 0]  - Boole[X[t] > 0], X[0] == x}, X, {t, 0, T}, {x}];
Show[
Table[
ParametricPlot[{Y[x][t], t}, {t, 0, T}],
{x, -1,1,0.1}
],
PlotRange -> All,
AxesLabel -> {"x", "t"}
]


But the code does not compute: I'm guessing because the characteristic accumulate at zero.

Simplify[Boole[X[t]<= 0]  - Boole[X[t] > 0]]


Piecewise[{{-1, X[t] > 0}}, 1]

So we can simplify ODE and get the plottable solution:

T = 1;
Y = ParametricNDSolveValue[{X'[t] == Piecewise[{{-1, X[t] > 0}}, 1],
X[0] == x}, X, {t, 0, T}, {x}]

Plot[Evaluate[Table[Y[x][t], {x, -1, 1, 0.1}]], {t, 0, T}, Frame -> True]


• That's very nice. Thank you. – Riku Dec 20 '19 at 16:15