I need to invert a function. I want to isolate the x basically. By the looks of the graphic I plotted, the function seems to be invertible, however when I call InverseFunction it doesn't return an output.

Here is my code:

g[x_] := E^(-x/2) - E^(x/2)
Plot[g[x], {x, -100, 100}, PlotRange -> All]

InverseFunction operates on an abstract function, yielding an abstract, anonymous function. g[x] is not a function, but a formula. Just leave out [x].

On 11.3, MacOS:

(* 2 Log[1/2 (-#1 - Sqrt[4 + #1^2])] & *)

Unfortunately, although it's an inverse, this doesn't appear to be the branch you want.


You can get @Henrik Schumacher's answer mindlessly by manipulating the defining expression for g (using = to evaluate before defining):

g[x_] = E^(-x/2) - E^(x/2) // ExpToTrig
(* -2 Sinh[x/2] *)

This coaxes InverseFunction onto the branch you probably want:

(* -2 ArcSinh[#1/2] & *)
  • $\begingroup$ Hello John, using this code the return I obtain is just g^(-1). $\endgroup$ – MarV Jul 21 '18 at 13:04
  • $\begingroup$ Hello John, can you send me your full code? For the first branch you calculated. $\endgroup$ – MarV Jul 21 '18 at 13:26
  • $\begingroup$ In a fresh kernel, g[x_] := E^(-x/2) - E^(x/2); ginv=InverseFunction[g]. g[ginv[y]] // FullSimplify yields y, but ginv[g[y]] winds up on the wrong branch. $\endgroup$ – John Doty Jul 21 '18 at 13:49
  • $\begingroup$ Thank you! I solved it manually and then it became clearer in the code. Now it works! $\endgroup$ – MarV Jul 30 '18 at 13:56

Your function g is equal to -2 Sinh[x/2]:

g[x_] := E^(-x/2) - E^(x/2);
FullSimplify[-2 Sinh[x/2] == g[x]]


So you are looking for

ginv[y_] := -2 ArcSinh[y/2]
  • $\begingroup$ Hello Henrik! That is a life saver, how did you figure that out? Is there any principle or rule? If possible do you have time to explain how -2 Sinh[x/2] == g[x]? $\endgroup$ – MarV Jul 21 '18 at 13:01
  • $\begingroup$ No principle behind that. Basically, Sinh[x] == (E^x - E^-x)/2 is the definition of the sinus hyperbolicus. $\endgroup$ – Henrik Schumacher Jul 21 '18 at 13:04
  • 1
    $\begingroup$ g[x] // ExpToTrig $\endgroup$ – John Doty Jul 21 '18 at 13:10

Here's another way to get the correct inverse function using Solve, which allows me to specify that the function is defined on the real axis:

Clear[x, y];
g[x_] := E^(-x/2) - E^(x/2)

gInverse[y_] = ExpToTrig[x /. First@Solve[g[x] == y, x, Reals]]

(* ==> -2 ArcSinh[y/2] *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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