%% 6.581 Problem set 2
%% Question 2. Large-range electrostatic interactions
%% estatic.m

%% Note: you need to fill in the section indicated below

numCharges = 50;
sepX = logspace(-5,5);
separation = zeros(size(sepX,2),3);
separation(:,1) = sepX';
pointCharges = zeros(2 * numCharges, 3);

for iter=1:length(sepX)
  % produce a list of source charge points and destination charge
  % points--students don't need to modify this
  for i=1:numCharges
	 srcCharges(i,:) = rand(1,3);
	 destCharges(i,:) = reflect(srcCharges(i,:), sepX(iter));
  end
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % a) Students fill in the interaction matrix %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  for i=1:numCharges
	 for j=1:numCharges
		A(i,j) = ;
	 end
  end
 
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
  % b) Decompose A into eigenvalues and eigenvectors using the eig command %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % c) Create rank one, two, k approximations to A. Use sort command to %
  % extract  eigenvalues with largest magnitudes and corresponding      %
  % eigenvectors                                                        %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  r1A = ;
  r2A = ;
  r8A = ;

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % d) take a random charge vector and see how good the low rank approximation is %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  q = rand(numCharges,1);
  r1error(iter) = ;
  r2error(iter) = ;
  r8error(iter) = ;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% e) plot errors as a function of separation distance %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
