Examples of “strange” inverses

Example 1

Consider the function f(x)=((x^2+x)/2). The graph below clearly indicates that this function is a bijection on [0,1].  The inverse of this bijection can be calculated by hand.

Plot[{((x^2+x)/2)},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Solve[((y^2+y)/2)==x,y]

Plot[{((x^2+x)/2),(1/2) (-1+(Sqrt[1+8 x]))},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Example 2

Consider the function f(x)=((x^3+x^2+x)/3). The graph below clearly indicates that this function is a bijection on [0,1]. Mathematica can find its inverse.

Plot[{((x^3 +x^2+x)/3)},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Solve[((y^3+y^2+y)/3)==x,y]

So, Mathematica finds three roots for the above cubic equation. Which one will provide the inverse of our function can be verified by trial and error. Or, we can ask Mathematica to do it for us.

Simplify[Solve[((y^3+y^2+y)/3)==x,y,Reals],And[x>0,x<1]]

Root[-3 x+#1+((#1)^2)+((#1)^3)&,1]/.{x->.5}

Plot[{((x^3+x^2+x)/3),-(1/3)-((2 (2^(1/3)))/(3 (((7+81 x+9 (Sqrt[1+14 x+81 (x^2)])))^(1/3))))+((((7+81 x+9 (Sqrt[1+14 x+81 (x^2)])))^(1/3))/(3 (2^(1/3))))},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Or,

Plot[{((x^3+x^2+x)/3),Root[-3 x+#1+((#1)^2)+((#1)^3)&,1]},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Example 3

Consider the function f(x)=((x^4+x^3+x^2+x)/4). The graph below clearly indicates that this function is a bijection on [0,1]. I will show below how to find its inverse.

Plot[{((x^4+x^3+x^2+x)/4)},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Solve[((y^4+y^3+y^2+y)/4)==x,y]

Simplify[Solve[((y^4+y^3+y^2+y)/4)==x,y,Reals],And[x>0,x<1]]

Root[-4 x+#1+((#1)^2)+((#1)^3)+((#1)^4)&,1]/.{x->.5}

N[Root[-4 x+#1+((#1)^2)+((#1)^3)+((#1)^4)&,2]/.{x->.5}]

Root[-4 x+#1+((#1)^2)+((#1)^3)+((#1)^4)&,2]/.{x->.5}

Plot[{((x^4+x^3+x^2+x)/4),Root[-4 x+#1+((#1)^2)+((#1)^3)+((#1)^4)&,2]},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Example 4

Consider the function g(x)=((x^5+x^4+x^3+x^2+x)/5). The graph below clearly indicates that this function is a bijection on [0,1]. I will show below how to find its inverse.

Plot[{((x^5+x^4+x^3+x^2+x)/5)},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

Simplify[Solve[(((y^5)+y^4+y^3+y^2+y)/5)==x,y,Reals]]

Plot[{((x^5+x^4+x^3+x^2+x)/5),Root[-5 x+#1+((#1)^2)+((#1)^3)+((#1)^4)+((#1)^5)&,1]},{x,0,1},PlotRange->{0,1},AspectRatio->Automatic,ImageSize->300]

The concept of a pure function

Sometimes it is desirable to have a notation for a function that does not involve a specific name for a variable.  In Mathematica this can be done by the construct called pure function. Below is the square function written as a pure function acting on the number 2:

(((#)^2))&[2]

Or, something more complicated:

(Sin[#]+Log[((#)^2)+1])&[2]

Whenever a result of  a Mathematica command is a function Mathematica will output it as a pure function. For example Mathematica can guess a pattern of a sequence:

FindSequenceFunction[{1,4,9,16,25}]

FindSequenceFunction[{1+1,4+2,9+3,16+4,25+5}]

FindSequenceFunction[{1+(1^3),4+(2^3),9+(3^3),16+(4^3),25+(5^3)}]

How to apply a function to a table

First form a table to apply a function to:

mytbl=Table[k,{k,1,100}]

Now use the function Map to apply a given function to each element of the table:

Map[(#^2)&,mytbl]

Or, us a shortcut

(#^2)&/@mytbl

or, with a different function

(Sin[#])&/@mytbl