Class GaussianQuadrature
- java.lang.Object
-
- dev.nm.analysis.integration.univariate.riemann.gaussian.GaussianQuadrature
-
- All Implemented Interfaces:
Integrator
- Direct Known Subclasses:
GaussChebyshevQuadrature,GaussHermiteQuadrature,GaussLaguerreQuadrature,GaussLegendreQuadrature
public class GaussianQuadrature extends Object implements Integrator
A quadrature rule is a method of numerical integration in which we approximate the integral of a function by a weighted sum of sample points. That is, \[ \int_{a}^b f(x)\,dx \approx \sum_{i=1}^n c_i f(x_i). \] By a suitable choice of the points \(x_i\) and the weights \(c_i\), an n-point weighted sum will yield an exact result for polynomials of degree (2n-1) or less, which is known as a Gaussian quadrature rule. Gaussian quadrature will only produce accurate results if \(f(x)\) is well approximated by a polynomial function within the range [-1,1]. However, if the integrated function can be written as \(f(x) = W(x) g(x)\) where \(g(x)\) is approximately polynomial and \(W(x)\) is known, then there are alternative weights \(w_i'\) such that \[ \int_{a}^b f(x)\,dx =\int_{a}^b W(x) g(x)\,dx \approx \sum_{i=1}^n w_i' g(x_i). \] Note that the precision for Gaussian quadrature rules cannot be specified, and hence callingIntegrator.getPrecision()will throw anUnsupportedOperationException.- See Also:
- Wikipedia: Gaussian quadrature
-
-
Constructor Summary
Constructors Constructor Description GaussianQuadrature(GaussianQuadratureRule rule)Create a Gaussian quadrature integrator with the given quadrature rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetPrecision()Get the convergence threshold.doubleintegrate(UnivariateRealFunction f, double a, double b)Integrate function f from a to b, \[ \int_a^b\! f(x)\, dx \]
-
-
-
Constructor Detail
-
GaussianQuadrature
public GaussianQuadrature(GaussianQuadratureRule rule)
Create a Gaussian quadrature integrator with the given quadrature rule.- Parameters:
rule- the Gaussian quadrature rule
-
-
Method Detail
-
integrate
public double integrate(UnivariateRealFunction f, double a, double b)
Description copied from interface:IntegratorIntegrate function f from a to b, \[ \int_a^b\! f(x)\, dx \]- Specified by:
integratein interfaceIntegrator- Parameters:
f- a univariate functiona- the lower limitb- the upper limit- Returns:
- \(\int_a^b\! f(x)\, dx\)
-
getPrecision
public double getPrecision()
Description copied from interface:IntegratorGet the convergence threshold. The usage depends on the specific integrator. For example, for anIterativeIntegrator, the integral is considered converged if the relative error of two successive sums is less than the threshold.- Specified by:
getPrecisionin interfaceIntegrator- Returns:
- the precision
-
-