weird Problem with dblquad
3 views (last 30 days)
Show older comments
Hi,
q = dblquad(@(theta1,phi1) Fnum3(ro,phi,z,theta1,phi1,k) ,0,1.99*pi ,0,0.1)
im trying to use dblquad to integrate over a function and with
some parameters i get those messages in a loop
for example when the parameter k is very large number
~k=1.2e+007
or when the integral bounderies is larger then some numbers
Warning: Maximum function count exceeded; singularity likely.
> In quad at 106
In dblquad>innerintegral at 84
In quad>quadstep at 126
In quad>quadstep at 167
In quad>quadstep at 167
In quad>quadstep at 167
In quad>quadstep at 167
In quad>quadstep at 167
In quad at 92
In dblquad at 60
In A2 at 16
does anyone knows a solution?
in new Matlab versions (not in mine)there is a function - integrate2, what is the difference between it and dblquad?
* * * i forgot to mention when running the handle Fnum3 with those parameters it works fine.
0 Comments
Accepted Answer
Mike Hosea
on 19 Mar 2012
The integrator QUAD (which is called in a nested way by DBLQUAD) has an internal limit on the number of function evaluations it will perform. This is to prevent it from wasting a lot of time on problems that cannot be solved. Unfortunately, it sometimes causes it to quit before it has solved a problem that it can solve. A possible workaround in some cases is to split the domain into pieces and add the results over each piece. Another possible workaround is to loosen the tolerance and accept a less accurate result.
You may have more luck with QUAD2D, which in most cases is a far superior code to DBLQUAD, but take care that you do not use the tactic of setting the integrand function to zero in order to integrate over a non-rectangular region. QUAD2D is designed to accept function handles for that situation. QUAD2D also lets you override the default limit on the number of function evaluations.
INTEGRAL2 is a new function in the 2012a release. It is a new code but actually based on the algorithms of QUAD2D or QUADGK, depending on the inputs. Although the old numerical integration codes have not been deprecated as yet, INTEGRAL, INTEGRAL2, and INTEGRAL3 are now the preferred functions for numerical integration in 1, 2, and 3 dimensions, respectively.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!