MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Inverse Interpolating Functions

  • To: mathgroup at
  • Subject: [mg29244] RE: [mg29221] Inverse Interpolating Functions
  • From: "David Park" <djmp at>
  • Date: Thu, 7 Jun 2001 01:14:49 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Ted's improvement is certainly more elegant and general, but I think that if
the function is decreasing we have to reverse the lists and range. So, I
think this is more correct.

    (Less @@ #1[[4,2]] || Greater @@ #1[[4,2]] & )] :=
  If[f[[4,2,1]] < f[[4,2,-1]], InterpolatingFunction[
    {{f[[4,2,1]], f[[4,2,-1]]}}, f[[2]], {f[[4,2]]},
    {f[[4,1]], f[[3,1]]}], InterpolatingFunction[
    {Reverse[{f[[4,2,1]], f[[4,2,-1]]}]}, f[[2]],
    {Reverse[f[[4,2]]]}, {f[[4,1]], Reverse[f[[3,1]]]}]]

There is also another method, which is using Mathematica more correctly, but
which doesn't seem to give any better results. I show this below.  Here is a
sample case again.

f = FunctionInterpolation[Sin[x], {x, -(Pi/2), Pi/2},
   InterpolationPoints -> 401, InterpolationOrder -> 5]

g1 = InverseInterpolatingFunction[f]

This is the alternative method.

g2 = Interpolation[Transpose[{f[[4,2]], f[[3,1]]}]]

Plot[g1[f[x]] - x, {x, -Pi/2, Pi/2}, Frame -> True,
   PlotRange -> All];
Plot[f[g1[x]] - x, {x, -1, 1}, Frame -> True,
   PlotRange -> All];

Plot[g2[f[x]] - x, {x, -Pi/2, Pi/2}, Frame -> True,
   PlotRange -> All];
Plot[f[g2[x]] - x, {x, -1, 1}, Frame -> True,
   PlotRange -> All];

The problem is that there is significant error near the end of the domains.
Otherwise, it is quite good. And it works better for functions that don't
approach zero slope.

I would still be interested in knowing what is the best method to obtain an
inverse InterpolatingFunction for a monotonic function.

David Park
djmp at

> From: Ersek, Ted R [mailto:ErsekTR at]
To: mathgroup at
> Dave Park wrote about making an interpolating function for the inverse of
> f[x] when we already have an interpolating function of f[x] which is
> monotonic. I give you an implementation that works if the samples are
> monotonically increasing or decreasing.  I also think this
> implementation is
> a little more elegant and direct than the one you had.
>   In[1]:=
>   InverseInterpolatingFunction[(f_InterpolatingFunction)?
> (Less@@Part[#,4,2]||Greater@@Part[#,4,2]& )] :=
>   InterpolatingFunction[{{f[[4,2,1]],f[[4,2,-1]]}}, f[[2]], {f[[4,2]]},
> {f[[4,1]], f[[3,1]]}]
> How mathematically sound is this?  I don't know, but FunctionInterpolation
> adaptively samples a function so that the interpolation meets certain
> criteria for precision and accuracy.  Who knows how well the same samples
> work for making an interpolation of the inverse function.
> One thing that could be useful is a version that would take the function
> whose inverse we want to approximate and return a good
> InterpolatingFunction
> of the inverse. If adaptive sampling shows that the function
> isn't monotonic
> over the range of interest we would get back $Failed.  Then we
> could do for
> example:
>   In[3]:=
>    g = InverseInterpolatingFunction[ Sin[x]+x,  {x,0, Pi/2} ];
>    In[4]:=
>     g[1.5]
>    Out[4]=  0.789793
>    In[5]:=
>     Sin[0.789793] + 0.789793
>    Out[5]=  1.5
> I did a little bit of experimenting to try and get this working,
> but it was
> taking too much time.  If we have a version that does what I show
> above, it
> wouldn't care if the function was a symbolic expression or an
> InterpolatingFunction.  I might work on it sometime.
> -----
>   Ted Ersek
>      Download Mathematica tips, tricks from

  • Prev by Date: RE:Inverse Interpolating Functions
  • Next by Date: Using rules with MathLink
  • Previous by thread: RE:Inverse Interpolating Functions
  • Next by thread: RE: Inverse Interpolating Functions