Skip to the content of the web site.

Project U.2: Time dilation and length contraction

When an object is moving very fast (at relativistic speeds), time begins to slow down and length begins to contract.

The Lorenz factor describes the time dilation and the length contraction by the formula

$\gamma = \frac{1}{\sqrt{1 - \frac{v^2}{c^2}}}$

where $c$ is the speed of light and $v$ is the speed of the object in question. First, write a function that calculates the Lorentz factor with the function declaration:

double lorentz_factor( double speed );

and then write two functions that determine the time dilation and length contraction that use the formulas

$t' = \gamma t$
$\ell' = \frac{\ell}{\gamma}$

where $t$ is the undilated time, and $\ell$ is the uncontracted length.

double time_dilation( double time, double speed );
double length_contraction( double length, double speed );

Your documentation should clearly specify the units of the parameters and the units of the return values.

Note that while the units of speed must be specified, the units of time and length need not be specified, as the calculation is simply a scalar multiple of the argument, so if the argument is in feet, the output will also be in feet, and if the argument is in seconds, the output will be in seconds.