2
$\begingroup$

For the expressions $f(r)=1-1/r$; $V(r)=f(r)*(2/r^2)$; $dr_*=1/f(r)dr$. I want to obtain the image of $V(r_*)$ as a function of $r_*$. One of my attempts is as follows:

Clear["`*"]
f[r_] = 1 - 1/r;
rstar[r_] = Integrate[1/f[r], r];
V[r_] = f[r]*2/r^2;
Vs[r_] = V@InverseFunction[rstar][r];
Plot[Vs[r], {r, -80, 80}, PlotRange -> All]

Finally, images of them can be obtained as follows, enter image description here. But how to implement it using numerical integration, ie. Command of NIntegrate[]. In other words, how to numerically integrate r* and then draw the image of $V(r_*)$ like the previous. This is because not all f(r) can be directly calculated using the inverse function.

I would appreciate it if one could sort it out. Thank you!

$\endgroup$
2
  • $\begingroup$ You mean, you want to change f(r) by some other function? $\endgroup$
    – A. Kato
    Commented Aug 6 at 4:57
  • $\begingroup$ Yes, especially the function f(r) cannot be integrated directly. Therefore, I would like to learn how to use numerical integration as an alternative method. $\endgroup$ Commented Aug 6 at 8:38

1 Answer 1

3
$\begingroup$

Your definition of rstar isn't unique

R=Values@(DSolve[rs'[r] == 1/f[r], rs, r][[1, 1]]/. C[1] -> c1)
(*Function[{r}, r + c1 + Log[-1 + r]]*)  
Plot[Table[R[r], {c1, -2, 2}], {r, -80, 80}]

enter image description here

Plot shows only for r>1 there exists Element[R,Reals]

Assuming rs[1 + ProductLog[1/Exp[1]]]==0 we get numerical version

rst[r_?NumericQ] := NIntegrate[1/f[\[Rho]], {\[Rho], 1 +ProductLog[1/Exp[1]], r}]
Plot[rst[r], {r, 1, 80}, AxesLabel -> {r, rstar}]

enter image description here

Finally

ParametricPlot[{rst[r], V[r]}, {r, 1, 80}, 
AxesLabel -> { "rstar[r]", "V[r]"} , AspectRatio -> 1 , 
PlotRange -> All, PlotPoints -> 1000]

enter image description here

$\endgroup$
3
  • $\begingroup$ Thanks. This is a nice and clear answer that helped me a lot. My problem has been greatly solved. However, I found that the current data is discrete and divided into two parts (rst[r], V[r]), which may not be conducive to further applications, such as V[r] may be a term in a partial differential equation like the Schrodinger equatio. Therefore, my question is, is there a way to integrate these two data into a function command, like (Vs[r_]) in my example, and finally use the Plot command to draw the graph. I am also trying to figure it out, thank you again. $\endgroup$ Commented Aug 6 at 8:07
  • $\begingroup$ This is my try, but it failed. Vstar = V[r] /. r -> rst[r]; Plot[Vstar, {r, 1, 80}, PlotRange -> {{-80, 80}, {-0.02, 0.31}}, PlotPoints -> 1000] $\endgroup$ Commented Aug 6 at 8:27
  • $\begingroup$ @littlestar Last plot shows the function V[rstar] you are looking for. You might take plottetd points to create an interpolation function. $\endgroup$ Commented Aug 6 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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