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

enter image description here

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

  • 2
    $\begingroup$ Have you defined tau? $\endgroup$
    – yarchik
    Sep 9 at 5:37
  • $\begingroup$ setting $\tau=1$ $\endgroup$
    – sined
    Sep 9 at 5:47
  • 1
    $\begingroup$ Please update your post, not everyone is reading comments $\endgroup$
    – yarchik
    Sep 9 at 5:51

This can be done as follows.

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]


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



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]


also works, but perfoms the same warning as yours.

  • $\begingroup$ 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. $\endgroup$
    – sined
    Sep 9 at 13:50
  • 1
    $\begingroup$ g[10^{-3},1,1] produces 2218.03 and a warning (not an error) quoted by you. $\endgroup$
    – user64494
    Sep 9 at 14:08
  • $\begingroup$ 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." $\endgroup$
    – sined
    Sep 9 at 14:25
  • 1
    $\begingroup$ 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. $\endgroup$
    – user64494
    Sep 9 at 14:40

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.