How to get properties of interpolating function?

I have an InterpolatededFunction func and want to get some of its properties, namely:

  • Domain, Order, Method as shown in the output of func by clicking the plus-Button.
  • The functions pieces which are polynomials.
  • The value-range of the function within the domain.

I tried many things but did not succeed. The reason behind my problem is a complex plotting function that gets a function and a domain (= x-PlotRange), plots the function and many other things by Prolog and Epilog. I need a reasonable y-Plotrange which has at least to include the functions FunctionRange. Of course, I can use FindMaximum and FindMinimum, but its not so easy to get reasonable iteration starting points. Everything would be easier and faster if I had the information mentioned above.

Here is an example:

Block[{xs = {-2, 0, 1, 3, 4, 7}, ys = {0, 1, 3, 7, 2, -1}, data, xS, 
   xE, func, order = Automatic, method = "Spline"},
  xS = Min[xs]; xE = Max[xs];
  data = Thread[{xs, ys}];
  func = Interpolation[data, InterpolationOrder -> order, 
    Method -> method];
  Print[Column[{
     {xS, xE},
     data,
     {order, method},
     func,
     Plot[func[x], {x, xS, xE}, 
      Epilog -> {PointSize[Medium], Point[data]}, 
      AxesOrigin -> {0, 0}, ImageSize -> Small],
     Properties[func],
     FunctionRange[{func[x], xS <= x <= xE}, x, y]
     }]];
  ];

Werner,

All that information is available by looking at the FullForm. Do

func // FullForm

to see the format and use Part to get the info. For example,

dom = func[[1]] 

will give you the domain. You can even define your functions to pull the info out once you figure out what you need. For example, you can define

mydomain[x_InterpolatingFunction] := x[[1]]

Regards,

Neil

Recently I found a way to do it. Assume my InterpolatingFunction is stored in a variable, say x. Then

x["Methods"]

will return a list of available “fields”: {"Coordinates", "DerivativeOrder", "Domain", "ElementMesh", ...}. Then you can call any of them just like x["Coordinates"], x["Domain"] etc. By the may, there’re some fields regarding the “Method” of interpolation.

Thanks, Neil. This works, but is pretty tedious. I think Nicolay’s method is much clearer.

Thanks, Nicolay. This works indeed. I could not find that anywhere. Is it an undocumented feature?
If you write:

TableForm[{#,func[#]}&/@globFunc["Methods"]]

you get all the “properties” and you can see that the property “MethodInformation” needs more arguments and that the properties “Evaluate” and “GetPolynomial” do not work like this.

But I get the information which I really need: “InterpolationOrder”, “InterpolationMethod”, “Domain”, “Coordinates”, “ValuesOnGrid”.

This helps.

Block[{xs = {-2, 0, 1, 3, 4, 7}, ys = {0, 1, 3, 7, 2, -1}, data, xS, 
   xE, func, order = Automatic, method = "Spline"},
  xS = Min[xs]; xE = Max[xs];
  data = Thread[{xs, ys}];
  func = Interpolation[data, InterpolationOrder -> order, 
    Method -> method];
  Print[Column[{
     {xS, xE},
     data,
     {order, method},
     func,
     Plot[func[x], {x, xS, xE}, 
      Epilog -> {PointSize[Medium], Point[data]}, 
      AxesOrigin -> {0, 0}, ImageSize -> Small]
     }]];
  Print[Grid[{#, func[#]} & /@ globFunc["Methods"], 
    Alignment -> {{Right, Left}, Top}]]
  ];

Interesting. I was not aware of that. Thank you.

However, we should report this as a bug because the interpolation function should support [“Properties”] which I tried before posting my response but it returned useless information. Changing to “Method” instead of “Properties” violates the latest standard used throughout the language.

Regards,

Neil

You are totally right, Neil. This is a bug.
I tried Properties, Options, Information before my post and searched on the net. None of them gives something helpful.

I think I once reported a bug, but don’t remember how to do this. Can you tell me?