To compute the following Gaussian integral using the Gauss-Hermite method:
The delegate function is simply x2, since the weighting function w(x) = e-x2 for
the Gauss-Hermite integration.
Running this example creates the results shown above. The exact result of this integral is equal to √π / 2. The result for
n = 3 is already very close to the exact result.
Testing the Gauss-Hermite Integration Method
In order to test the Gauss-Hermite method as defined above, a new TestGaussHermite()
static method has been added and executed. Supporting code and methods are not shown.
►
|
static void TestGaussHermite();
{
ListBox1.Items.Clear();
ListBox2.Items.Clear();
double result;
for (int n = 1; n < 9; n++)
(
result = Integration.GaussHermite(f4, n);
ListBox1.Items.Add(" " + n + );
ListBox2.Items.Add(" " + result);
)
}
|
|