Numeric antiderivative for a noncontinuous function using ODEProblem

  1. If you know where the discontinuity is, you should tell the solver where it is; otherwise the problem is much harder (and you should probably specify a larger error tolerance). This is true for any numerical method — integration methods are usually designed for smooth functions.
  2. In general, you almost never want to evaluate definite integrals by solving ODEs — specialized integration routines are much more efficient (and simpler to use), because they exploit the fact that you have “random access” to your integrand values at any point in the domain (rather than having to build it up from “left to right” as in a general ODE). To be able to evaluate the integral at arbitrary points in a given interval, see How do I do a fast cumulative integration - #6 by stevengj
2 Likes