J3/05-248r3
To: J3
From: Dan Nagle
Subject: libm math functions
Date: 2005 August 12
At Delft, it was decided to pursue the libm procedures.
This paper attempts to provide edits to do so.
The specifications are in 05-132r2, pursuant to J3-038.
Specification: Add subsections to Section 13 detailing
the Fortran names for these procedures from the C libm:
j0, j1, jn, y0, y1, yn, erf, erfc, hypot, gamma, lgamma.
(Some of the C names should not be used due
to the common usage,
in Fortran, of names such as j0 etc.)
The functions are (the C names):
Bessel functions (j0, j1, jn, y0, y1, yn)
erf Functions (erf, erfc)
Hypotenuse (hypot)
Gamma and log gamma (tgamma, lgamma)
The detailed mathematical specification of these
procedures is given in the references above.
The intention is to allow the vendor to use
the procedure supplied by libm, so the exact
specification is left to libm, which is most likely
what the applications programmer wants.
Edits would include adding to the list in 13.5.2:
BESSEL_J0
BESSEL_J1
BESSEL_JN
BESSEL_Y0
BESSEL_Y1
BESSEL_YN
ERFC
ERF
GAMMA
HYPOT
LOG_GAMMA
Syntax:
No new syntax. The procedure names are as above.
The calling sequences are the same one- or two- argument sequences
as the C versions, except that LOG_GAMMA is a subroutine.
Edits:
[Add to the list 13.5.2]
[294:28+] Add
"BESSEL_J0
BESSEL_J1
BESSEL_JN
BESSEL_Y0
BESSEL_Y1
BESSEL_YN
ERFC"
[294:30+] Add
"ERF"
[294:31+] Add
"GAMMA
HYPOT"
[294:33+] Add
"LOG_GAMMA"
[306:13+] Add
"13.7.15+ BESSEL_J0 (X)
*Description.* Bessel function of the first kind
of order zero.
*Class.* Elemental function.
*Argument.* X shall be of type real.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the first kind of the zeroth order of X.
*Example.* BESSEL_J0(1.0) has the value 0.765 (approximately).
13.7.15+ BESSEL_J1 (X)
*Description.* Bessel function of the first kind
of order one.
*Class.* Elemental function.
*Argument.* X shall be of type real.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the first kind of the first order of X.
*Example.* BESSEL_J1(1.0) has the value 0.440 (approximately).
13.7.15+ BESSEL_JN (N,X)
*Description.* Bessel function of the first kind
of order N.
*Class.* Elemental function.
*Arguments.*
X shall be of type real.
N shall be of type integer and nonnegative.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the first kind of the Nth order of X.
*Example.* BESSEL_JN(2, 1.0) has the value 0.115 (approximately).
13.7.15+ BESSEL_Y0 (X)
*Description.* Bessel function of the second kind
of order zero.
*Class.* Elemental function.
*Argument.* X shall be of type real.
Its value shall be greater than zero.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the second kind of the zeroth order of X.
*Example.* BESSEL_Y0(1.0) has the value 0.088 (approximately).
13.7.15+ BESSEL_Y1 (X)
*Description.* Bessel function of the second kind
of order one.
*Class.* Elemental function.
*Argument.* X shall be of type real.
Its value shall be greater than zero.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the second kind of the first order of X.
*Example.* BESSEL_Y1(1.0) has the value -0.781 (approximately).
13.7.15+ BESSEL_YN (N,X)
*Description.* Bessel function of the second kind
of order N.
*Class.* Elemental function.
*Arguments.*
X shall be of type real. Its value shall be
greater than zero.
N shall be of type integer and nonnegative.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the Bessel
function of the second kind of the Nth order of X.
*Example.* BESSEL_YN(2, 1.0) has the value -1.651 (approximately)."
[308:20+] Add
"ERFC (X)
*Description.* Complementary erf function.
*Class.* Elemental function.
*Argument.* X shall be of type real.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the
complementary error function (that is, 1.0 - erf(X))
of the erf function, erf(X).
*Example.* ERFC(1.0) has the value 0.157 (approximately)."
[315:24+] Add
"ERF (X)
*Description.* erf function.
*Class.* Elemental function.
*Argument.* X shall be of type real.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the
erf function,
2 divided by sqrt(pi) times the integral
from 0 to x of exp( -t*t) dt.
*Example.* ERF(1.0) has the value 0.843 (approximately)."
[317:10+] Add
"GAMMA (X)
*Description.* Gamma function.
*Class.* Elemental function.
*Argument.* X shall be of type real. Its value
shall not be a negative integer or zero.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation
of the gamma function,
the integral from 0 to infinity
of exp( -t) t**( x - 1) dt.
*Example.* GAMMA(1.0) has the value 1.000 (approximately)."
[319:20+] Add
"HYPOT (X,Y)
*Description.* Euclidean distance function
*Class.* Elemental function.
*Argument.*
X shall be of type real.
Y shall be of type real
with the same kind type parameter as X.
*Result Characteristics.* Same as X.
*Result Value.* The result has a value equal
to a processor-dependent approximation of the
Euclidean distance sqrt( x*x + y*y ).
*Example.* HYPOT(2.0, 1.0) has the value 2.236 (approximately)."
[329:21+] Add
"LOG_GAMMA (X , LOGGAMMA, [, SIGNGAM])
*Description.* log gamma function.
*Class.* Elemental subroutine.
*Argument.*
X shall be of type real. Its value
shall not be a negative integer or zero.
LOGGAMMA shall be of type real and
of the same type kind parameter
as X. It is an INTENT(OUT) argument.
LOGGAMMA is assigned a value equal
to a processor-dependent approximation of the
natural logarithm of the absolute value of the
gamma function."
SIGNGAM (optional) shall be of type real and
have the same kind type parameter
as X. It is an INTENT(OUT) argument.
SIGNGAM is assigned the value 1.0
if the GAMMA function
is positive, and is assigned the value -1.0
if the GAMMA function is negative.
*Example.* CALL LOG_GAMMA(1.0, LG) assigns the value
0.765 (approximately) to LG."