|   | InfiniteAdaptiveGaussKronrod Class | 
 Inheritance Hierarchy
Inheritance HierarchyNamespace: Accord.Math.Integration
 Syntax
Syntaxpublic class InfiniteAdaptiveGaussKronrod : IUnivariateIntegration, INumericalIntegration, ICloneable, INumericalIntegration<InfiniteAdaptiveGaussKronrodStatus>
The InfiniteAdaptiveGaussKronrod type exposes the following members.
 Constructors
Constructors| Name | Description | |
|---|---|---|
|  | InfiniteAdaptiveGaussKronrod(Int32) | 
              Creates a new InfiniteAdaptiveGaussKronrod integration algorithm.
             | 
|  | InfiniteAdaptiveGaussKronrod(Int32, FuncDouble, Double) | 
              Creates a new InfiniteAdaptiveGaussKronrod integration algorithm.
             | 
|  | InfiniteAdaptiveGaussKronrod(Int32, FuncDouble, Double, Double, Double) | 
              Creates a new InfiniteAdaptiveGaussKronrod integration algorithm.
             | 
 Properties
Properties| Name | Description | |
|---|---|---|
|  | Area | 
              Gets the numerically computed result of the
              definite integral for the specified function.
             | 
|  | Error | 
              Gets the integration error for the
              computed Area value.
             | 
|  | Function | 
              Gets or sets the function to be differentiated.
             | 
|  | FunctionEvaluations | 
              Gets the number of function evaluations performed in 
              the last call to the Compute method.
             | 
|  | Range | 
              Gets or sets the input range under
              which the integral must be computed.
             | 
|  | Status | 
              Get the exit code returned in the last call to the
              Compute method.
             | 
|  | Subintervals | 
              Get the maximum number of subintervals to be utilized in the
              partition of the integration interval.
             | 
|  | ToleranceAbsolute | 
              Desired absolute accuracy. If set to zero, this parameter
              will be ignored and only other requisites will be taken
              into account. Default is zero.
             | 
|  | ToleranceRelative | 
              Desired relative accuracy. If set to zero, this parameter
              will be ignored and only other requisites will be taken
              into account. Default is 1e-3.
             | 
 Methods
Methods| Name | Description | |
|---|---|---|
|  | Clone | 
              Creates a new object that is a copy of the current instance.
             | 
|  | Compute | |
|  | Equals | Determines whether the specified object is equal to the current object.(Inherited from Object.) | 
|  | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) | 
|  | GetHashCode | Serves as the default hash function. (Inherited from Object.) | 
|  | GetType | Gets the Type of the current instance.(Inherited from Object.) | 
|   | Integrate(FuncDouble, Double) | 
              Computes the area under the integral for the given function, in the given 
              integration interval, using the Infinite Adaptive Gauss Kronrod algorithm.
             | 
|   | Integrate(FuncDouble, Double, Double, Double) | 
              Computes the area under the integral for the given function, in the given 
              integration interval, using the Infinite Adaptive Gauss Kronrod algorithm.
             | 
|   | Integrate(FuncDouble, Double, Double, Double, Double) | 
              Computes the area under the integral for the given function, in the given 
              integration interval, using the Infinite Adaptive Gauss Kronrod algorithm.
             | 
|  | MemberwiseClone | Creates a shallow copy of the current Object.(Inherited from Object.) | 
|  | ToString | Returns a string that represents the current object.(Inherited from Object.) | 
 Extension Methods
Extension Methods| Name | Description | |
|---|---|---|
|  | HasMethod | 
              Checks whether an object implements a method with the given name.
            (Defined by ExtensionMethods.) | 
|  | IsEqual | 
                Compares two objects for equality, performing an elementwise 
                comparison if the elements are vectors or matrices.
            (Defined by Matrix.) | 
|  | To(Type) | Overloaded. 
              Converts an object into another type, irrespective of whether
              the conversion can be done at compile time or not. This can be
              used to convert generic types to numeric types during runtime.
            (Defined by ExtensionMethods.) | 
|  | ToT | Overloaded. 
              Converts an object into another type, irrespective of whether
              the conversion can be done at compile time or not. This can be
              used to convert generic types to numeric types during runtime.
            (Defined by ExtensionMethods.) | 
 Remarks
RemarksIn applied mathematics, adaptive quadrature is a process in which the integral of a function f(x) is approximated using static quadrature rules on adaptively refined subintervals of the integration domain. Generally, adaptive algorithms are just as efficient and effective as traditional algorithms for "well behaved" integrands, but are also effective for "badly behaved" integrands for which traditional algorithms fail.
The algorithm implemented by this class has been based on the original FORTRAN implementation from QUADPACK. The function implemented the Non-adaptive Gauss- Kronrod integration is qagi(f,bound,inf,epsabs,epsrel,result,abserr,neval, ier,limit,lenw,last,iwork,work). The original source code is in the public domain, but this version is under the LGPL. The original authors, as long as the original routine description, are listed below:
Robert Piessens, Elise de Doncker; Applied Mathematics and Programming Division, K.U.Leuven, Leuvenappl. This routine calculates an approximation result to a given integral i = integral of f over (bound,+infinity) or i = integral of f over (-infinity,bound) or i = integral of f over (-infinity,+infinity) hopefully satisfying following claim for accuracy abs(i-result).le.max(epsabs,epsrel*abs(i)).
References:
 Examples
ExamplesLet's say we would like to compute the definite integral of the function f(x) = cos(x) in the interval -1 to +1 using a variety of integration methods, including the TrapezoidalRule, RombergMethod and NonAdaptiveGaussKronrod. Those methods can compute definite integrals where the integration interval is finite:
// Declare the function we want to integrate Func<double, double> f = (x) => Math.Cos(x); // We would like to know its integral from -1 to +1 double a = -1, b = +1; // Integrate! double trapez = TrapezoidalRule.Integrate(f, a, b, steps: 1000); // 1.6829414 double romberg = RombergMethod.Integrate(f, a, b); // 1.6829419 double nagk = NonAdaptiveGaussKronrod.Integrate(f, a, b); // 1.6829419
Moreover, it is also possible to calculate the value of improper integrals (it is, integrals with infinite bounds) using InfiniteAdaptiveGaussKronrod, as shown below. Let's say we would like to compute the area under the Gaussian curve from -infinite to +infinite. While this function has infinite bounds, this function is known to integrate to 1.
// Declare the Normal distribution's density function (which is the Gaussian's bell curve) Func<double, double> g = (x) => (1 / Math.Sqrt(2 * Math.PI)) * Math.Exp(-(x * x) / 2); // Integrate! double iagk = InfiniteAdaptiveGaussKronrod.Integrate(g, Double.NegativeInfinity, Double.PositiveInfinity); // Result should be 0.99999...
 See Also
See Also