Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to build a table of InverseFunctions, f.e.:

Table[InverseFunction[Head[foo][#] &][x], {foo, {Sin[x], Log[x], Sqrt[x]}}]

{ArcSin[x], E^x, Power(-1)[x]}

I' m frustrated by the fact that Sqrt[x] evaluates to Power ... instead of x^2. As a temporary fix I have written:

Table[InverseFunction[(Head[foo] /. Power -> Sqrt)[#] &][x], {foo, {Sin[x], Log[x], Sqrt[x]}}] 

which gives the desired result:

{ArcSin[x], E^x, x^2}

I would like to find a more general and reliable way to prevent this kind of "Head-Substitution". I tried many things with HoldForm etc., but to no avail.

Thanks for your ideas

share|improve this question
This is cosely related: Inverting a function in a certain region – Artes Aug 6 '14 at 10:43
up vote 3 down vote accepted

If you use ToString, make sure you specify InputForm (compare ToString[1/x] v.s. ToString[1/x, InputForm]).

Why not something like this?

pureify[f_, x_] := Function @@ {f /. x -> #}

Table[InverseFunction[pureify[foo, x]][x], {foo, {Sin[x], Log[x], Sqrt[x]}}]

(* {ArcSin[x], E^x, x^2} *)
share|improve this answer
Magnificent and exactly what I was hoping for :) – eldo Aug 6 '14 at 18:12

Thanks to @hieron suggestion to start with the "pure" heads I found this solution:

GetHeads[fun_] := ToExpression@First@StringSplit[ToString[fun], "["]

f = GetHeads /@ {Sin[x], Log[x], Sqrt[x]}

{Sin, Log, Sqrt}

Table[InverseFunction[foo[#] &][x], {foo, f}]

{ArcSin[x], E^x, x^2}

share|improve this answer

Without "Head-Substitution", you may achieve it:

inv = InverseFunction /@ {Sin, Log, Sqrt}
x // inv // Through


{ArcSin[x], E^x, x^2}


Yes, to get rid of the arguments I just wanted to suggest you

inv = InverseFunction /@ 
  ToExpression /@ (StringTake[#, {1, -4}] & /@ToString /@ {Sin[x], Log[x], Sqrt[x]})
x // inv // Through

But I was not so happy with StringTake, you got the more general way finally

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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