function [ t, y ] = euler_one ( dydt, tspan, y0, n )

%*****************************************************************************80
%
%% euler_one approximates the solution to an ODE using Euler's method.
%
%  Discussion:
%
%    This version of the Euler code can only handle one equation,
%    not a system.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    function handle dydt: points to a function that evaluates the right
%    hand side of the ODE.
%
%    real tspan(2): contains the initial and final times.
%
%    real y0: the initial condition.
%
%    integer n: the number of steps to take.
%
%  Output:
%
%    real t(n+1), y(n+1): the times and solution values.
%
  t = zeros ( n + 1, 1 );
  y = zeros ( n + 1, 1 );

  tfirst = tspan(1);
  tlast = tspan(2);
  dt = ( tlast - tfirst ) / n;
  t(1,1) = tspan(1);
  y(1,1) = y0;

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

  return
end

