The Gauss-Legendre integration is used to numerically calculate the following integral:
I = ∫-11 f(x)dx = ∑i=0n-1 wi f(xi)
This case corresponds to the Gauss integration with the weighting function w(x) = 1
From the above equation, the Gauss-Legendre integration is completely determined by a set of nodes xi
and weights wi. The nodes and weights for the Gauss-Legendre integration have been
computed with great precision and tabulated in literature. These data can be used without knowing the theory behind them,
since all we need are the values of xi and wi.
In order to test the Gauss-Legendre integration we will compute the following integral:
Running this example creates the results shown above. It can be seen that the result for n = 3
is already very accurate.
Testing the Gauss-Legendre Integration Method
In order to test the Gauss-Legendre method as defined above, a new TestGaussLegendre()
static method has been added and executed. Supporting code and methods are not shown.
static void TestGaussLegendre();
for (int n = 1; n < 9; n++)
result = Integration.GaussLegendre(f2, 1, 2, n);
ListBox1.Items.Add(" n = " + n + ", result = " + result);