9
$\begingroup$

InverseFunction works well for globally invertible functions, like

f = 2*# + 2 &;
InverseFunction[f]
1/2 (-2 + #1) &

However, how would one for example find the inverse of $f(x)=x^2$ around $(x,f(x))=(1,1)$? My Mathematica (8.0.4) gives me a warning about multivalued inverses in this case, as well as the result $-\sqrt{x}$, which is not the branch that I'm looking for:

f = #^2 &
InverseFunction[f]
#1^2 &

InverseFunction::ifun: 
  Inverse functions are being used. Values may be lost for multivalued inverses. >>

-Sqrt[#1] &

So: How can I specify the neighbourhood a function should be inverted on?

$\endgroup$

3 Answers 3

14
$\begingroup$

Something like this is helpful :

InverseFunction[ConditionalExpression[#1^2, 2 > #1 > 0] &]

yields

ConditionalExpression[Sqrt[#1], 0 <= #1 <= 4] &

Then you can use it as an ordinary function, e.g. :

Integrate[%[x], {x, 1/2, 3/2}]
1/6 (-Sqrt[2] + 3 Sqrt[6]) 

or

D[ConditionalExpression[Sqrt[#1], 1/4 <= #1 <= 9/4] &[x], x]
ConditionalExpression[1/(2 Sqrt[x]), 1/4 <= x <= 9/4]
Plot[ConditionalExpression[Sqrt[#1], 1/4 <= #1 <= 9/4] &[x],
                         {x, 1/4, 9/4}, AxesOrigin -> {0, 0}]

enter image description here

$\endgroup$
6
$\begingroup$

You can also use Solve (or Reduce) to obtain the inverse function and pick the branch that matches your neighbourhood point. A simple approach to obtain $x(y)$ given $y(x)$ and $\{x_0, y (x_0)\}$ is the following:

inverseFunc[func_, x_, y_, {a_, b_}] := Module[{f, sols},
    Pick[#, # /. {Rule -> Equal, x -> a, f -> b} // Flatten] &@
      Solve[f == func, {x}] /. f -> y
]

For your example of $f(x)=x^2$:

inverseFunc[x^2, x, y, {1, 1}]
Out[1]= {{x -> Sqrt[y]}}
$\endgroup$
5
$\begingroup$

Being a nonexpert, this is how I invert any kind of weird functions:

f[x_]:=x^2;
invf=Interpolation[Table[{f[x],x},{x,3,6,0.1}]]

InterpolatingFunction[{{9.,36.}},<>]

invf[25]

5.

$\endgroup$
1
  • 5
    $\begingroup$ For numerical inverses, another, possibly better, method is given in the Applications section of the documentation for FindRoot. $\endgroup$ Commented Feb 27, 2012 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.