# Problem with InverseFunction of Sqrt

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.

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} *)

• Magnificent and exactly what I was hoping for :)
– eldo
Aug 6, 2014 at 18:12

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}

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

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


out:

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


## Edit1:

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