package odeadapt; /** * ODESolverEuler.java * solves a given ODE by giving the "next" value for x * using simple Euler scheme */ public class ODESolverEuler extends ODESingleStepSolver { /** * construct solver for a given ODE */ public ODESolverEuler(ODE ode) { super(ode); order = 1; } /* * integrate until t + h * using the first order Euler scheme */ public int nextStep(double h) { // x += h * ode.f(x, t); x.plusEquals( ode.f(x, t).times(h) ); t += h; return 1; } }