Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a system of ODEs whose time courses I'd like to numerically integrate. One of these should have a continuous strictly decreasing term and a discontinuous increasing term. It looks something like this:

d[A]/dt = -k*A over the whole interval

and additionally

d[A]/dt = c for t in every 10 steps (if t%10 == 0)

I have encoded the first one as ODE in SBML, the 2nd one as discrete event. Using numerical solvers like LSODE or CVODE fail to integrate this, however, with a root finding error.

What is the best way to encode such an ODE in a way that the solvers above can handle?

Ok I found the issue:

d[A]/dt = c for t in every 10 steps (if t%10 == 0)

does not work because t does not need to be divisible by 10 at any point. The following works:

d[A]/dt = c for t in every 10 steps (if t%10 < 0.01)
share|cite|improve this question

For what it's worth: usually for ODEs with discontinuous functions involved, it is a good idea to ensure that the routine/function in your computing environment supports "event detection"; Mathematica has the Method -> {"EventLocator", (*sub-options*)} for NDSolve[], and the FORTRAN routines by Hairer and Wanner support this capability as well.

share|cite|improve this answer
CVODE is supposed to support it as well. – user538603 Jul 1 '11 at 18:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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