Im trying to understand why a call like this
G = const * quadv(fun,a,b,tol)
returns different values than
lenB = length(b)
for 1 = 1:lenB
G(i) = const .* quadl(fun,a,b,tol)
end
and how to achieve both calls to return the same values ?
EDIT: I would like to run the quadl faster for arrays as well. So I would formulate the above question:
If it is possible, how to call quadl also for arrays (similar like the quadv call above), and thus increase performance by the calculations?
Matlab's quadl uses adaptive Lobatto quadrature; quadv uses adaptive Simpson's rule.
The quality of the answer you get might depend on the function you assume. What does your test fun look like?
I'll assume that you're passing the same function, limits, and tolerance to both calls. That will mean the differences are smaller than the tolerance.
The two methods are different - Gaussian quadrature is not the same as Simpson's rule:
http://en.wikipedia.org/wiki/Gaussian_quadrature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With