% the program takes the intial data y_0 at the initial time x_0 and 
% computes up to time x_final using n timesteps.  It creates
% two vectors, x and y, which you can then plot against each other
% plot(x,y)
%
% [x,y] = euler_step(y_0,x_0,x_final,n)

function [x,y] = euler_step(y_0,x_0,x_final,n)

% for dy/dx = f(y(x),x)
% y(x+dx) ~ y(x) + dx y'(x) = y(x) + dx f(y(x),x)

% size of the time-step:
dx = (x_final-x_0)/n;

% put initial data into vector
x(1) = x_0;
y(1) = y_0;
for i=1:n
  y(i+1) = y(i) + dx*F(y(i),x(i));
  x(i+1) = x_0 + i*dx;
end
