function dot = carcrash(t,input)

global B k m

if input(2)<0,
    % lost contact; only rolling resistance slows vehicle
    pdot = -0.1*input(1)/m;
else
    % bumper in contact
    pdot = -k*input(2) - B*(input(1)/m);
end

xdot = input(1)/m;

dot = [pdot;xdot];