# A problem in the application of numerical integration

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, . 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!

• You mean, you want to change f(r) by some other function? Commented Aug 6 at 4:57
• 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. Commented Aug 6 at 8:38

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


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


Finally

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


• 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. Commented Aug 6 at 8:07
• 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] Commented Aug 6 at 8:27
• @littlestar Last plot shows the function V[rstar]` you are looking for. You might take plottetd points to create an interpolation function. Commented Aug 6 at 14:07