function [ t, y ] = euler ( yprime, n, a, b, y0 )

%*****************************************************************************80
%
%% euler uses Euler's method to solve an ODE;
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    29 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    function handle yprime: of the form
%      value = yprime ( t, y )
%    which returns dydt.
%
%    integer N: the number of steps.
%
%    real A, B: the initial and final times.
%
%    real Y0: the initial value of the solution.
%
%  Output:
%
%    real T(N+1): the times.
%
%    real Y(N+1): the computed solution values.
%
  t = linspace ( a, b, n + 1 );
  t = t';
  dt = ( b - a ) / n;

  m = length ( y0 );
  y = zeros ( n + 1, m );
  y(1,:) = y0(:);

  for i = 1 : n
    y(i+1,:) = y(i,:) + dt * yprime ( t(i), y(i,:) );
  end

  return
end

