# Solving a Piecewise ODE [closed]

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.

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