function vend= velocityClosedForm(ti, tf, vi, m, cd)
% velocityClosedForm(ti, tf, vi, m, cd):
%   The closed form solution to the free falling bungee jumper
%
% input:
%   ti = inital time (sec)
%   tf = final time (sec)
%   vi = inital value of dependent variable (m/s)
%   m= mass (kg)
%   cd= drag coefficient (kg/m)
%
% output:
%   vend= the velocity of the jumper at tf (m/s)
format short

timeArray= linspace(ti,tf);
g= 9.81;

vData=zeros(1,100);
vData(1)= vi;
for i= 2:100
    vData(i)= sqrt(g * m / cd) * tanh( sqrt(g * cd / m) * timeArray(i));
end

plot(timeArray, vData,'r-')
xlabel('time (seconds)');
ylabel('velocity (m/s)');
hold on

vend= vData(100);