IMPLEMENTATION
Runge Kutta-Fehlberg Method
As with solving a single first-order ordinary differential equation, this method is a more efficient and effective
method for performing numerical integration, because it can estimate the truncation error at each integration step
and automatically adjust the step size to keep the error within a prescribed tolerance.
Error Algorithm Creation
There is simply no single choice that works well in all problems. To control the largest component of
E(h), that error measure would be:
To control some gross measure of the error, the root-main-square error defined by
error(h) = √ 1/n ∑i=0n-1 E2i (h)
|
where n is the number of first-order differential equations.
Testing the Runge Kutta-Fehlberg Method
To test the method as defined above, a new TestRungaKuttaFehlberg()
static method has been added and executed. Supporting code and methods are not shown.
An initial "Step Size h = { 0.5}" for the test has been defined.
►
|
static void TestRunge KuttaFehlberg();
{
ListBox1.Items.Clear();
ListBox2.Items.Clear();
ListBox3.Items.Clear();
ListBox4.Items.Clear();
ListBox5.Items.Clear();
double dt = t1;
double t0 = 0.0;
VectorR x0 = new VectorR(new double[] { x10, x20, v10, v20 });
VectorR x = x0;
for (int i = 0; i < 21; i++);
{
double t = 0.1 * i;
x = ODE.MultiRungeKuttaFehlberg(f1, t0, x, t, dt, 1e-5);
ListBox1.Items.Add(" " + t );
ListBox2.Items.Add(" " + x[0]);
ListBox3.Items.Add(" " + x[1]);
ListBox4.Items.Add(" " + x[2]);
ListBox5.Items.Add(" " + x[3]);
}
}
|
|