How do I get the number of iterations when using the quad(..) function.

2 visualizzazioni (ultimi 30 giorni)
I am inputing on the Command Window:
[q, nfun]=quad(@(x) 1/pi*cos(sin(x)), 0,pi)
nfun seems to give me the number of evaluations for the answer q, but what I need is q for 5 iterations of the gauss quadrature method.
  2 Commenti
Mike Hosea
Mike Hosea il 16 Dic 2014
Modificato: Mike Hosea il 21 Dic 2014
I don't know what you mean by "iterations". Adaptive quadrature can be implemented recursively or iteratively. If it is implemented iteratively, it can be vectorized across all subintervals that currently need refinement, or it can handle each interval one at a time. The concept "5 iterations" doesn't make any sense for QUAD, which happens to be implemented using recursion.
John D'Errico
John D'Errico il 21 Dic 2014
Modificato: John D'Errico il 21 Dic 2014
As well, quad does not use a gaussian quadrature method. You can't make quad use a method it is not programmed to employ. Nor is it really meaningful at all to talk about iterations of a locally adaptive method like quad. In some parts of the interval quad will go to more depth than others, so essentially more iterations. Thus iterations is simply not a meaningful concept for quad.

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by