1
$\begingroup$

I am trying to run the following code

l = N@Subdivide[-1, 1, 20][[;; -2]] + 1/20;
data = Table[NIntegrate[        
    1/2*r*
     Log[r^2 + (x^2 + y^2) - 2 r*Sqrt[x^2 + y^2]*Cos[t - ArcTan[x, y]]]
    , {t, 0, 2 Pi }, {r, 0, 1/Sqrt[4 Cos[t]^2 + 25 Sin[t]^2]}, 
    PrecisionGoal -> 6], {x, l}, {y, l}];

and I am getting the error

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.

The $x$ and $y$ are parameters for the integration. Is is possible to get the values of $x$ and $y$ for which I am getting the error?

$\endgroup$
1
  • $\begingroup$ NIntegrate::slwcon is a warning, not an error. If the integral fails to converge, then it's a hint about what might be the problem. If the integral converges, then it can be ignored. (Of course, numerical methods might mess up, that is, give a result that is erroneous without giving any message about it.) $\endgroup$
    – Michael E2
    Jul 16, 2023 at 15:38

1 Answer 1

3
$\begingroup$

If you define

int[x_?NumericQ, y_?NumericQ] := 
 NIntegrate[
  1/2*r*Log[
    r^2 + (x^2 + y^2) - 
     2 r*Sqrt[x^2 + y^2]*Cos[t - ArcTan[x, y]]], {t, 0, 2 Pi}, {r, 0, 
   1/Sqrt[4 Cos[t]^2 + 25 Sin[t]^2]},Method->"LocalAdaptive" ]

Plot3D shows a smooth surface without error message.

Plot3D[int[x, y], {x, -1, 1}, {y, -1, 1}]

enter image description here

Probably case x=0,y=0 causes the message in your solution grid!

Try

Table[{x, y, int[x, y]}, {x, Subdivide[-1, 1, 21]}, {y,Subdivide[-1, 1, 21]}]

which evaluates without error message

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.