function [t1,Y] = computelorenz(t_start, t_end, step, sigma, r, b, y0)
%
% Computes the Lorenz time series between 't_start' and 't_end' in 'step' increments 
%
% arguments:
%  t_start: start time (0)
%  t_end: end time (40)
%  step: step increment (1e-3)
%  y0: initial conditions ([-8 8 27])
%  b: (8/3)
%  r: (28);
%  sigma: (10);
%
% return: 
%  t1: time
%  Y: solutions (each t corresponds to a row in Y)
%

% set ode45 options
%
options = odeset('RelTol',1e-4,'AbsTol',[step step step]);

% calculate soltion to differential equations
%
[t1,Y] = ode45(@lorenzequation,[t_start t_end],y0,options,b,r,sigma);

% define Lorenz equations
%
function dxyz = lorenzequation(t,xyz,b,r,sigma)
dxyz = zeros(3,1);
dxyz(1) = - sigma*xyz(1) + sigma*xyz(2);
dxyz(2) = - xyz(1)*xyz(3) + r*xyz(1) - xyz(2);
dxyz(3) = xyz(1)*xyz(2) - b*xyz(3);