Message Boards Message Boards

0
|
5168 Views
|
11 Replies
|
1 Total Likes
View groups...
Share
Share this post:

NIntegrate::slwcon warning for definite integration

Posted 5 years ago

Hi, This integral seems to have a singularity.. all constants are defined.

NIntegrate[Exp[-alpha*Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + z^2]], {z, 10*-a, 
  10*(L - a)}, {theta, 0, 2 Pi}]

I get a NIntegrate::slwcon warning.

POSTED BY: Haress Nazary
11 Replies
Posted 5 years ago

This

alpha=1;R=2;x=3;a=4;L=5;
NIntegrate[Exp[-alpha*Sqrt[R^2-2*x*R*Cos[theta]+x^2+z^2]], {z,10-a,10(L-a)}, {theta,0,2 Pi}]

almost instantly gives

0.00743265

with no warnings or errors. So I assume your problem depends on the values of your constants.

Can you perhaps give the values of all your constants to show where and why there is a singularity? Possibly even include a 3d plot of the function to show where and how it blows up.

Note: If you put your Mathematica input on separate lines from your text and you put four spaces in front of each of those lines then the posting software will understand that this is Mathematica input and will do less desktop publishing, won't remove the * in your message, etc.

POSTED BY: Bill Nelson
Posted 5 years ago
alpha = 0.5;
R = 32;
L = 45;
a = 25;
s = Table[(1 - Exp[-alpha])*NIntegrate[Exp[-alpha*Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + z^2]], {z,10*-a, 10*(L - a)}, {theta, 0, 2 Pi}], {x, 0, 32}(*,{a,0,L}*)];

This is what I calculate. I get: 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.

POSTED BY: Haress Nazary

Your integrals seems in the beginning to be near zero, and NIntegrate seems to not like this. Look at

alpha = 0.5;
R = 32;
L = 45;
a = 25;
s = Table[{x, (1 - Exp[-alpha])*
     NIntegrate[
      Exp[-alpha*Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + z^2]], {z, 
       10*-a, 10*(L - a)}, {theta, 0, 2 Pi}]}, {x, 0, 32, 1}(*,{a,0,
   L}*)];
ListLinePlot[s, Epilog -> Point /@ s]

Looks reasonable - or?

@Bill Nelson: your integrand is not the same as in the problem.

POSTED BY: Hans Dolhaine
Posted 5 years ago

Excellent catch. Thank you

I was scraping this before he put his code into a code block which made his multiplication more explicit. I think I correctly saw the switch in italics inside his integrand, but I missed the italic minus signs in his limits of integration.

Thank you again

POSTED BY: Bill Nelson

Calculate this integral with NIntegrate?

POSTED BY: Daniel Lichtblau
Posted 5 years ago

Thanks, but this still gives me the same warning..

I don't have this problem anymore because I realized I made a mistake in coming up for the integral for my specific application.

POSTED BY: Haress Nazary

Code with no warnings:

 $Version
  (* "11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)" *)
 alpha = 1/2;
 R = 32;
 L = 45;
 a = 25;
 s = Table[(1 - Exp[-alpha])*
    NIntegrate[
     Exp[-alpha*Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + z^2]], {z, 
      10*-a, 10*(L - a)}, {theta, 0, 2 Pi}, 
     Method -> "LocalAdaptive"], {x, 0, 32}(*,{a,0,L}*)]


  (*{5.70737*10^-6, 6.02507*10^-6, 7.03033*10^-6, 
   8.88889*10^-6, 0.0000119095, 0.000016599, 0.0000237522, \
  0.0000345936, 0.0000509949, 0.0000758066, 0.000113361, 0.000170229, \
  0.000256365, 0.000386811, 0.00058424, 0.00088272, 0.00133324, \
  0.00201175, 0.00303073, 0.00455555, 0.00682723, 0.0101931, 0.0151465, \
  0.0223752, 0.0328135, 0.0476838, 0.0684951, 0.0969276, 0.13446, \
  0.181468, 0.235262, 0.286114, 0.309488}*)
