# Confusion with function “InverseFunction”

Run codes below

InverseFunction /@ {InverseFunction, List, Reverse, RotateLeft, RotateRight, Sequence}


and one is returned with

{InverseFunction^(-1), #1 &, #1 &, #1 &, #1 &, #1 &}


For the first one, at least a formal answer is given (even though I hoped it gave something like InverseFunction itself); however for the rest it does not make sense that an identity function is obtained.

Ideally, Reverse is the inverse function of itself, and RotateRight and RotateLeft are inverse functions to each other.

Is it a bug?

• Since this behavior also appears in Mathematica 10.1 I am removing the version tag. – Mr.Wizard Jul 25 '18 at 6:55

I have never considered applying InverseFunction to Symbols such as these so I appreciate the question.

I hypothesize that, without a specifically defined inverse, the Symbol is tested on an arbitrary argument, e.g. Reverse[foo]. Since each of these heads do not actually do anything in such a case (other than issue a Message) they appear inert, and # & is a reasonable inverse of an inert function I suppose. Why this evaluation takes place rather than returning e.g. InverseFunction[Reverse] I don't know.

This idea seems plausible based the TracePrint, e.g.

InverseFunction[Reverse]; // TracePrint


(Reverse^(-1))

InverseFunction

Reverse

Reverse

Reverse[SolveInvFVar[0]]

Reverse

SolveInvFVar[0]

SolveInvFVar

0

SolveInvFVar[0]

SolveInvFVar

0

#1&

Function

Wherein SolveInvFVar[0] looks like the arbitrary argument I supposed.

• Will it be possible to incorporate it as built-in functionality that, say, InverseFunction[RotateLeft] returns RotateRight in the future? – Αλέξανδρος Ζεγγ Jul 26 '18 at 6:46
• @ΑλέξανδροςΖεγγ I am not a Wolfram Research developer, so if you are asking about "from the factory" functionality I have no idea. If you mean can one modify InverseFunction so that it will return that, yes, easily, but it may not be wise to do so. Try this if you care to: Unprotect[InverseFunction]; InverseFunction[RotateLeft] := RotateRight; InverseFunction[RotateRight] := RotateLeft; Protect[InverseFunction]; – Mr.Wizard Jul 26 '18 at 9:17
• Wizard Is it possible to use something like UpSet or TagSet? – Αλέξανδρος Ζεγγ Jul 26 '18 at 9:38
• @ΑλέξανδροςΖεγγ For Protected functions like RotateRight you would need to them (RotateRight) to use TagSet, but if you prefer that to unprotecting InverseFunction it's certainly an option. – Mr.Wizard Jul 26 '18 at 9:51