# how to adjust the limits of this numerical integral?

I have a complicated function as follows:

f[rp_] := (E^(-2 rp^2 \[Gamma]) M^2 norm^2 \[Pi]^(
3/2) (E^((M \[Alpha] - 2 me rp \[Gamma])^2/(
2 (M^2 \[Beta] +
me^2 \[Gamma]))) ((-1 + E^((4 M me rp \[Alpha] \[Gamma])/(
M^2 \[Beta] + me^2 \[Gamma]))) M \[Alpha] +
2 (1 + E^((4 M me rp \[Alpha] \[Gamma])/(
M^2 \[Beta] + me^2 \[Gamma]))) me rp \[Gamma]) +
E^((M \[Alpha] - 2 me rp \[Gamma])^2/(
2 (M^2 \[Beta] + me^2 \[Gamma]))) (M \[Alpha] -
2 me rp \[Gamma]) Erf[(M \[Alpha] - 2 me rp \[Gamma])/(
Sqrt[2] M Sqrt[\[Beta] + (me^2 \[Gamma])/M^2])] -
E^((M \[Alpha] + 2 me rp \[Gamma])^2/(
2 (M^2 \[Beta] + me^2 \[Gamma]))) (M \[Alpha] +
2 me rp \[Gamma]) Erf[(M \[Alpha] + 2 me rp \[Gamma])/(
Sqrt[2] M Sqrt[\[Beta] + (me^2 \[Gamma])/M^2])]))/(8 Sqrt[2]
me rp \[Gamma] (M^2 \[Beta] + me^2 \[Gamma]) Sqrt[\[Beta] + (
me^2 \[Gamma])/M^2]);


I want to do some calculations on f function to obtain my desire final number. In this vein I need to integrate over rp as follows $$\int_{|re-r|}^{re+r} f(r_p) dr_p \tag{1}$$ As Mathematica can't solve (1) analytically, I have to use NIntegrate, but when I try (1) numerically

NIntegrate[f[rp], {rp, Abs[re - r], r + re}, {re, 0, \[Infinity]}, {r, 0, \[Infinity]}]


where the numerical values of constants are

me = 1;
mp = 1;
M = mp + me;
\[Omega] = 100;
\[Gamma] = SetPrecision[0.5*M*\[Omega], 50];
{\[Alpha], \[Beta]} = \
{0.40731020595362082969970174417539965361356735229492187550.,
24.58661827021306933716005005408078432083129882812550.};
norm = 189.2253326188998254888908479720045476056553654261503687655661\
49.454966552225144;


I get this error:

NIntegrate::nlim: rp = Abs[-1. r+re] is not a valid limit of integration.


So how can I solve my integral?! Any idea?

• You doesn't show the call to NIntegrate: Perhaps re,r isn't defined yet? You should also provide numerical values for all the parameters! Nov 15, 2021 at 14:42
• Please see the update Nov 15, 2021 at 14:44
• NIntegrate is a numerical function and needs numerical parameter values! Nov 15, 2021 at 14:48
• the situation is the same when I add limits of re and r. Please see the update again Nov 15, 2021 at 14:51
• Have you defined numerical values for $\alpha$, $\beta$, $\gamma$, M, norm, and me? You haven't provided them in the code above, and NIntegrate definitely won't work if you don't. Nov 15, 2021 at 14:54

Changing the order of the integration seems to help. I'm not sure why; it probably has something to do with how Mathematica does its sampling. The documentation for NIntegrate says that "The first variable given [for the integration region] corresponds to the outermost integral and is done last", so it is plausible that the limits of the first integration variable must be numeric.
NIntegrate[f[rp], {re, 0, \[Infinity]}, {r, 0, \[Infinity]}, {rp, Abs[re - r], r + re}]

(* 3.98439 *)
`