function dy= lorentz(t,y)
% LORENTZ Calculates particle motion in given E and B fields
% Input values are scalar time t and vector y(6)= (x,y,z,vx,vy,vz)
% Electric field vector E(3) is given by function electric (in electric.m)
% Magnetic field vector B(3) is given by function magnetic (in magnetic.m)
% Output values are column vector dy(6)=(dx/dt,dy/dt,dz/dt,dvx/dt,dvy/dt,dvz/dt)
%

% Get Electric and Magnetic Fields for this (t,y)
E=electric(t,y);
B=magnetic(t,y);

% Charge-to-Mass Ratio
qoverm=1. ;

dy=zeros(6,1) ;  %Column vector with 6 values
% Velocities
dy(1)=y(4) ;
dy(2)=y(5) ;
dy(3)=y(6) ;
% Accelerations
dy(4)=qoverm*E(1)+ qoverm*(B(3)*y(5)-B(2)*y(6)) ;
dy(5)=qoverm*E(2)+ qoverm*(B(1)*y(6)-B(3)*y(4)) ;
dy(6)=qoverm*E(3)+ qoverm*(B(2)*y(4)-B(1)*y(5)) ;
