function v = velcoast(v0, vt, g, t0, t)
%velcoast calculates the velocity from burnout to apogee
% v0 is the initial velocity.
% vt is the terminal velocity.
% g is the local acceleration of gravity.
% t0 is the time at which the coasting phase began.
% t is the array of times for which the coasting velocity is desired.
v = vt*tan(-g/vt*(t-t0)+atan(v0/vt));
end