Weights and abscissae of GaussLegendre 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
)
numeric::gldata(n, digits)
returns the weights
and the abscissae of the GaussLegendre quadrature rule with n nodes
with a precision of digits
decimal digits.
The GaussLegendre quadrature rule produces the exact integral for all polynomial integrands f(x) through degree 2 n  1. The weights b_{i} and abscissae c_{i} are related to the roots of the nth Legendre polynomial.
The weights and abscissae are computed by a straightforward
numerical algorithm with a working precision set by the argument digits
.
The resulting floatingpoint numbers are correct to digits
leading
decimal places.
Typically, the argument digits
is chosen
as the current value of the environment variable DIGITS
.
The data for n = 20
, 40
, 80
, 160
with digits
<= 200
are stored internally. They are returned immediately
without any computational costs.
Due to the internal remember mechanism, only the first call
to numeric::gldata
leads to computational costs.
For any further call with the same arguments, the data are returned
immediately.
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 digits
.
The function uses option remember
.
The following call computes the GaussLegendre data with a precision
given by the current value of the environment variable DIGITS
(the
default value is DIGITS = 10
):
[b, c] := numeric::gldata(4, DIGITS)
The GaussLegendre 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 floatingpoint approximations:
DIGITS := 4: numeric::gldata(5, DIGITS)
delete DIGITS:

The number of nodes: a positive integer 

The number of decimal digits: a positive integer 
List [b, c]
is returned. The lists b
= [b_{1}, …, b_{n}]
and c
= [c_{1}, …, c_{n}]
are
numerical approximations of the weights and abscissae with digits
significant
digits.
The numerical integrator numeric::quadrature
calls numeric::gldata
to
provide the data for Gaussian quadrature.