Module gauss_quad::jacobi

source ·
Expand description

Numerical integration using the Gauss-Jacobi quadrature rule.

This rule can integrate integrands of the form (1 + x)^alpha * (1 - x)^beta * f(x) over the domain [-1, 1], where f(x) is a smooth function on [1, 1], alpha > -1 and beta > -1. The domain can be changed to any [a, b] through a linear transformation (which is done in this module), and this enables the approximation of integrals with singularities at the end points of the domain.

Example

use gauss_quad::jacobi::GaussJacobi;
use approx::assert_abs_diff_eq;

let quad = GaussJacobi::init(10, 0.0, -1.0 / 3.0);

// numerically integrate sin(x) / (1 - x)^(1/3), a function with a singularity at x = 1.
let integral = quad.integrate(-1.0, 1.0, |x| x.sin());

assert_abs_diff_eq!(integral, -0.4207987746500829, epsilon = 1e-14);

Structs