MATLAB: Do I receive a “Singularity likely” warning when I use the QUAD function in MATLAB for a function that does not have a singularity

quadquad8quadl

For example when I execute the following command:
quad(@exp,0,30)
I receive the following warning message:
Warning: Maximum function count exceeded; singularity likely.
and I receive the following answer:
ans =
9.2156e+012
However, I am expecting the answer to be:
ans =
1.0686e+013

Best Answer

This warning will occur when the default absolute error tolerance of 1.0e-6 is too small to evaluate the integral in fewer function evaluations than the default 10000.
To work around this issue, specify a larger absolute tolerance as the fourth input argument to the QUAD function. For example, the following command specifies an absolute tolerance of 1:
quad(@exp,0,30,1)
and returns the expected result:
ans =
1.0686e+013