How should I resolve the warning "Warning: Reached the maximum number of function evaluations (100000). The result fails the global error test."?

30 views (last 30 days)
Yaswanth Sai Jetti on 16 May 2020
I am trying too evaluate a double integral numerically using 'quad2d' function over a triangular area.
c = 1;
xib = 0;
yib = 0.866;
zi = 1e-05;
gamma = 0.866;
tmin1 = 0;
tmax1 = @(s)sqrt(3)*(s+c/2);
tmin2 = 0;
tmax2 = @(s)sqrt(3)*(-s+c/2);
rho = @(s,t)((xib-s).^2+(yib-t).^2+zi.^2).^(1./2);
fintzz = @(s,t)-t./rho(s,t).^5;
touzz = touzz1+touzz2;
Initially, I was integrating over the entire triangular area in one line. I know that there is a singularity at point (0,0) for the integrand. After looking at some suggestions in MATLAB forums, I have split the integration region into two areas. I am using the above code to solve a bigger problem, for which I have analytical solutions. The results improved with splitting the region, but I am not getting an answer which is satisfactorily closer to the analytical values. The accuracy is not improving for whatever number of function evaluations I do, like here I have used 100000 evaluations, and I still get the warning. Can someone guide me with any better alternatives in MATLAB? Thanks.

Devineni Aslesha on 19 May 2020
Hi Yaswanth
It looks like the warning occurs even when the maximum number of function evaluations are 2000. I recommend you to go through the 'Limitations of quad2d' in quad2d doc link. You can try splitting the integral into more areas by examining the FailurePlot, increase the tolerances using 'AbsTol' and 'RelTol' properties of quad2d as specified in this link. Also, try using integral2 function in MATLAB with 'Method' property set to 'iterated'.
Yaswanth Sai Jetti on 19 May 2020
Thank you. I will try solving the integral with 'integral2' function.