Why do I get the error "max number of function evalutations reached" using integral2?

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!

4 个评论

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?
Why should it make a difference that the singularity is a boundary point ?
integral_{0}^{1} 1/t dt does not exist although the only singularity is 0 at the boundary.
You do not need singularity to have integral2 problems with iterations: it can happen due to round-off problems, and it can happen for very steep functions, and it can happen for oscillating functions. It is a convergence issue, and sometimes you can deal with those by permitted more steps and sometimes you are never going to be able to solve them numerically.

请先登录,再进行评论。

回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by