I’m using an interpolation function defined over a limited range & using “Piecewise” to extend the range. This “Piecewise” function defines the derivative in “NDSolve.” The result seems to be correct, but an error message results indicating that the interpolation function is being asked to extrapolate out of its defined range. I have used “Piecewise” in the past with “NDSolve” without this error. Using “Integration” to integrate the “Piecewise” function doesn’t generate the error message. Here is a simplified version of the code:
Thanks. Sorry, i shouldn’t have used the word “error.” I know it’s just warning that it is extrapolating beyond the interpolation function’s defined range.
The issue is that because of the “Piecewise” function, h[t], “NDSolve” shouldn’t be calling the interpolation function outside it’s defined range. The attachment shows what my system looks like when I execute the example.
Note than when I plot the function,h[t], & use “NIntegrate,” there are no warning messages.
I am having the same problem. The attached notebook gives a minimal realization and a workaround, based on this discussion. To me, this seems a bug: NDSolveValue (and its cousins) misinterpret functions defined using Piecewise, generating an event and then somehow turning what should be a call within the defined range into an extrapolation.
If anyone can explain why this shouldn’t be considered a bug, I’d be very interested to understand why! And if it is a bug, hopefully, it can get corrected soon…
I contacted Wolfram Support. Apparently, the message is deliberate and reflects an internal evaluation that gets triggered whenever there is a discontinuity in the function.
In any case, an easier way to solve the issue is to use a built-in option for NDSolveValue: