0
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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.]

Addendum

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}]

enter image description here

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

| improve this answer | |
$\endgroup$
  • $\begingroup$ Solve doesn't work for other values of $q$. BTW, I have a large parameter space $q<1$. $\endgroup$ – user583893 Oct 3 '19 at 3:06
  • $\begingroup$ My goal is to reuse the output of inverse function as a function $\endgroup$ – user583893 Oct 3 '19 at 11:34
  • $\begingroup$ 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? $\endgroup$ – user583893 Oct 5 '19 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.