3
$\begingroup$

I have a set of ODEs solved with NDSolve which returns InterpolatingFunctions. When I am trying to plot them, it takes a long time to render. I am guessing that adaptive subdivision for the sharp features makes it slow. My question is: since the interpolation was done internally before NDSolve returns, is there any way we can obtain the list of data points NDSolve used to interpolate? Thanks.

$\endgroup$
2
6
$\begingroup$
iF = y /. NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}][[1]]

enter image description here

You can access the list of Properties of InterpolatingFunction object using

 PropertyList[iF]
 {"Coordinates", "DerivativeOrder", "Domain", "ElementMesh", "Evaluate", 
   "GetPolynomial", "Grid", "InterpolationMethod", "InterpolationOrder", 
   "MethodInformation", "Methods", "OutputDimensions", "Periodicity", "PlottableQ", 
   "Properties", "QuantityUnits", "Unpack", "ValuesOnGrid"}

or

  iF["Methods"]

same list

You can access the property p using iF[p]. For example,

iF["InterpolationOrder"]
 {3}
iF["Coordinates"] // Short[#, 3] &

enter image description here

iF["Grid"] // Short[#, 3] &

enter image description here

iF["ValuesOnGrid"] // Short[#, 3] &

enter image description here

etc.

$\endgroup$
2
  • $\begingroup$ Wonderful. Thanks. $\endgroup$ – QIZE SHU Apr 21 '20 at 22:34
  • 3
    $\begingroup$ From @MichaelE2's last link, you can also ListPlot[iF]. $\endgroup$ – Chris K Apr 22 '20 at 0:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.