POSTED BY: Mariusz Iwaniuk
Posted 5 years ago

what about this one?

alpha = 0.04; (*Absorptionskoeffizient*)
R = 32; (*Stabradius*)
L = 450; (*Stablänge*)
a = 210;
x = 32;
s = NIntegrate[
  Exp[-alpha*
     Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + 
       z^2]]/(Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2)]*
     Sqrt[1 + z^2/(R^2 - 2*x*R*Cos[theta] + (x)^2)]^3), {z, -a, 
   L - a}, {theta, 0, 2 Pi}]

or:

alpha = 0.4; (*Absorptionskoeffizient*)
R = 32; (*Stabradius*)
L = 450; (*Stablänge*)
a = 210;
x = 31;
s = NIntegrate[
  Exp[-alpha*
     Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + 
       z^2]]/(Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2)]*
     Sqrt[1 + z^2/(R^2 - 2*x*R*Cos[theta] + (x)^2)]^3), {z, -a, 
   L - a}, {theta, 0, 2 Pi}]
POSTED BY: Haress Nazary
alpha = 0.04;(*Absorptionskoeffizient*)R = 32;(*Stabradius*)L = \
450;(*Stablänge*)a = 210;
x = 32;
s = NIntegrate[
Exp[-alpha*
 Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + 
   z^2]]/(Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2)]*
 Sqrt[1 + z^2/(R^2 - 2*x*R*Cos[theta] + (x)^2)]^3), {z, -a, 
L - a}, {theta, 0, 2 Pi}, Method -> "GaussKronrodRule"]

(*2.66833*)

Works fine.

POSTED BY: Mariusz Iwaniuk
Posted 5 years ago

thanks. this still gives me problems:

alpha = 0.9; (*Absorptionskoeffizient*)
R = 32; (*Stabradius*)
L = 45; (*Stablänge*)
(*a=250;*)
s = Table[(*{x,
   a*10,*)(1 - Exp[-alpha])*
    NIntegrate[
     Exp[-alpha*
        Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + 
          z^2]]/(Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2)]*
        Sqrt[1 + z^2/(R^2 - 2*x*R*Cos[theta] + (x)^2)]^3), {z, -10 a, 
      10*(L - a)}, {theta, 0, 2 Pi}, 
     Method -> "GaussKronrodRule"], {x, 0, 32}, {a, 0, L}];
POSTED BY: Haress Nazary
alpha = 9/10;(*Absorptionskoeffizient*)R = 32;(*Stabradius*)
L = 45;(*Stablänge*)(*a=250;*);

f[x_?NumericQ, a_?NumericQ] := (1 - Exp[-alpha])*
  NIntegrate[
   Exp[-alpha*
      Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + 
        z^2]]/(Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2)]*
      Sqrt[1 + z^2/(R^2 - 2*x*R*Cos[theta] + (x)^2)]^3), {z, -10 a, 
    10*(L - a)}, {theta, 0, 2 Pi}, Method -> "LocalAdaptive", 
   MaxRecursion -> 100]

   f[31, 45](*x=31,a=45 ,OK*)
   (* 0.0184785 *)
   f[32, 45](*For x = 32 ,a=45 Not OK *)
   (* "The integrand  has evaluated to Overflow, Indeterminate, or Infinity  " *)
   f[33, 45](*x=33,a=45  OK*)
   (* 0.0179095*)

For certain values x,and a integral is divergent.

We can see:

 FunctionDomain[E^(-(9/10) Sqrt[1024 + x^2 + z^2 - 64 x Cos[theta]])/(
  Sqrt[1024 + x^2 - 
    64 x Cos[theta]] (1 + z^2/(1024 + x^2 - 64 x Cos[theta]))^(3/2)),
   x]
 (*x^2 - 64 x Cos[theta] > -1024 *)

 Table[x^2 - 64 x Cos[theta] > -1024 /. theta -> 2 Pi, {x, 31, 33}]
  (*{True, False, True}*)(* For x =32 is not true*)
POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract