The IMSL_CONSTANT function returns the value of various mathematical and physical constants.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
The names allowed are listed in the table that follows. Values marked with (mp) are exact (to machine precision). The references in the right-hand column are indicated by code numbers: (1) for Cohen and Taylor (1986), (2) for Liepman (1964), and (3) for precomputed mathematical constants. The supported units are listed below.
Name |
Description |
Value |
Ref. |
amu |
atomic mass unit
|
1.6605655 x 10–27 kg
|
1 |
ATM |
standard atm. pressure
|
1.01325 x 105 N/m2 (mp)
|
2 |
AU |
astronomical unit
|
1.496 x 1011 m
|
|
Avogadro |
Avogadro’s number, N
|
6.022045 x 1023 1/mole
|
1 |
Boltzman |
Boltzman’s constant, k
|
1.380662 x 10–23 J / K
|
1 |
C |
speed of light, c
|
2.997924580 x 108 m/s
|
1 |
Catalan |
Catalan’s constant
|
0.915965... (mp)
|
3 |
E |
base of natural logs, e
|
2.718... (mp) |
3 |
ElectronCharge |
electron charge, e
|
1.6021892 x 10–19 C
|
1 |
ElectronMass |
electron mass, me
|
9.109534 x 10–31 kg
|
1 |
ElectronVolt |
electron volt, ev
|
1.6021892 x 10–19 J
|
1 |
Euler |
Euler’s constant, γ
|
0.577... (mp) |
3 |
Faraday |
Faraday constant, F
|
9.648456 x 104 C/mole
|
1 |
FineStructure |
fine structure, α
|
7.2973506 x 10–3
|
1 |
Gamma |
Euler’s constant, γ
|
0.577... (mp) |
3 |
Gas |
gas constant, R0
|
8.31441 J/mole/K
|
1 |
Gravity |
gravitational constant, G
|
6.6720 x 10–11 N m2 /
kg2 |
1 |
Hbar |
Planck’s constant / 2π
|
1.0545887 x 10–34 J s
|
1 |
PerfectGasVolume
|
std. vol. ideal gas
|
2.241383 x 10–2 m3 /
mole |
1 |
Pi |
Pi, π |
3.141... (mp) |
3 |
Planck |
Planck’s constant, h
|
6.626176 x 10–34 J s
|
1 |
ProtonMass |
proton mass, Mp
|
1.6726485 x 10–27 kg
|
1 |
Rydberg |
Rydberg’s constant, Rinfinity
|
1.097373177 x 107 /m
|
1 |
Speedlight |
speed of light, c
|
2.997924580 x 108 m/s
|
1 |
StandardGravity |
standard g |
9.80665 m/s2 (mp)
|
2 |
StandardPressure
|
standard atm. pressure
|
1.01325 x 105 N/m2
(mp) |
2 |
StefanBoltzman |
Stefan-Boltzman, σ
|
5.67032 x 10–8 W/K4
/m2 |
1 |
WaterTriple |
triple point of water
|
2.7316 x 102 K
|
2 |
The units allowed are as follows:
Unit |
Description |
time |
day, hour = hr, min = minute, s = sec = second, year
|
frequency |
Hertz = Hz |
mass |
AMU, g = gram, lb = pound, ounce = oz, slug
|
distance |
Angstrom, AU, feet = foot, in = inch,
m = meter = metre, micron, mile, mill, parsec, yard
|
area |
acre |
volume |
l = liter = litre
|
force |
dyne, N = Newton
|
energy |
BTU, Erg, J = Joule
|
work |
W = watt |
pressure |
ATM = atmosphere, bar
|
temperature |
degC = Celsius, degF = Fahrenheit, degK = Kelvin
|
viscosity |
poise, stoke |
charge |
Abcoulomb, C = Coulomb, statcoulomb
|
current |
A = ampere, abampere, statampere
|
voltage |
Abvolt, V = volt
|
magnetic induction
|
T = Tesla, Wb = Weber
|
other units |
l, farad, mole, Gauss, Henry, Maxwell, Ohm
|
The metric prefixes listed in the next table can be used with the previous units. The one- or two-letter prefixes can only be used with one-letter unit abbreviations.
Prefix |
Definition |
Value |
a |
atto |
10–18 |
f |
femto |
10–15 |
p |
pico |
10–12 |
n |
nano |
10–9 |
u |
micro |
10–6 |
m |
milli |
10–3 |
c |
centi |
10–2 |
d |
deci |
10–1 |
dk |
deca |
102 |
k |
kilo |
103 |
|
myria |
104 |
|
mega |
106 |
g |
giga |
109 |
t |
tera |
1012 |
There is no one-letter unit abbreviation for myria or mega since m means milli.
Examples
Example 1
In this example, Euler’s constant γ is obtained and printed. Euler’s constant is defined to be as follows:
PM, IMSL_CONSTANT('gamma')
0.577216
Example 2
In this example, the speed of light is obtained using several different units.
c1 = IMSL_CONSTANT('SpeedLight', 'meter/second')
c2 = IMSL_CONSTANT('SpeedLight', 'mile/second')
c3 = IMSL_CONSTANT('SpeedLight', 'cm/ns')
PM, 'speed of light = ', c1, c2, c3, $
Title =' meters/second ' + $
'miles/second cm/ns'
IDL prints:
meters/second miles/second cm/ns
speed of light = 2.99792e+008 186282. 29.9792
Syntax
Result = IMSL_CONSTANT(Name[, Units]] [, /DOUBLE])
Return Value
By default, returns the desired constant. If no value can be computed, NaN (Not a Number) is returned.
Arguments
Name
Scalar string specifying the name of the desired constant. The case of the characters is not relevant when specifying name, i.e., character strings “PI”, “Pi”, “pI”, and “pi” are equivalent. Spaces and underscores are allowed and ignored.
Units (optional)
Scalar string specifying the units of the desired constant. If empty, then Systeme International d’Unites (SI) units are assumed. The case of the characters is not relevant when specifying units, i.e., character strings “METER”, “Meter”, and “meter” are equivalent. Parameter units has the form “U1*U2*...*Um/V1/.../Vn,” where Ui and Vi are the names of basic units or the names of basic units raised to a power. Basic units must be separated by * or /. Powers are indicated by ^, as in “m^2” for m2. Examples are “METER*KILOGRAM/SECOND”, “M*KG/S”, “METER”, or “M/KG^2”.
Keywords
DOUBLE (optional)
If present and nonzero, double precision is used.
Errors
Warning Errors
MATH_MASS_TO_FORCE: Conversion of units-of-mass to units-of-force required for consistency.
Version History