Let's make an InterpolatingFunction
:
if = Interpolation[Transpose[{#, Sin@#} &@Range[0, 4, 0.1]]];
As expected, evaluating it outside of its domain switches from interpolation to extrapolation, giving a pretty wacky result. However, Mathematica helpfully warns you about this
if[10]
(* InterpolatingFunction::dmval: Input value {10} lies outside the range of data in the interpolating function. Extrapolation will be used.
36.3612 *)
However, when I go and Plot
it, no such warning is offered:
Plot[if[t], {t, 0, 10}]
This is in Mathematica 12.0+. I have a strong recollection that I used to get warnings when I tried to plot InterpolatingFunction
s outside their domain, and if at all possible I would really like to have that behavior back.
ColorFunction
, e.g.,Plot[if[t], {t, 0, 10}, ColorFunction -> Function[{t, f}, If[t > if[[1, 1, -1]], Red, ColorData[97][1]]], ColorFunctionScaling -> False]
$\endgroup$Plot[]
does suppress error messages. Consider the following:test[t_] := If[TrueQ[Between[t, if["Domain"]]], if[t], Message[InterpolatingFunction::dmval, t]; Undefined]; Plot[test[t], {t, 0, 10}]
$\endgroup$if = Interpolation[Transpose[{#, Sin@#} &@Range[0, 4, 0.1]], "ExtrapolationHandler" -> {Indeterminate &, "WarningMessage" -> False}]
so that extrapolation is not used. $\endgroup$