function [dxdt,dvdt]= lorentz(q,m,x,v,E0,B0);
% LORENTZ Calculates particle motion in given E and B fields
% Input values are
%      q= particle charge
%      m= particle mass
%      x= position (Column vector)(1:3)
%      v= velocity (Column vector)(1:3)
%      E0=constant electric field  (Column vector)(1:3)
%      B0=constant magnetic field  (Column vector)(1:3)
% Output values are
%      dxdt= position (Column vector)(1:3)
%      dvdt= velocity (Column vector)(1:3)

% Initialized dxdt and dvdt as column vectors 
dxdt=zeros(3,1);
dvdt=zeros(3,1);
  
dxdt(1:3)=v(1:3);
dvdt(1)= q/m*(E0(1) + v(2)*B0(3) -v(3)*B0(2) );
dvdt(2)= q/m*(E0(2) + v(3)*B0(1) -v(1)*B0(3) );
dvdt(3)= q/m*(E0(3) + v(1)*B0(2) -v(2)*B0(1) );

