Module gauss_quad::legendre
source · Expand description
Numerical integration using the Gauss-Legendre quadrature rule.
In Gauss-Legendre quadrature rules the integrand is evaluated at
the unique points such that a degree n
rule can integrate
degree 2n - 1
degree polynomials exactly.
Evaluation point x_i of a degree n rule is the i:th root
of Legendre polynomial P_n and its weight is
w = 2 / ((1 - x_i)(P’_n(x_i))^2).
Example
use gauss_quad::legendre::GaussLegendre;
use approx::assert_abs_diff_eq;
let quad = GaussLegendre::init(10);
let integral = quad.integrate(-1.0, 1.0,
|x| 0.125 * (63.0 * x.powi(5) - 70.0 * x.powi(3) + 15.0 * x)
);
assert_abs_diff_eq!(integral, 0.0);
Structs
- A Gauss-Legendre quadrature scheme.