I'm trying to numerically solve an integral in a specific region and then to visualize it as follows.

 NIntegrate[1/Sqrt[r] - 1/Sqrt[l + r Sin[t]], {r, l, t} ∈
  ImplicitRegion[r + l Sin[t] > 0 && l > 0 && r > 0, {r, l, t}]], {r, 
  0, 5}, {l, 0, 10}, {t, 0, pi/4}]

However, Mathematica complains that

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.

I basically tried to get rid of potential singularities by taking that specific integration region into account. Yet, I have no idea about the slow convergence of highly oscillatory integrand.

Edit 1: There is also another warning saying

NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 27 recursive bisections in l near {r,l,t} = {0.184661,1.641681647898248*10^690538901,0.184661}. NIntegrate obtained 8.935806122974667*10^22717757165+31581.2 I and 2.096578395728379`15.954589770191005*^22717757166 for the integral and error estimates.

How can I fix these issues?

Edit 2: What I am actually looking for is the 3D plot corresponding to the following integral function F(l,\theta) where r is a fixed number (say, 10, or whatever). I am particularly in trouble to get rid of singularities and divergent subsets of the variable's domains.

enter image description here

  • $\begingroup$ Your formulation is unclear to me: after integration over {r,l,t} you obtain a number so what you plot in {r,l,t}? $\endgroup$
    – user64494
    Jul 29, 2019 at 17:38
  • $\begingroup$ @user64494: I actually doesn't want a single number, but the parametric plot of the result of the integration according to {r,l,t}. $\endgroup$
    – Pinton
    Jul 29, 2019 at 17:40
  • $\begingroup$ Don't understand. The result of NIntegrate[1/Sqrt[r] - 1/Sqrt[l + r Sin[t]], {r, l, t} ∈ ImplicitRegion[r + l Sin[t] > 0 && l > 0 && r > 0, {r, l, t}]] is a complex number (maybe, with its imaginary part equal to zero). $\endgroup$
    – user64494
    Jul 29, 2019 at 17:44
  • $\begingroup$ (1) Why RegionPlot3D? The syntax is wrong. (2) NIntegrate::slwcon is a warning, not an error: If there are no other errors, then the integral evaluated fine. Are there other error messages? $\endgroup$
    – Michael E2
    Jul 29, 2019 at 18:06
  • 1
    $\begingroup$ @MichaelE2: My basic interest is in the variation of the integral result regarding different combinations of l and t (with a fixed r). Considering I am not interested in infinity, can you please show me how to plot that integral function in terms of l and t? $\endgroup$
    – Pinton
    Jul 29, 2019 at 18:24

1 Answer 1


Maybe this will get you started:

ff[r_?NumericQ, t_?NumericQ, l_?NumericQ] := 
  NIntegrate[1/Sqrt[r] - 1/Sqrt[ll + r Sin[tt]], {tt, 0, t}, {ll, 0, l}];

Plot3D[ff[0.1, t, l], {t, 0, Pi}, {l, 0, 4}]

enter image description here

In the original code, there was a restriction, r + l Sin[t] > 0, but I'm not sure how you want to handle that. You might use Piecewise[] or multiply the integrand by Boole[r + ll Sin[tt] > 0], if appropriate.

  • $\begingroup$ Thanks a bunch! $\endgroup$
    – Pinton
    Jul 29, 2019 at 19:45
  • $\begingroup$ @Pinton You're welcome! $\endgroup$
    – Michael E2
    Jul 29, 2019 at 19:46

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.