You will get an error in this code.
f = fcnchk(funfcn);
c = (a + b)/2;
The values of a and b are not defined or provided as an input. This can only work, if you have M-files called a.m and b.m, but this would be a very bad choice of names.
1. the expression for w?
w = [s .242611071901408 fliplr(s)];
What exactly is your question concerning this line? w is defined as a row vector, which contains the elements of s, the value 0.242... (the leading zero can be omitted, but it is recommended to avoid this for clarity) and finally the elements of s in reversed order. See help fliplr.
r = abs(Q2-Q0)/abs(Q1-Q0+realmin(class(Q0)));
2. the expression for Q0?
Q0 is h times w times the transposed of y. When w and y are vectors, this is the dot product.
3. the term realmin(class(Q0))?
Did you read the documentation already?
The smallest possible number of the class of Q0 is created, e.g. 2.2251e-308 if Q0 is a double. This avoid the division by 0 if Q1 and Q0 have exactly the same value. But this can still fail, when Q1 equals Q0+realmin. Better:
(abs(Q1 - Q0) + realmin(class(Q0))
This is still extremely large and the result is dominated by random rounding errors. Therefore I'd prefer to get a NaN from a division by zero, such that the problem is clear.
Best Answer
MATLAB has multiple integration routines:
https://www.mathworks.com/help/matlab/ref/integral.html#References
References:
[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.
https://www.mathworks.com/help/matlab/ref/quad.html
Algorithms
quad implements a low order method using an adaptive recursive Simpson's rule. References
[1] Gander, W. and W. Gautschi, “Adaptive Quadrature – Revisited,” BIT, Vol. 40, 2000, pp. 84-101. This document is also available at http://www.inf.ethz.ch/personal/gander.
https://www.mathworks.com/help/matlab/ref/quadgk.html#f94-1004038
Algorithms
quadgk implements adaptive quadrature based on a Gauss-Kronrod pair (15th and 7th order formulas). References
[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.
https://www.mathworks.com/help/matlab/ref/quadl.html#f94-998971
Algorithms
quadl implements a high order method using an adaptive Gauss/Lobatto quadrature rule. References
[1] Gander, W. and W. Gautschi, “Adaptive Quadrature – Revisited,” BIT, Vol. 40, 2000, pp. 84-101. This document is also available at http://www.inf.ethz.ch/personal/gander.