Weights and abscissae of Gauss-Legendre quadrature
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
numeric::gldata(n, digits) returns the weights
and the abscissae of the Gauss-Legendre quadrature rule with n nodes
with a precision of
digits decimal digits.
The Gauss-Legendre quadrature rule produces the exact integral for all polynomial integrands f(x) through degree 2 n - 1. The weights bi and abscissae ci are related to the roots of the n-th Legendre polynomial.
The weights and abscissae are computed by a straightforward
numerical algorithm with a working precision set by the argument
The resulting floating-point numbers are correct to
Typically, the argument
digits is chosen
as the current value of the environment variable
The data for
n = 20,
<= 200 are stored internally. They are returned immediately
without any computational costs.
Due to the internal remember mechanism, only the first call
numeric::gldata leads to computational costs.
For any further call with the same arguments, the data are returned
For odd n, the abscissa and the corresponding weight are rational numbers.
numeric::gldata is not sensitive
to changes of the environment variable
DIGITS, because the
numerical working precision is specified by the second argument
The function uses
The following call computes the Gauss-Legendre data with a precision
given by the current value of the environment variable
default value is
DIGITS = 10):
[b, c] := numeric::gldata(4, DIGITS)
The Gauss-Legendre data with 4 nodes provide exact numerical quadrature results for polynomials through degree 7:
f := x -> x^7: int(f(x), x= 0..1) = _plus(b[i]*f(c[i]) $ i=1..4)
delete b, c, f:
For odd n, exact rational data for and are returned. The other data are computed as floating-point approximations:
DIGITS := 4: numeric::gldata(5, DIGITS)
The number of nodes: a positive integer
The number of decimal digits: a positive integer
[b, c] is returned. The lists
= [b1, …, bn] and
= [c1, …, cn] are
numerical approximations of the weights and abscissae with
The numerical integrator
provide the data for Gaussian quadrature.