# Find function inverse

I'm trying to find the inverse of a function:

(30*x^2 (1 - x)^2) (* where 0<x<1 *)


I tried all the following options:

1.

InverseFunction[ConditionalExpression[30*#1^2 (1 - #1)^2, 0 < #1 < 1] &]


2.

f = Function[30*#^2 (1 - #)^2] &

g = InverseFunction[f]


3.

g[x_] = 30*x^2 (1 - x)^2

sol = Solve[y == x^2 &&  0 < x < 1, x]

D[x /. sol[[1]], y]


Thank you so much in advance!

Solve also works

Solve[y == 30 x^2 (1 - x)^2 && 0 < x < 1, x, Reals]

{{x -> ConditionalExpression[Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 2], 0 < y < 15/8]},
{x -> ConditionalExpression[Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 3], 0 < y < 15/8]}}


Use ToRadicals to get it in a nice looking form.

• why does mathematica convert x into #1 ? Commented Sep 20, 2014 at 18:28
• @user19754 That's not really what's happening here. Please read this: (24945) as well as the documentation for Root. Commented Sep 20, 2014 at 19:10

Your second approach is nearly correct. Modify it like so.

f = 30*#^2 (1 - #)^2 &;
g = InverseFunction[f]

1/30 (15 - Sqrt[15] Sqrt[15 - 2 Sqrt[30] Sqrt[#1]]) &

Plot[f[g[x]], {x, 0, 1}]


• Hm... I overlooked that mistake. +1 Commented Sep 20, 2014 at 13:11
• this gives an error "InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses. " Commented Sep 20, 2014 at 13:14
• @user19754 Right. See my answer for a different treatment. Commented Sep 20, 2014 at 13:17
• @user19754. It's not an error message. It's a warning. In the domain {0, 1}, the g is fine. In the domain x < 0, it is not valid. You can turn it off with Quiet. Commented Sep 20, 2014 at 13:22
• @Mr.Wizard. In the domain {0,1}, specified by the OP, either brach will work. The way the question is posed, makes me think the OP would be satisfied by any functional form that works in his domain, and and is not interested in the complete set. Commented Sep 20, 2014 at 13:36

Reduce appears to provide useful information:

Reduce[{(30*x^2 (1 - x)^2) == y, 0 < x < 1}, x, Reals]

(0 < y < 15/8 && (x == Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 2] ||
x == Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 3])) || (y == 15/8 && x == 1/2)


ToRadicals can be used to put this into a more familiar form.

% // ToRadicals

(0 < y < 15/8 && (x == 1/2 (1 + Sqrt[15 - 2 Sqrt[30] Sqrt[y]]/Sqrt[15]) ||
x == 1/2 (1 - Sqrt[15 + 2 Sqrt[30] Sqrt[y]]/Sqrt[15]))) || (y == 15/8 && x == 1/2)


Branches:

Plot[
{1/2 (1 + Sqrt[15 - 2 Sqrt[30] Sqrt[y]]/Sqrt[15]),
1/2 (1 - Sqrt[15 + 2 Sqrt[30] Sqrt[y]]/Sqrt[15])},
{y, 0, 15/8}
]


• Thank you for this option! For some reason, mine output is all in decimals, I wonder if I can reset it globally to output fractions Commented Sep 20, 2014 at 18:35
• never mind, it works great! Commented Sep 20, 2014 at 18:44

A good comprehensive answer should explain why InverseFunction "didn't work", however there's been no explanation so far. A unique inverse function can be found in a region if there its jacobian is nondegenerate, i.e. its determinant doesn't vanish (Inverse function theorem) . For one - variable function it means that the derivative doesn't vanish.

Reduce[ D[ 30 #1^2 (1 - #1)^2 &[x], x] != 0, x, Reals]

x < 0 || 0 < x < 1/2 || 1/2 < x < 1 || x > 1


Now taking any of the specified ranges InverseFunction works expectedly:

InverseFunction[ ConditionalExpression[30*#1^2 (1 - #1)^2, 0 < #1 < 1/2] &][y]

ConditionalExpression[Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 2], 0 < y < 15/8]

InverseFunction[ ConditionalExpression[30*#1^2 (1 - #1)^2, 1/2 < #1 < 1] &][y]

ConditionalExpression[Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, 3], 0 < y < 15/8]


so depending on the region inverse function might be any of Root[-y + 30 #1^2 - 60 #1^3 + 30 #1^4 &, k] for $k=1\ldots4$.

Invertibility of the given function is restrected to appropriate regions, this can be easily seen from the following plot

Plot[ 30 #1^2 (1 - #1)^2 &[x], {x, -1/4, 5/4}, PlotStyle -> Thick,
Epilog -> {Red, Thickness[0.008], Line[{{-1/2, 0}, {0, 0}}],
Blue, Line[{{0, 0}, {1/2, 0}}],
Darker @ Green, Line[{{1/2, 0}, {1, 0}}],
Darker @ Magenta, Line[{{1, 0}, {3/2, 0}}],
Red, Dashed, Line[{{{0, 3}, {0, -1}}, {{1/2, 3}, {1/2, -1}},
{{1, 3}, {1, -1}}}]}]


• Artes, this is a great explanation. How do we deal with functions such as the one given in this question where there are multiple monotone regions? For example y=x^2 is monotone on $(-\infty,0)$ and $(0, \infty)$ . Is it possible for mathematica to recognize that and give two answers like -sqrt(y) for the first region and and sqrt(y) for the second? Commented Sep 21, 2014 at 14:49
• @user19754 Great? No upvotes so far... Reduce[y == x^2, x, Reals] yields y >= 0 && (x == -Sqrt[y] || x == Sqrt[y]). Perhaps also FunctionDomain[InverseFunction[#^2 &][x], x] could be useful however this should be more a bit precise question. Commented Sep 21, 2014 at 15:19
• Artes, Reduce[y == x^2 && x > -1 && x < 1, x, Reals] works, giving (0 < y < 1 && (x == -Sqrt[y] || x == Sqrt[y]), but it does not give us the information that for -Sqrt[y] x must be from -1 to 0 and for the other one, from 0 to 1. I'm sorry if my question is confusing Commented Sep 21, 2014 at 16:06
purify[f_, x_] := Function @@ {f /. x -> #}

fun = 30*x^2 (1 - x)^2;

inv = InverseFunction[purify[fun, x]][x] // Quiet


LogPlot[{fun, inv}, {x, 0, 1}, PlotTheme -> "Detailed"]


• thank you for a nice option. It does not output the range for y though. Commented Sep 20, 2014 at 18:41