Legendre-Gauss Quadrature formula: Difference between revisions
imported>Dmitrii Kouznetsov m (→Nodes and weights: mistypes) |
mNo edit summary |
||
(12 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Subpages}} | ||
'''Legendre-Gauss | The '''Legendre-Gauss Quadrature formula''' or '''Gauss-Legendre quadrature''' is the approximation of the integral | ||
:(1) <math>\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^N w_i f(x_i).</math> | :(1) <math>\int_{-1}^1 f(x)\,dx \approx \sum_{i=1}^N w_i f(x_i).</math> | ||
with special choice of nodes <math>x_i</math> and weights <math>w_i</math>, characterised in that, if the | with special choice of nodes <math>x_i</math> and weights <math>w_i</math>, characterised in that, if the function <math>f</math> is [[polynomial]] of degree smaller than <math>2N</math>, then the exact equality takes place in equation (1). | ||
The Legendre-Gauss quadrature formula is a special case of [[Gaussian quadratures]] which allow efficient approximation of a function with known asymptotic behavior at the edges of the interval of integration. This approximation is especially recommended if the integrand is [[holomorphic function|holomorphic]] in a neighbourhood of integration interval. | |||
==Nodes and weights== | ==Nodes and weights== | ||
The nodes <math>x_i</math> in equation (1) are zeros of the [[Legendre polynomial]] <math>P_N</math>: | |||
: (2) <math> P_N(x_i)=0</math> | : (2) <math> P_N(x_i)=0</math> | ||
: (3) <math> -1<x_1<x_2< ... <x_N <1</math> | : (3) <math> -1<x_1<x_2< ... <x_N <1</math> | ||
The weights <math>w_i</math> in equation (1) can be expressed bu | |||
: (4) <math> w_i = \frac{2}{\left( 1-x_i^2 \right) (P'_N(x_i))^2} </math> | : (4) <math> w_i = \frac{2}{\left( 1-x_i^2 \right) (P'_N(x_i))^2} </math> | ||
There is no straightforward | There is no straightforward expression for the nodes <math>x_i</math>; they can be approximated to many decimal places through only few iterations, solving numerically equation (2) with initial approach | ||
: (5) <math> x_i\approx \cos\left(\pi \frac{1/2 +i}{N}\right) </math> | : (5) <math> x_i\approx \cos\left(\pi \frac{1/2 +i}{N}\right) </math> | ||
Line 21: | Line 22: | ||
<ref name="irene">{{cite book | <ref name="irene">{{cite book | ||
|first=Milton | |first=Milton | ||
| | |last=Abramovitz | ||
|coauthors=I. | |coauthors=I. Stegun | ||
|title=Handbook | |title=[[Handbook of mathematical functions]] | ||
|year= | |year=1964 | ||
| | |publisher=[[National Bureau of Standards]] | ||
|isbn=0-486-61272-4 | |||
|city=NY | |||
|url=http://www.convertit.com/Go/ConvertIt/Reference/AMS55.ASP?Res=200&Page=887 | |||
}}</ref> | }}</ref> | ||
<ref name="recipes">{{cite book | <ref name="recipes">{{cite book | ||
|title = Numerical Resipes in C | |author=W.H.Press, S.A.Teukolsky, W.T.Vetterling, B.P.Flannery | ||
|publisher=[[ | |title = [[Numerical Resipes in C]] | ||
|publisher=[[Cambridge University Press]] | |||
|year=1988 | |||
|isbn=0-521-43108-5 | |||
|url=http://www.nrbook.com/a/bookcpdf.php | |||
}}</ref> | }}</ref> | ||
==Precision of the approximation== | ==Precision of the approximation== | ||
If the integrand is a [[holomorphic function]] along the path of integration, then the error of approximation decreases exponentially in the number of nodes <math>N</math>. If the integrand is a [[polynomial]] of degree <math>2N-1</math> or less, then Legendre-Gauss quadrature with <math>N</math> nodes yields the exact answer. | |||
If the integrand has a singularity, then the formula still can be used, but the approximation is poor. In that case, one may consider to use another [[Gaussian quadrature]], more suitable for the specific function. Alternatively, it may be possible to deform the [[contour of integration]] to avoid the singularity if it is inside the integration interval. Another possibility is to do a substitution that makes the integrand regular. | |||
==Example== | ==Example== | ||
{{Image|GaulegExample.png|right|300px|Fig.1. Example of estimate of precision: Logarithm of residual versus number <math>N</math> of terms in the right hand side of equation (1) for various integrands <math>f(x)</math>.}} | |||
In Fig.1, the [[decimal logarithm]] of the modulus of the residual of the appdoximation of integral with Gaussian quadrature is shown versus number of terms in the sum, for four examples of the integrand. | |||
: <math> f(x)=x^{16} </math> (black) | |||
: <math> f(x)=\sqrt{1+x^2} </math> (red) | |||
: <math> f(x)=1/(1+x^2) </math> (green) | |||
: <math> f(x)=1/(3+x) </math> (blue) | |||
The first of these functions is integrated "exactly" at <math>N>8</math>, and the residual is determined by the rounding errors at the [[long double]] arithmetic. | |||
The second function (red) has [[branch points]] at the end of the interval; therefore, the approximation does not improve quickly at the increase of number terms in the sum. The last two functions are analytic within the range of integration; the residual decreases exponentially, and the precision of evaluation of the integral is limited only by the rounding errors. | |||
==Extension to other interval== | ==Extension to other interval== | ||
is straightforward. Should I copypast the obvious formulas here? | is straightforward. Should I copypast the obvious formulas here? | ||
==References== | ==References== | ||
<references/> | <references/>[[Category:Suggestion Bot Tag]] | ||
[[Category: | |||
Latest revision as of 06:00, 11 September 2024
The Legendre-Gauss Quadrature formula or Gauss-Legendre quadrature is the approximation of the integral
- (1)
with special choice of nodes and weights , characterised in that, if the function is polynomial of degree smaller than , then the exact equality takes place in equation (1).
The Legendre-Gauss quadrature formula is a special case of Gaussian quadratures which allow efficient approximation of a function with known asymptotic behavior at the edges of the interval of integration. This approximation is especially recommended if the integrand is holomorphic in a neighbourhood of integration interval.
Nodes and weights
The nodes in equation (1) are zeros of the Legendre polynomial :
- (2)
- (3)
The weights in equation (1) can be expressed bu
- (4)
There is no straightforward expression for the nodes ; they can be approximated to many decimal places through only few iterations, solving numerically equation (2) with initial approach
- (5)
These formulas are described in the books [1] [2]
Precision of the approximation
If the integrand is a holomorphic function along the path of integration, then the error of approximation decreases exponentially in the number of nodes . If the integrand is a polynomial of degree or less, then Legendre-Gauss quadrature with nodes yields the exact answer.
If the integrand has a singularity, then the formula still can be used, but the approximation is poor. In that case, one may consider to use another Gaussian quadrature, more suitable for the specific function. Alternatively, it may be possible to deform the contour of integration to avoid the singularity if it is inside the integration interval. Another possibility is to do a substitution that makes the integrand regular.
Example
In Fig.1, the decimal logarithm of the modulus of the residual of the appdoximation of integral with Gaussian quadrature is shown versus number of terms in the sum, for four examples of the integrand.
- (black)
- (red)
- (green)
- (blue)
The first of these functions is integrated "exactly" at , and the residual is determined by the rounding errors at the long double arithmetic. The second function (red) has branch points at the end of the interval; therefore, the approximation does not improve quickly at the increase of number terms in the sum. The last two functions are analytic within the range of integration; the residual decreases exponentially, and the precision of evaluation of the integral is limited only by the rounding errors.
Extension to other interval
is straightforward. Should I copypast the obvious formulas here?
References
- ↑ Abramovitz, Milton; I. Stegun (1964). Handbook of mathematical functions. National Bureau of Standards. ISBN 0-486-61272-4.
- ↑ W.H.Press, S.A.Teukolsky, W.T.Vetterling, B.P.Flannery (1988). Numerical Resipes in C. Cambridge University Press. ISBN 0-521-43108-5.