gauss-quadrature
Gauss-Legendre quadrature rules
npm install gauss-quadrature
Want to see pretty graphs? Log in now!
7 | downloads in the last month |
Last Published By | |
---|---|
Version | 0.0.0 last updated a year ago |
License | MIT |
Keywords | quadrature, gauss, legendre, points, weights, numeric, integration, polynomial, calculus |
Repository | git://github.com/mikolalysenko/gauss-quadrature.git (git) |
Dependencies | horner, legendre-poly, poly-derivative, durand-kerner |
Dependents | mikolalysenko-hoarders |
gauss-quadrature
This library computes Gauss-Legendre quadrature points and weights for numerical integration. For more information, see:
Example
var gaussQ = require("gauss-quadrature")
console.log(gaussQ(2))
//Prints:
//
// [ [ -0.5773502691896257, 0.5773502691896257 ], [ 1, 1 ] ]
//
Install
npm install gauss-quadrature
require("gauss-quadrature")(n[, a, b])
Computes the Gaussian quadrature points and weights for the interval [a, b].
n
is the number of quartature pointsa
is the start of the interval (default -1)b
is the end of the interval (default +1)
If either a
or b
is unspecified, the interval defaults to [-1, 1]
Returns An array with two elements, [x, w]
where:
x
is the list of quadrature pointsw
is the list of quadrature weights
Note
Currently numeric.js' eigen decomposition code has some bugs, so this library may fail for high numbers of quadrature points. In theory this could be avoided by using a better set of routines for computing eigenvalues/vectors or some other method for finding roots (or even by just hard coding some of the quadrature weights into a table). Until this issue gets fixed, this library is of limited use.
Credits
(c) 2013 Mikola Lysenko. MIT License