Does anyone know how to solve this equation in Mathematica

dx/dt = f(x) + u


f(x) = -x, if x < 1 or x = 1


closed as off-topic by Michael E2, rhermans, garej, Henrik Schumacher, bbgodfrey Jul 12 at 0:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, rhermans, garej, Henrik Schumacher, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Look at Piecewise to define the function and at DSolve for the solution of the differential equation. $\endgroup$ – bill s Jul 6 at 16:55
  • $\begingroup$ I have written Dsolve[x'[t] == u + f[x], x[t], t] but I don't know how to continue. Do you have any idea? $\endgroup$ – Evina Jul 6 at 17:10
  • 1
    $\begingroup$ Try DSolve instead of Dsolve. You can look up the help file by typing ?DSolve. $\endgroup$ – Bill Watts Jul 6 at 17:29
  • $\begingroup$ It's my mistake! I have written DSolve, my problem is how we solve the equation when we have the condition "x<1 or x=1". $\endgroup$ – Evina Jul 6 at 17:37

"$x<1$ or $x=1$" is simply $x\le1$. I'm assuming that $f(x)=0$ for $x>1$; please specify if this is not true.

f[x_] = Piecewise[{{-x, x <= 1}, {0, x > 0}}];

Solve the differential equation:

DSolve[x'[t] == f[x[t]] + u, x[t], t]

enter image description here

  • $\begingroup$ Thank you very much for the help!!!! $\endgroup$ – Evina Jul 6 at 19:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.