PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_ode_bvp_ps_lin_quad_weights (d02uy)
Purpose
nag_ode_bvp_ps_lin_quad_weights (d02uy) obtains the weights for Clenshaw–Curtis quadrature at Chebyshev points. This allows for fast approximations of integrals for functions specified on Chebyshev Gauss–Lobatto points on .
Syntax
[
w,
ifail] = nag_ode_bvp_ps_lin_quad_weights(
n)
Description
nag_ode_bvp_ps_lin_quad_weights (d02uy) obtains the weights for Clenshaw–Curtis quadrature at Chebyshev points.
Given the (Clenshaw–Curtis) weights , for , and function values (where , for , are the Chebyshev Gauss–Lobatto points), then .
For a function discretized on a Chebyshev Gauss–Lobatto grid on the resultant summation must be multiplied by the factor .
References
Trefethen L N (2000) Spectral Methods in MATLAB SIAM
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, where the number of grid points is .
Constraint:
and
n is even.
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
The Clenshaw–Curtis quadrature weights,
, for .
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The accuracy should be close to
machine precision.
Further Comments
A real array of length is internally allocated.
Example
This example approximates the integral using Clenshaw–Curtis weights and a -point Chebyshev Gauss–Lobatto grid on .
Open in the MATLAB editor:
d02uy_example
function d02uy_example
fprintf('d02uy example results\n\n');
n = int64(64);
a = -1;
b = 3;
[x, ifail] = d02uc(n, a, b);
f = 3*x.^2;
scale = 0.5*(b-a);
[w, ifail] = d02uy(n);
integ = dot(w, f)*scale;
fprintf('Integral of f(x) from %4.1f to %4.1f = %7.4f\n', a, b, integ);
fprintf('\nError in approximation = %12.2e\n', integ-28);
d02uy example results
Integral of f(x) from -1.0 to 3.0 = 28.0000
Error in approximation = 3.55e-15
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015