Skip to main content
integrated J.M.'s comment
Source Link
anderstood
  • 14.5k
  • 2
  • 32
  • 82

Another possibility, probably not as good as the ones proposed here but which can be helpful in some other cases, is to extract the boundaries of the interval on which the InterpolatingFunction is defined. This is done below in the line {{xmin, xmax}} = myfcn[[1, 1]];myfcn["Domain"]; (thank you @J.M. for this info). Then, a piecewise function is built, defined only on the appropriate interval.

myfcn = Interpolation[Table[{x, 2 x^3 - 5 x^4/3 + 5 x/2}, {x, 1, 1.5, 0.1}]];
{{xmin, xmax}} = myfcn[[1, 1]];myfcn["Domain"];
myfcn2[x_] = Piecewise[{{myfcn[x], xmin <= x <= xmax}}, Indeterminate];
ContourPlot[myfcn2[x t] == t, {t, 0, 5}, {x, 0, 1}, MaxRecursion -> 3]

enter image description here

(I copied the output from MichaelE2's answer as there is no visible difference).

Another possibility, probably not as good as the ones proposed here but which can be helpful in some other cases, is to extract the boundaries of the interval on which the InterpolatingFunction is defined. This is done below in the line {xmin, xmax} = myfcn[[1, 1]];. Then, a piecewise function is built, defined only on the appropriate interval.

myfcn = Interpolation[Table[{x, 2 x^3 - 5 x^4/3 + 5 x/2}, {x, 1, 1.5, 0.1}]];
{xmin, xmax} = myfcn[[1, 1]];
myfcn2[x_] = Piecewise[{{myfcn[x], xmin <= x <= xmax}}, Indeterminate];
ContourPlot[myfcn2[x t] == t, {t, 0, 5}, {x, 0, 1}, MaxRecursion -> 3]

enter image description here

(I copied the output from MichaelE2's answer as there is no visible difference).

Another possibility, probably not as good as the ones proposed here but which can be helpful in some other cases, is to extract the boundaries of the interval on which the InterpolatingFunction is defined. This is done below in the line {{xmin, xmax}} = myfcn["Domain"]; (thank you @J.M. for this info). Then, a piecewise function is built, defined only on the appropriate interval.

myfcn = Interpolation[Table[{x, 2 x^3 - 5 x^4/3 + 5 x/2}, {x, 1, 1.5, 0.1}]];
{{xmin, xmax}} = myfcn["Domain"];
myfcn2[x_] = Piecewise[{{myfcn[x], xmin <= x <= xmax}}, Indeterminate];
ContourPlot[myfcn2[x t] == t, {t, 0, 5}, {x, 0, 1}, MaxRecursion -> 3]

enter image description here

(I copied the output from MichaelE2's answer as there is no visible difference).

Source Link
anderstood
  • 14.5k
  • 2
  • 32
  • 82

Another possibility, probably not as good as the ones proposed here but which can be helpful in some other cases, is to extract the boundaries of the interval on which the InterpolatingFunction is defined. This is done below in the line {xmin, xmax} = myfcn[[1, 1]];. Then, a piecewise function is built, defined only on the appropriate interval.

myfcn = Interpolation[Table[{x, 2 x^3 - 5 x^4/3 + 5 x/2}, {x, 1, 1.5, 0.1}]];
{xmin, xmax} = myfcn[[1, 1]];
myfcn2[x_] = Piecewise[{{myfcn[x], xmin <= x <= xmax}}, Indeterminate];
ContourPlot[myfcn2[x t] == t, {t, 0, 5}, {x, 0, 1}, MaxRecursion -> 3]

enter image description here

(I copied the output from MichaelE2's answer as there is no visible difference).