% Test of oneshot.m
function oneshotTest

N_energies = 100;
E_lowest = -100;
E = linspace(E_lowest, 0, N_energies);
width = 6; % This means -3 < x < 3.
for i=1:N_energies
   i
   err(i) = oneshot(E(i), @v1square, width);
end

plot(E, err)
% plot(E, sign(err).*abs(err).^(1/7) )
xlabel('{E}', 'fontsize', 18);
ylabel('{err}', 'fontsize', 18);
title('oneshotTest.m: Eigenvalues are the roots.', 'fontsize', 20)

% Note that the root at E=0 is an artifact!

% err(E) is sometimes almost discontinuous near the roots. Unless E
% is very close to an eigenvalue, the result of the shooting is a wave
% function psi(x) that grows exponentially when the potential is near zero, 
% resulting in a large error compared to the boundary condition. Normalization
% of psi scales this large error down, so that all the wildly erroneous results
% are of similar order. The typical error in dpsi/dx is of order sqrt(-E), so 
% the "err" as defined in oneshot.m tends to look like a square wave multiplied
% by +/- sqrt(E).