% Implementation of the time-independent Schrodinger equation for an
% assumed energy eigenvalue E and arbitrary 1D potential, V(x).
function dqdx = schrodinger(q, x, E, V)

% Interpret state of the system
psi = q(1);
dpsi_dx = q(2);

% Schrodinger equation
d2psi_dx2 = ( V(x) - E ) * psi;

% Return derivative of state vector
dqdx = [dpsi_dx; d2psi_dx2];

% Note that the output is a column vector. This makes the ODEs compatible
% with lsode rather than my lsode2 hack.