6

Here's the code:

yan = FunctionInterpolation[x^2, {x, -1, 1}];
FullSimplify[yan[x] > -1, -1 < x < 1]

Needless to say, what I expect to see in the output is "True", but FullSimplify doesn't seem to work. What function should I turn to?


@J.M. @belisarius @acl

囧…A very simple solution suddenly struck me, it is:

yan = FunctionInterpolation[x^2, {x, -1, 1}];
MinValue[{yan[x], -1 < x < 1},x]>-1
xzczd
  • 65,995
  • 9
  • 163
  • 468
  • Huh? "seems not to work" is correct? I just delete it because of my language sense…OK, let me add it back. – xzczd Aug 06 '12 at 05:55
  • "doesn't seem to work" as you added is more standard, but in my opinion "seems not to work" is also acceptable and understandable. – Mr.Wizard Aug 06 '12 at 06:10
  • In fact I've become confused after I searched the Internet, so I turned to the standard form to be on the safe side 囧. – xzczd Aug 06 '12 at 06:47

3 Answers3

6

You can do this by explicitly constructing the InterpolatingPolynomial corresponding to yan, and then using FullSimplify:

yin = InterpolatingPolynomial[Transpose[Flatten /@ {yan[[3]],yan[[4]]}],x];
FullSimplify[yin > -1, -1 < x < 1]
(*True*)

Why does this work? Because yan actually has a list of points:

FullForm[yan]

Mathematica graphics

so I can extract them with Transpose[Flatten /@ {yan[[3]],yan[[4]]}] and use them to construct a polynomial, which does the same thing as the interpolation function but which FullSimplify can now handle.

Maybe there's a better way to construct the InterpolatingPolynomial but this works.

acl
  • 19,834
  • 3
  • 66
  • 91
6

The following is basically the same @acl did, but using the package InterpolatingFunctionAnatomy which (in principle) will behave better than peeking at the internal structures when Mma version changes.

Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"];
yan = FunctionInterpolation[x^2, {x, -1, 1}];

yin = InterpolatingPolynomial[Transpose[Flatten /@
                                {InterpolatingFunctionCoordinates@yan, 
                                 InterpolatingFunctionValuesOnGrid@yan}], x];
FullSimplify[yin > -1, -1 < x < 1]
(*
  True
*)
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • very nice. how come I have less votes than you though, despite being first and explaining details?! Not fair! :) – acl Aug 05 '12 at 19:38
  • @acl That was because I forgot to upvote your answer. Easy to correct! :D – Dr. belisarius Aug 05 '12 at 19:40
  • really, I was joking! – acl Aug 05 '12 at 19:48
  • 1
    In fact, you don't need to load the package if you remember the actual syntax being used internally; in this case, it's yan["Coordinates"] and yan["ValuesOnGrid"] that can be used directly. Still, this works only because the original function was well approximated by a polynomial. In general, a polynomial interpolant can be more oscillatory than the piecewise polynomial interpolant used by InterpolatingFunction[]; be careful! – J. M.'s missing motivation Aug 05 '12 at 23:48
  • @J.M. yes, it was intended just for this case – Dr. belisarius Aug 05 '12 at 23:52
  • @J.M. So, in fact this is still not a perfect solution for this problem? Huh…whatever! It's enough for me, in my case it won't make a big difference even if InterpolatingPolynomial causes some oscillation. By the way, where can I find those syntax in the help? – xzczd Aug 06 '12 at 06:30
  • @xzczd, definitely not the perfect solution. To use the classical example (due to Carl Runge), try FunctionInterpolation[1/(1 + x^2), {x, -2, 2}]. InterpolatingPolynomial[] will fail spectacularly to reproduce the original interpolating function. – J. M.'s missing motivation Aug 06 '12 at 06:41
  • @J.M. Haha, it's really spectacular. By the way, where can I find those syntax ("Coordinates" "ValuesOnGrid" etc.) in the help? – xzczd Aug 06 '12 at 08:18
  • @xzczd, they aren't (explicitly) documented, but try looking up InterpolatingFunctionAnatomy in the docs. – J. M.'s missing motivation Aug 06 '12 at 10:39
  • @xzczd Search for InterpolatingFunctionAnatomy in this site. You'll find some nice applications for it – Dr. belisarius Aug 06 '12 at 14:57
0

Today I ocasionally recall this question I asked 10 years ago, and notice nowadays ResourceFunction["InterpolatingFunctionToPiecewise"] or InterpolationToPiecewise in this post seems to be the best choice to resolve the problem:

yan = FunctionInterpolation[x^2, {x, -1, 1}];
yanAnalytic = ResourceFunction["InterpolatingFunctionToPiecewise"][yan, x]
FullSimplify[yanAnalytic > -1, -1 < x < 1]
(* True *)

This method perfectly handles the troublesome case shown by J.M., too:

func = FunctionInterpolation[1/(1 + x^2), {x, -2, 2}];
funcAnalytic = ResourceFunction["InterpolatingFunctionToPiecewise"][func, x];
Simplify[funcAnalytic < 3/2, -2 < x < 2]
(* True *)

BTW, I don't evaluate my MinValue method in the question as the best, because it's essentially a numeric method. MinValue has secretly called NMinimize internally!:

Trace[MinValue[{yan[x], -1 < x < 1}, x], __NMinimize, TraceInternal -> True]

enter image description here

xzczd
  • 65,995
  • 9
  • 163
  • 468