function [VMeKNOTS,VmeKNOTS,VyeKNOTS,hdotmaxFPM,VxeKNOTS,gammaxDEG,VbgeKNOTS,gammabgDEG,VmdeKNOTS,hdotmdFPM]=...
  boot(S,A,P0HP,C,d,CD0,e,m,b,RPM0,W0,sigma,W)
%function [VMeKNOTS,VmeKNOTS,VyeKNOTS,hdotmaxFPM,VxeKNOTS,gammaxDEG,VbgeKNOTS,gammabgDEG,VmdeKNOTS,hdotmdFPM]=...
%         boot(S,A,P0HP,C,d,CD0,e,m,b,RPM0,W0,sigma,W)
% INPUTS AND TYPICAL VALUES FOR CESSNA 172
%   S=174       Wing reference area (ft^2)
%   A=7.38      Wing aspect ratio
%   P0HP=160    Rated sea level horsepower, hp
%   C=.12       Altitude drop-off parameter
%   d=6.25      Propeller diameter (ft)
%   CD0=.037    Parasite drag coefficient
%   e=.72       Airplane efficiency factor
%   m=1.7       Propeller polar slope
%   b=-.0564    Propeller polar intercept
%   RPM0=2700   Prop revolutions per min
%   W0=2400     Standard weight lbf
%   sigma=.786  Density ratio on given test day
%   W=1800      Test day weight, lbf
%
% OUTPUTS
%   VMeKNOTS    Equivalent velocity for max level flight speed, knots
%   VmeKNOTS    Equivalent velocity for min level flight speed, knots
%   VyeKNOTS    Equivalent velocity for best rate of climb, knots
%   hdotmaxFPM  Best climb rate, ft/min
%   VxeKNOTS    Equivalent velocity for best climb angle, knots
%   gammaxDEG   Best climb angle, deg
%   VbgeKNOTS   Equivalent velocity for best (longest) glide, knots
%   gammabgDEG  Best (longest) glide angle, deg
%   VmdeKNOTS   Equivalent velocity for minimum descent rate, knots
%   hdotmdFPM   Minimum rate of descent, ft/min
%
% Note: For low speeds (M<.3) calibrated airspeed is approximately equal to equivalent airspeed
%
% Ref: Lowry, pp. 206-208 (Chapter 7)
% Assumes single engine. For two engines use boot2


rho0=0.00237691267925741;
n0=RPM0/60;
P0=P0HP*550;    % Rated sea lever power, ft-lbf
E0=m*P0/(n0*d);
phi=(sigma-C)/(1-C);
E=phi*E0;
F0=rho0*d^2*b;
F=sigma*F0;
G0=.5*rho0*S*CD0;
G=sigma*G0;
H0=(2*W0^2)/(rho0*S*pi*e*A);
H=(W/W0)^2*H0/sigma;
K0=F0-G0;
K=sigma*K0;
Q0=E0/K0;
Q=phi*Q0/sigma;
R0=H0/K0;
R=(W/W0)^2*R0/sigma^2;
U0=H0/G0;
U=(W/W0)^2*U0/sigma^2;

rad2deg=180/pi;

VM=sqrt(-Q/2+sqrt(Q*Q/4+R));    % Equation 19, Lowery chapter 7
% Ve=Vt*sqrt(sigma) ft/sec
% VeKNOTS=Ve/1.687808
VMeKNOTS=VM*sqrt(sigma)/1.687808;
Vm=sqrt(-Q/2-sqrt(Q*Q/4+R));   % Equation 21
VmeKNOTS=Vm*sqrt(sigma)/1.687808;
Vy=sqrt(-Q/6+sqrt(Q*Q/36-R/3));  % Equation 24
VyeKNOTS=Vy*sqrt(sigma)/1.687808;
hdotmax=(E*Vy+K*Vy^3-H/Vy)/W;  % Equation 24,39
hdotmaxFPM=hdotmax*60;
Vx=(-R)^.25;   % Equation 27
VxeKNOTS=Vx*sqrt(sigma)/1.687808;
gammax=asin((E-2*sqrt(-K*H))/W);   % Equation 44
gammaxDEG=gammax*rad2deg;
Vbg=U^.25;   % Equation 31
VbgeKNOTS=Vbg*sqrt(sigma)/1.687808;
gammabg=-asin(2*sqrt(G*H)/W);   % Equation 51
gammabgDEG=gammabg*rad2deg;
Vmd=(U/3)^.25;   % Equation 33
VmdeKNOTS=Vmd*sqrt(sigma)/1.687808;
hdotmd=(-G*Vmd^3-H/Vmd)/W;   % Equation 33,46
hdotmdFPM=hdotmd*60;




