This chapter describes macros for the values of physical constants, such
as the speed of light, c, and gravitational constant, G.
The values are available in different unit systems, including the
standard MKS system (meters, kilograms, seconds) and the CGS system
(centimeters, grams, seconds), which is commonly used in Astronomy.
The definitions of constants in the MKS system are available in the file
`gsl_const_mks.h'. The constants in the CGS system are defined in
`gsl_const_cgs.h'. Dimensionless constants, such as the fine
structure constant, which are pure numbers are defined in
`gsl_const_num.h'.
The full list of constants is described briefly below. Consult the
header files themselves for the values of the constants used in the
library.
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