Message Boards Message Boards


Has anyone seen a bug with NDSolve using both Floor and a transformation?

Posted 10 years ago
1 Reply
2 Total Likes
I ran into this problem using a slightly complicated model, but made as simple an example as I could to identify the exact problem.

What I found was that, when solving a system of differential equations numerically, if NDSolve was asked to deal with both a floor function (e.g. Floor) and an algebraic transformation (e.g. y[t-5]), then it will not work. For example, the code
NDSolve[{y'[t] == y[t - 7]*Floor[t], y[0] == 3}, {y[t]}, {t, 0, 2000}]
returns the errors
NDSolve::ihist: "Conditions given at t = 0.` will be interpreted as initial history functions for t/;t<=0.. "
NDSolve::ndssc: Step size changed sign at t == 14.`. 
and it only Interpolates from [{{0,14}},<>]

Even though running NDSolve with a function involving either y[t-7] or Floor alone works fine. (For example, NDSolve is able to compute the following two lines of code.)
NDSolve[{x'[t] == Floor[t], x[0] == 0}, {x[t]}, {t, 0, 2000}]
NDSolve[{y'[t] == y[t - 7], y[0] == 3}, {y[t]}, {t, 0, 2000}]

Finally, and most perplexingly, if you run NDSolve on the previous two functions together instead of separately, even though they do not depend on each other, it still returns errors as in the first example.  
NDSolve[{x'[t] == Floor[t], y'[t] == y[t - 7], x[0] == 0,
  y[0] == 3}, {x[t], y[t]}, {t, 0, 2000}]
NDSolve::ihist: "Conditions given at t = 0.` will be interpreted as initial history functions for t/;t<=0.. "NDSolve::ndssc: Step size changed sign at t == 14.`. Interpolates from [{{0,14}},<>]

Does anyone know anything about an error like this?
POSTED BY: Jamby Humbert
Delay Differential equations are tricky and I can imagine that such a discontinuous delay differential equation might throw a wrench whatever the automatically selected solver is in this case.

The documentation has a tutorial on working with Delay Differential Equations. It's a pretty good read and gives you some idea of the issues involved in numerically solving these kinds of equations. 

When specifying the boundary conditions for a delay differential equation, please use this syntax:
y[t /; t <= 0] == 3.
This says that y for t<=0 is 3.

Your problem can be resolved by using Method->"StiffnessSwitching" along side MaxSteps->Infinity:
NDSolve[{y'[t] == y[t - 7]*Floor[t], y[t /; t <= 0] == 3}, {y[t]}, {t, 0, 2000}, Method -> "StiffnessSwitching", MaxSteps -> Infinity]
StiffnessSwitching is often a very useful value for Method to try. You may want to compare against the method of steps mentioned in the documentation. 
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract