1
$\begingroup$

I am attempting to solve a piecewise ODE.

$y' = \begin{cases} -1 & \text{for $y \geq 0$}\\ 1 & \text{for $y < 0$} \end{cases}, \qquad y(0)=0, \qquad x \in [0,1]$

I have attempted solving by the

DSolve[y'[x] == Piecewise[{{-1, y >= 0}, {1, y < 0}}], y[x], x]

However, the error always reports the function y has no arguments. Any help would be greatly appreciated.

$\endgroup$
  • 5
    $\begingroup$ try DSolve[y'[x] == Piecewise[{{-1, y[x] >= 0}, {1, y[x] < 0}}], y[x], x] as error says, y needs to have argument. $\endgroup$ – Nasser Apr 27 at 15:46
  • $\begingroup$ I can't seem to get a solution unless I drop the equal sign in the $y\geq 0$ part. $\endgroup$ – SuperCiocia Apr 27 at 22:47