# Domain specifications for InverseFunction

I have difficulty implementing on how to specify the domain that I want for ry which is the inverse function of rho. The necessary condition is that, $$\textbf{ry}$$ must remain $$\textbf{positive}$$ for any positive or negative value of y. Also, at $$y=0$$, ry should have the value $$\textbf{1}$$. I have tried adding Refine in the code but it does not solve the problem. Note also that the InverseFunction is unable to evaluate negative values of $$y$$.

q = -1;
b0 = 1;
ry = InverseFunction[rho[#] &];
dry[y_] := D[ry[y], y] // Simplify
rho[r_] := Refine[(2 b0)/(1 - q) Sqrt[1 - (b0/r)^(1 - q)]Hypergeometric2F1[1/2, (q - 2)/(q - 1), 3/2, 1 - (b0/r)^(1 - q)],r > 0] // Simplify;(*throat profile*)


Any help is appreciated. Thanks

Why not just use Solve?

Solve[rho[r] == z && r>0, r, Reals]


{{r -> ConditionalExpression[Sqrt[1 + z^2], z > 0]}}

For values of q other than -1 you will also need to specify the value of z. For example:

q = 1/2;
Quiet @ Solve[rho[r] == 2 && r>0, r, Reals] //N


{{r -> 1.45108}}

You can use ConditionalExpression with InverseFunction to restrict the domain:

q=1/2;
ry = InverseFunction[ConditionalExpression[rho[#], #>0]&];

N @ ry[2]


1.45108

However, I find InverseFunction with ConditionalExpression buggy. For example, the following doesn't evaluate:

ry[2.]


InverseFunction[ConditionalExpression[rho[#1], #1 > 0] &][2.]

Addressing the OP comment. You can use FindRoot instead of Solve, and turn it into a function:

f[q_, b0_][r_] := (2 b0)/(1-q) Sqrt[1-(b0/r)^(1-q)]Hypergeometric2F1[1/2,(q-2)/(q-1),3/2,1-(b0/r)^(1-q)]

inv[q_?NumericQ, b0_?NumericQ][x_] := r /. FindRoot[f[q,b0][r]==x, {r, 1+x}]


You can use inv as a function:

Plot[inv[1/5,1][x],{x,0,10}]


It is also possible to turn the inverse problem into an ODE and use ParametricNDSolveValue.

• Solve doesn't work for other values of $q$. BTW, I have a large parameter space $q<1$. – user583893 Oct 3 '19 at 3:06
• My goal is to reuse the output of inverse function as a function – user583893 Oct 3 '19 at 11:34
• Hi @Carl Woll, thanks for the help. One last thing, how can I specify the derivative of the inverse function and again turn it into function? – user583893 Oct 5 '19 at 7:48