RE:Inverse Interpolating Functions
- To: mathgroup at smc.vnet.net
- Subject: [mg29241] RE:[mg29221] Inverse Interpolating Functions
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Thu, 7 Jun 2001 01:14:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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 http://www.verbeia.com/mathematica/tips/Tricks.html