1
$\begingroup$

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

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

1 Answer 1

2
$\begingroup$

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

Addition

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.

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.