Example: Runge-Kutta-Verner ordinary differential equation solver

An ordinary differential equation problem is solved using a solver which implements the Runge-Kutta-Verner method. The solution at time t=10 is printed.
using System;
using Imsl.Math;

public class OdeRungeKuttaEx1 : OdeRungeKutta.IFunction
{
    public void F(double t, double[] y, double[] yprime)
    {
        yprime[0] = 2.0 * y[0] * (1 - y[1]);
        yprime[1] = - y[1] * (1 - y[0]);
    }


    public static void  Main(String[] args)
    {        
        double[] y = new double[]{1, 3};
        OdeRungeKutta q = new OdeRungeKutta(new OdeRungeKuttaEx1());
        int nsteps = 10;
        for (int k = 0; k < nsteps; k++)
        {
            q.Solve(k, k + 1, y);
        }
        Console.Out.WriteLine("Result = {" + y[0] + "," + y[1] + "}");
    }
}

Output

Result = {3.14434167651608,0.3488265985197}

Link to C# source.