Group Abstract Group Abstract

Message Boards Message Boards

Defining a function to estimate a function's inverse?

Posted 4 years ago
POSTED BY: Steve Kilner
5 Replies

Dear @Steve Kilner, dear @Gianluca Gorni,

in my first reply above I used interpolation only to generate some (as I said) not necessarily analytic function. (Then reversing the points here would be somewhat "pointless".) Of course there is no need to do it like so in general when an inverse is wanted. And as you input an analytic expression it is certainly not necessary here. Without having looked at the code too closely, this modification seems to point into the right direction:

ClearAll[f, g, xx];
Manipulate[
 f[xx_] := Evaluate[p /. x -> xx];
 inv = InverseFunction[f];
 l = Min[{f'[a], f'[b]}];
 u = Max[{f'[a], f'[b]}];
 Plot[NIntegrate[inv[x], {x, 0, m}], {m, -.99, .99}, 
  PlotStyle -> Directive@{Yellow, Dashed}, 
  AxesOrigin -> {0, 0}], {{p, Cos[x], 
   Text[Style[TraditionalForm["f(x)= "], Blue, Italic, 18]]}, 
  ControlType -> InputField}, 
 Row[{Control[{{a, -1.57, 
      Text[Style[TraditionalForm["a= "], Blue, Italic, 12]]}, 
     InputField, ImageSize -> Tiny}], 
   Control[{{b, 1.57, 
      Text[Style[TraditionalForm["b= "], Blue, Italic, 12]]}, 
     ControlType -> InputField, ImageSize -> Tiny}]}], 
 SynchronousUpdating -> True]

The problem now basically is the invertibility of Cos[x] - for comparison try e.g. simply x.

POSTED BY: Henrik Schachner

No need for InverseFunction. Simply reverse the pairs of points to interpolate:

Plot[x + Sin[x], {x, 0, 10}]
ptsReversed = Table[N[{x + Sin[x], x}], {x, 0, 10, 1/10}];
ListPlot@ptsReversed
inv = Interpolation[ptsReversed, InterpolationOrder -> 1]
Plot[inv[x], {x, 0, inv["Domain"][[1, 2]]}]
POSTED BY: Gianluca Gorni

Steve, you can use InverseFunction; here is an example:

(* define some invertible - not necessarily analytic - function 'f': *)
pts = Table[N[{x, x + Sin[x]}], {x, 0, 10}];
f = Interpolation[pts];
(* define the inverse function: *)
inv = InverseFunction[f];
(* plot the respective expression: *)
Plot[m*inv[m] + NIntegrate[f[t], {t, 0, inv[m]}], {m, 0, 4}]
POSTED BY: Henrik Schachner
Posted 4 years ago
POSTED BY: Steve Kilner
Posted 4 years ago
POSTED BY: Steve Kilner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard