Module legendre

Source
Expand description

Numerical integration using the Gauss-Legendre quadrature rule.

A Gauss-Legendre quadrature rule of degree n can integrate degree 2n-1 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::new(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§

GaussLegendre
A Gauss-Legendre quadrature scheme.
GaussLegendreError
The error returned by GaussLegendre::new if it’s given a degree of 0 or 1.
GaussLegendreIntoIter
An owning iterator over the node-weight pairs of the quadrature rule.
GaussLegendreIter
An iterator over the node-weight pairs of the quadrature rule.
GaussLegendreNodes
An iterator over the nodes of the quadrature rule.
GaussLegendreWeights
An iterator over the weights of the quadrature rule.