INTERFACE EulerIntegrator;

IMPORT Integrator;
FROM Integrator IMPORT DiffProc, Time, State, Velocity, Error;

TYPE
  T <: Public;
    (*
      An adaptive Euler integrator for ordinary differential equations.
      
      The "integrate" method performs one or more chained steps of
      the trivial (Euler) method, which is only accurate to first order.  
      
      The time step is automatically chosen at each step, as as
      specified by the client "checkStep" and "checkState" procedures.
      The error estimate at each step is the difference between the
      first- and second-order approximators.

      Created 95/06 by R.L.Liesenfeld, C.H.Q.Forster, and J.Stolfi
    *)
    
  Public = Integrator.T OBJECT METHODS
    END;

PROCEDURE Step(
    diff: DiffProc;
    ta: Time;
    READONLY sa: State;
    READONLY va: Velocity;
    tb: Time;
    VAR sb: State; (* Final state *)
    VAR er: Error; (* Error estimate *)
    VAR v2: Velocity; (* Auxiliary velocities: *)
  );
  (*
    Performs a single step of the trivial Euler
    integrator, extrapolating to the system's path from state "sa" 
    at time "ta" to state "sb" at time "tb". 
    
    The procedure must be given the velocity "va" at "sa", already
    computed.  The estimated error is returned in "er".  *)

END EulerIntegrator.