gauss-quad 0.1.0

Library for applying Gaussian quadrature to integrate a function
Documentation

gauss_quad

The gauss_quad crate is a small library to calculate integrals of the type

equation

using Gaussian quadrature.

The general call structure is to first initialize the n-point quadrature rule setting the degree n via

 let quadrature = gauss_quad::QUADRATURE_RULE::init(n);

where QUADRATURE_RULE can currently be either of:

GaussLegendre
GaussHermite

Then to calculate the integral of a function can be calculated by calling

let integral = quad.integrate(a, b, f(x));

where a and b (both f64) are the integral bounds and the f(x) the integrand (fn(f64) -> f64). For example to integrate a parabola from 0..1 one can use a lambda expression as integrand and call:

let integral = quad.integrate(0.0, 1.0, |x| x*x);

If the integral is improper, as in the case of Gauss Hermite integrals

equation

no integral bounds should be passed and the call simplifies to

let integral = quad.integrate(f(x));