Go to the first, previous, next, last section, table of contents.

Examples

The following program demonstrates the use of the physical constants in a calculation. In this case, the goal is to calculate the range of light-travel times from Earth to Mars.

The required data is the average distance of each planet from the Sun in astronomical units (the eccentricities of the orbits will be neglected for the purposes of this calculation). The average radius of the orbit of Mars is 1.52 astronomical units, and for the orbit of Earth it is 1 astronomical unit (by definition). These values are combined with the MKS values of the constants for the speed of light and the length of an astronomical unit to produce a result for the shortest and longest light-travel times in seconds. The figures are converted into minutes before being displayed.

#include <stdio.h>
#include <gsl/gsl_const_mks.h>

int
main (void)
{
  double c  = GSL_CONST_MKS_SPEED_OF_LIGHT;
  double au = GSL_CONST_MKS_ASTRONOMICAL_UNIT;
  double minutes = GSL_CONST_MKS_MINUTE;

  /* distance stored in meters */
  double r_earth = 1.00 * au;  
  double r_mars  = 1.52 * au;

  double t_min, t_max;

  t_min = (r_mars - r_earth) / c;
  t_max = (r_mars + r_earth) / c;

  printf("light travel time from Earth to Mars:\n");
  printf("minimum = %.1f minutes\n", t_min / minutes);
  printf("maximum = %.1f minutes\n", t_max / minutes);

  return 0;
}

Here is the output from the program,

light travel time from Earth to Mars:
minimum = 4.3 minutes
maximum = 21.0 minutes

Go to the first, previous, next, last section, table of contents.