# Non-numerical values for integral

I am trying to solve the following integral numerically

SEND[d_?NumericQ] := NIntegrate[NIntegrate[k ((1/\[Tau]) Exp[-2 k d])/((1/\[Tau])^2 + (\[Omega]+k Cos[\[Theta]]+k Sin[\[Theta]])^2), {k,0,Infinity}], {\[Theta],0,2\[Pi]}]


but Mathematica keeps giving me the error

I have tried everything I could find, e.g., finite integration interval, use of ?NumericQ. Any clue? Thanks

• Have you defined tau? Sep 9 '21 at 5:37
• setting $\tau=1$ Sep 9 '21 at 5:47

This can be done as follows.

ClearAll["Global*"];
f[\[Theta]_?NumericQ, d_?NumericQ, \[Omega]_?NumericQ, \[Tau]_?NumericQ] :=
NIntegrate[k ((1/\[Tau]) Exp[-2 k d])/((1/\[Tau])^2 + (\[Omega] +
k Cos[\[Theta]] + k Sin[\[Theta]])^2), {k, 0, Infinity}]
f[Pi/4, 1, Pi/3, 2]


0.0281453

g[d_?NumericQ, \[Omega]_?NumericQ, \[Tau]_?NumericQ] :=
NIntegrate[f[\[Theta], d, \[Omega], \[Tau]], {\[Theta], 0, 2 *Pi}]
g[4, 1, 1]


0.050794

SEND[d_?NumericQ, \[Omega]_?NumericQ, \[Tau]_?NumericQ] :=
NIntegrate[NIntegrate[ k ((1/\[Tau]) Exp[-2 k d])/((1/\[Tau])^2 + (\[Omega] +  k Cos[\[Theta]] + k Sin[\[Theta]])^2), {k, 0,
Infinity}], {\[Theta], 0, 2 \[Pi]}]
SEND[4, 1, 1]


0.050794

also works, but perfoms the same warning as yours.

• Thank you. That works indeed. However, if I ask for g[10^{-3},1,1] I still encounter an issue: "NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small." Any idea of how to overcome that? I tried to increase MaxPoints and Workingprecisioin, but it did not work. Sep 9 '21 at 13:50
• g[10^{-3},1,1] produces 2218.03 and a warning (not an error) quoted by you. Sep 9 '21 at 14:08
• right, you are correct. but the error states about the inaccuracy of the value: "NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in [Theta] near {[Theta]} = {5.49769}. NIntegrate obtained 2214.5754409669808 and 30.909327582704197 for the integral and error estimates." Sep 9 '21 at 14:25
• You are right.: I overlooked an error communication.The code g[d_?NumericQ, \[Omega]_?NumericQ, \[Tau]_?NumericQ] := NIntegrate[f[\[Theta], d, \[Omega], \[Tau]], {\[Theta], 0, 2 *Pi}, AccuracyGoal -> 4, PrecisionGoal -> 4, MaxRecursion -> 30] g[10^-3, 1, 1] produces 2218.3` and only a warning. Sep 9 '21 at 14:40