How can I simplify my my program so as not to give the following warning: Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test. ? ?

51 views (last 30 days)
the full warning is the following:
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 107
In pjodc at 165
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 107
In pjodc at 166
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 107
In pjodc at 168
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 107
In pjodc at 169
Warning: Reached the maximum number of function evaluations (10000). The result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 130
In funfun\private\integral2Calc at 10
In integral2 at 107
In pjodc at 170
And my program is the following:
clear all
a=1.436;
b=1.981;
Nx=0.947;
Ny=0.639;
Nxy=0.799;
t=0.0088;
v12=0.23;
E1=60*10^9;
E2=24.8*10^9;
v21=v12*(E2/E1);
p=2620;
Dx=(t^3*E1)/(12*(1-v12*v21));
Dy=(t^3*E2)/(12*(1-v12*v21));
Dxy=(t^3*E1*v21)/(12*(1-v12*v21));
K=56.915;
G=12*10^9;
x = sym('x','real');
y = sym('y','real');
mi=1
ni=1
mj=3
nj=1
ymi=(4*mi+1)*(pi/4);
yni=(4*ni+1)*(pi/4);
ymj=(4*mj+1)*(pi/4);
ynj=(4*nj+1)*(pi/4);
%PARA i
Hxi=cosh(((ymi/a).^2)*x)-cos((ymi/a).^2*x);
Fxi=cosh((ymi.^2)/a)-cos((ymi.^2)/a);
Jxi=sinh((ymi.^2)/a)-sin((ymi.^2)/a);
Kxi=sinh((ymi/a).^2*x)-sin((ymi/a).^2*x);
Hyi=cosh(((yni/b).^2)*y)+cos((yni/b).^2*y);
Fyi=cosh((yni.^2)/b)+cos((yni.^2)/b);
Jyi=sinh((yni.^2)/b)+sin((yni.^2)/b);
Kyi=sinh((yni/b).^2*y)+sin((yni/b).^2*y);
%para j
Hxj=cosh(((ymj/a).^2)*x)-cos((ymj/a).^2*x);
Fxj=cosh((ymj.^2)/a)-cos((ymj.^2)/a);
Jxj=sinh((ymj.^2)/a)-sin((ymj.^2)/a);
Kxj=sinh((ymj/a).^2*x)-sin((ymj/a).^2*x);
Hyj=cosh(((ynj/b).^2)*y)+cos((ynj/b).^2*y);
Fyj=cosh((ynj.^2)/b)+cos((ynj.^2)/b);
Jyj=sinh((ynj.^2)/b)+sin((ynj.^2)/b);
Kyj=sinh((ynj/b).^2*y)+sin((ynj/b).^2*y);
Xmi=Hxi-((Fxi)/(Jxi))*(Kxi);
Yni=Hyi-((Fyi)/(Jyi))*Kyi;
Xmj=Hxj-((Fxj)/(Jxj))*(Kxj);
Ynj=Hyj-((Fyj)/(Jyj))*(Kyj);
wi=Xmi*Yni;
wj=Xmj*Ynj;
vpa(wi,6);
vpa(wj,6);
dwidx2=diff(wi,x,2);
dwidy2=diff(wi,y,2);
dwidydx2=diff(diff(wi,x),y);
dwjdx2=diff(wj,x,2);
dwjdy2=diff(wj,y,2);
dwjdydx2=diff(diff(wj,x),y);
vpa(dwidx2,6);
vpa(dwidy2,2);
vpa(dwidydx2,2);
vpa(dwjdx2,2);
vpa(dwjdy2,2);
vpa(dwjdydx2,2);
dwidx2=matlabFunction(dwidx2);
dwidy2=matlabFunction(dwidy2);
dwidydx2=matlabFunction(dwidydx2);
dwjdx2=matlabFunction(dwjdx2);
dwjdy2=matlabFunction(dwjdy2);
dwjdydx2=matlabFunction(dwjdydx2);
wj=matlabFunction(wj);
wi=matlabFunction(wi);
func1=@(x,y)Dx.*(dwidx2(x,y).*(dwjdx2(x,y)));
func2=@(x,y)Dy.*(dwidy2(x,y).*(dwjdy2(x,y)));
func3=@(x,y)Dxy.*(dwidx2(x,y).*dwidy2(x,y));
func4=@(x,y)Dxy.*dwjdx2(x,y).*dwjdy2(x,y);
func5=@(x,y)4.*G.*dwidydx2(x,y).*dwjdydx2(x,y);
func6=@(x,y)K.*wi(x,y).*wj(x,y);
vpa(func1,6);
vpa(func2,6);
vpa(func3,6);
vpa(func4,6);
vpa(func5,6);
vpa(func6,6);
a1=integral2(func1,0,1.436,0,1.981);
b1=integral2(func2,0,1.436,0,1.981);
c1=integral2(func3,0,1.436,0,1.981);
d1=integral2(func4,0,1.436,0,1.981);
e1=integral2(func5,0,1.436,0,1.981);
f1=integral2(func6,0,1.436,0,1.981);
A12=a1+b1+c1+d1+e1+f1;
A12

Answers (1)

Walter Roberson
Walter Roberson on 7 Dec 2012
It isn't a matter of simplifying your function that is being integrated: the problem is that at least one of the functions is not sufficiently smooth to be integrated in 10000 calls with the default error tolerance.
You can increase the error tolerance or you can increase the allowed number of function calls. You would use an options structure either way.
  4 Comments
Mike Hosea
Mike Hosea on 17 Dec 2012
Right. INTEGRAL2 does not allow for increasing the maximum number of function evaluations, though QUAD2D does. Try using QUAD2D with FailurePlot,'true' to see where the problems are. The formulation seems to have some numerical issues in certain areas. I recommend examining those areas, maybe refactoring the integrand to avoid whatever numerical issues are causing the problem.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!