Ok so I've found out that there are two singularities occuring at (r=1,phi=0) and (r=1,phi=2*pi)... But those singularities sit on the boundary of the integration, so this schouldn't be a problem for integral2, right?

Any guesses?

1 view (last 30 days)

Show older comments

Hi,

I'm having some problems using the integral2 function. I get the error "max number of function evalutations reached" for certain imput values.

This is my code:

lambda = 4;

a = 1.8821;

m = 1.0228;

psi = 1;

p = @(r) 3/pi*a*sqrt(1-r.^2)-2*lambda/pi*atan(sqrt((m^2-1)./(1-r.^2)));

x = 0.9;

z = 1e-6; % varied value

nu = .25;

X = @(r,phi) x-r.*cos(phi);

Y = @(r,phi) -r.*sin(phi);

R = @(r,phi) (X(r,phi).^2 + Y(r,phi).^2).^.5;

Rho = @(r,phi) (X(r,phi).^2 + Y(r,phi).^2 + z^2).^.5;

f1 = @(r,phi) (1 - z./Rho(r,phi)).*(X(r,phi).^2 - Y(r,phi).^2)./R(r,phi).^2;

f2 = @(r,phi) f1(r,phi) + z*Y(r,phi).^2./Rho(r,phi).^3;

f3 = @(r,phi) (1 - 2*nu)./R(r,phi).^2.*f2(r,phi) - 3*z*X(r,phi).^2./Rho(r,phi).^5;

fun = @(r,phi) r.*p(r).*f3(r,phi);

sx = psi/2/pi*integral2(fun,0,1,0,2*pi);

In need the variable "sx" for different values of "z".

For values greater than 1e-4 it works just fine, but for small values, for example 1e-6, I get an error.

I guess this has to do with some kind of singularity when calculating the integral, but I don't know how integral2 works..

I'm happy about any ideas on how to fix this problem!

Thanks a lot!

Walter Roberson
on 23 Apr 2019

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!