%% Lab 1 

%% Question 1

% dimensions in feet
ht = 4;
len = 8;
wid = 4;

% meters per foot
mPerFt = 0.0254 * 12;

% volume in cubic meters
volume = ht * len * wid * mPerFt ^ 3


%%  Question 2a

% from the diagram we have
%    tan(theta) = 1 AU / x
% where x is the number of AUs in 1 parsec and
% theta is 1/3600 degrees
auPerPc = 1 / tand(1 / 3600)


%% Question 2b

mPerLy = 9460730472580800;
mPerAu = 149597870700;
lyPerPc = 1 * auPerPc * mPerAu / mPerLy


%% Question 2c

lyPerAu = mPerAu / mPerLy


%% Question 3a

% conversion factor from km/h to m/s
toMPerS = 1 / 3.6;

% time is not required; use Equation 3 and solve for a
v = 60 * toMPerS;
v0 = 100 * toMPerS;
x0 = 0;
x = 100;
a = 0.5 * (v^2 - v0^2) / (x - x0)

%% Question 3b

% acceleration is not required; use Equation 4 and solve for t
t = 2 * (x - x0) / (v0 + v)


%% Question 3c

% position is not required; use Equation 1 and solve for t
v = 0;
t = (v - v0) / a


%% Question 3d

dx = -0.5 * a * t^2
dx = v0 * t + 0.5 * a * t^2


%% Question 3e

dx = 250;
t = sqrt(-2 * dx / a);

v0 = sqrt(-2 * a * dx)
2 * dx /(v0 + v)

%% Question 4

R1 = 100;
R2 = 200;
R3 = 300;
Rt = 1 / ((1 / R1) + (1 / R2) + (1 / R3))

%% Question 5

% The behavior of floor(x) and ceil(x) does not depend on
% the sign of the x; the behavior of round(x) does depend
% on the sign of x. So, to correctly answer the question,
% we need to consider both positive and negative values
% of x.

x = [-1:0.1:1]';
[x round(x) floor(x) ceil(x)]

% Based on the table of values, we can see that:
%
% For positive values of x
%   round(x) is equivalent to floor(x) if the fractional part
%   of x is less than 0.5
%
%   round(x) is equivalent to ceil(x) if the fractional part
%   of x is greater than or equal to 0.5
%
% For negative values of x
%   round(x) is equivalent to floor(x) if the fractional part
%   of x is greater than or equal to 0.5
%
%   round(x) is equivalent to ceil(x) if the fractional part
%   of x less than 0.5

%% Question 6

c = 3e8;
v = 0.99 * c;
gamma = 1 / sqrt(1 - v^2 / c^2)
