ODESolverRalston
package odend;
import Jama.*;
/**
* solver using Ralston method
*/
public class ODESolverRalston extends ODESolver {
/** sets ode and initial values */
public ODESolverRalston(ODE ode) {
super(ode);
}
/** computes solution at next time step<br>
* using the 2nd order Ralston scheme
*/
public void nextStep(double h) {
Matrix k1 = ode.f(x, t);
double t1 = t + 3.0 / 4.0 * h;
Matrix x1 = x.plus(k1.times(3.0 / 4.0 * h)); // x1 = x + 3.0/4.0*h*k1
Matrix k2 = ode.f(x1, t1);
// x += (1.0/3.0*k1 + 2.0/3.0*k2)*h
x.plusEquals(k1.times(h / 3.0));
x.plusEquals(k2.times(h * 2.0 / 3.0));
t += h;
}
}

Peter Junglas 20.12.1999