Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inequality as constraints on NDSolve

157 views
Skip to first unread message

Stefano Pasetto

unread,
Jan 5, 2010, 1:42:09 AM1/5/10
to
Dear Mathematica experts:

is there a possibility to implement a constraint in NDSolve?

Suppose I want to solve

NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2 x[t] - y[t]^3, x[0] == y[0]
== 1}, {x, y}, {t, 20}]

But I want that the solutions satisfied the inequality x[t]>0 for every t
(because it represent a physical quantity that has no meaning to be
negative), i.e., and when it becomes =0 it has to stay zero. I've tried
something like

x[t_]:=If[x[t]>0,x[t],0]

in the definition of x or y but it does not make sense. Somehow, I'd need to
change the solution of the system when the solution itself become negative.

ThankX for the help, :-)

Best regards

Stefano Pasetto

dh

unread,
Jan 6, 2010, 6:00:38 AM1/6/10
to

Hi Stefano,

I think you are attacking your problem the wrong way. If the DE says

that the solution becomes negative then you can not simply request that

is is zero. In your case, the model does obviously not mirror the

physical system.

Now, if you can live with the imperfection of you model, you may simply

force the solution not to be nagative by taking the Max[0, solution].

But it will be better if you look for a better model that suits the

physical system.

Daniel

0 new messages