# Use Mathematica to plot the flow of an ODE with discontinuity

How can I use Mathematica to plot the flow of the following ODE in $$\mathbb R$$? $$\frac{d}{dt} X(t,x) = \chi_{\{x>0\}}(X(t,x)), t \in [0,T],$$ $$X(0,x) = x, x \in \mathbb R$$

where $$\chi$$ denotes the indicator function of a set.

I know about the command NDSolve, but is it applicable in this situation given the discontinuity in the source term? And I'd be mostly interested in rendering a nice picture of the flow.

Note that a related question was posed on MathOverflow.

T = 1;
Y = ParametricNDSolveValue[{X'[t] == Boole[X[t] > 0], X == 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"}
] • Incidentally, this is why I like Iverson brackets more than indicator functions; I find the latter more confusing to parse in general, whereas the Boole[] expression is concise and clear. – J. M.'s ennui Nov 29 '19 at 22:08
• Thank you very much. This looks very nice. It seems that there may be a nonuniqueness problem for trajectories starting at $x=0$. How does one identify in this picture the unique flow in the sense of DiPerna-Lions (php.math.unifi.it/users/cime/Courses/2005/02/…)? – Riku Nov 30 '19 at 12:37
• No, there is no nonuniqueness problem in thi case: For initial condition x>0, the right branch is taken and the left one for z <= 0. – Henrik Schumacher Nov 30 '19 at 12:59