# Why is the default behaviour of DifferentialEquations to extrapolate the solution beyond the time range?

**URL:** <https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421>\
**Category:** General Usage\
**Tags:** diffeq\
**Created:** [June 15, 2023, 8:28pm UTC](https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421 "2023-06-15T20:28:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larbino1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larbino1/32/37831_2.png) [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Post date:** [June 15, 2023, 8:28pm UTC](https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421/1 "2023-06-15T20:28:12Z")

</div>

I just spent an entire afternoon debugging why my equation appears to go unstable. Stupidly, I was animating the solution for T=[0, 10], whereas the solution was solved on the interval T=[0, 3].

For clarity, my code (from memory) looked something like

‘’’  
T = 3.0  
sol = solve(ode\_problem, u0, T)

ts = LinRange(0.0, 10.0, 100)  
plot(sol.(ts))  
‘’’

While fully admitting my culpability, is this not a bit of a footgun? Can we protect silly people like me by throwing an error when ‘t’ in ‘sol(t)’ is outside the range of the solution?

Otherwise, thank you for what is an amazing package/ecosystem!

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [June 15, 2023, 11:23pm UTC](https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421/2 "2023-06-15T23:23:23Z")

</div>

Related issue [Allow to disable solution extrapolation · Issue #869 · SciML/DifferentialEquations.jl · GitHub](https://github.com/SciML/DifferentialEquations.jl/issues/869)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 16, 2023, 12:26pm UTC](https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421/3 "2023-06-16T12:26:10Z")

</div>

It’s used in things like prediction-correctors like in the DDE solvers themselves. We could definitely have a switch on it. We used to actually disallow extrapolation by default but then that error was removed because people said it got in the way of too many things 😅

---

<div class="post-metadata">

**Author:** ![Larbino1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/larbino1/32/37831_2.png) [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Post date:** [June 19, 2023, 11:03am UTC](https://discourse.julialang.org/t/why-is-the-default-behaviour-of-differentialequations-to-extrapolate-the-solution-beyond-the-time-range/100421/4 "2023-06-19T11:03:20Z")

</div>

Thanks for the reply. From my point of view, a default behaviour (; extrapolate\_solution=false) would have saved a headache, but I understand there is a large ecosystem depending upon DifferentialEquations with varying needs and use cases.
