// sim_difeq.java solve simultaneous differential equations // by Runge-Kutta by Gills method // // solve system of equations Y_i = Y'_i(X, Y_1, ..., Y_n) for i=1,n // // user sets N number of equations (in N dependent variables) // Y array of N dependent variables with initial values // F array of N first derivatives of Y's (computed in loop) // Q array of N for use by Runge // X independent variable with initial value // XLIM limit value of X with value // H step size, delta X with value // M setp counter, initialize to zero // K returned 1=compute derivatives, 2=have Y values at X+H public strictfp class sim_difeq { static int M; static double X; public static void main(String args[]) { int N = 4; // number of equations double Y[] = new double[N]; // dependent variables double F[] = new double[N]; // computed derivatives, Y' double Q[] = new double[N]; // temporaries for Runge double XLIM, H; int K; System.out.println("sim_difeq.java solving "+N+" equations"); X = 0.0; // initial independent variable XLIM = 1.0; // final value of independent variable H = 0.1; // step size M = 0; // step counter // initial condition for dependent variables for(int i=0; i