# surface integral computation.

30 views (last 30 days)
doron bartov on 9 May 2012
hi, i am trying to calculate a surface integral [integral(integrand*da), where da is in spherical coordinates- r^2*sin(thetha)dthetha*dfi] numericly with the dblquad function. the function is the EM field poynting vector- E cross B.
to see that it can perform the integral well, i tried to calculate a surface integral of a constant vector and it did not produce the result zero, so i figure that using dblquad might not be a good way to approach this. ?

Mike Hosea on 11 May 2012
You should never expect an exact result from a numerical integrator. Even when there is no discretization error, there can be some roundoff error. Nevertheless, DBLQUAD is obsolete. Try INTEGRAL2, or if you don't have R2012a, QUAD2D.
##### 2 CommentsShowHide 1 older comment
Mike Hosea on 14 May 2012
You can increase MaxFunEvals to anything you like, e.g. quad2d(...,'MaxFunEvals',10000). However, the convergence problems will still occur if you have discontinuities in the interior of the region. To deal with that, break the integral up into multiple pieces such that the discontinuities are always on the boundaries of subintegrals. If you still have convergence problems after that, you may have a singularity that is too strong for the code to handle. Sometimes loosening the tolerances may help, e.g. quad2d(...,'AbsTol',1e-3,'reltol',1e-3), but in such cases you may be able to keep the default tolerances and increase 'MaxFunEvals' instead. If you need to increase 'MaxFunEvals' and then are successful, please let me know what value of 'MaxFunEvals' you needed. We simplified a little when we introduced INTEGRAL2 and didn't include a similar parameter, instead setting it to a fixed 10000 internally for the 'tiled' method. You can always split an integral to overcome that limitation, but increasing a parameter is less work.