J3/05-248r2
To: J3
From: Dan Nagle
Subject: libm math functions
Date: 2005 August 11
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.
(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)
Error 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
COMP_ERROR
ERROR
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:
[7:35+] Add:
"ISO 31-11:1992(E) Quantities and Units- Part 11: Mathematical signs and
symbols for use in the physical sciences and technology."
[Add to the list 13.5.2]
[294:28+] Add
"BESSEL_J0
BESSEL_J1
BESSEL_JN
BESSEL_Y0
BESSEL_Y1
BESSEL_YN
COMP_ERROR"
[294:30+] Add
"ERROR"
[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. Its value
shall satisfy the inequality N >= 0.
*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 0.
*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 0.
*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 satisfy the inequality X > 0.
N shall be of type integer. Its value
shall satisfy the inequality N >= 0.
*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
"COMP_ERROR (X)
*Description.* Complementary error 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
complement (that is, 1.0 - ERROR(X)) of the
error function, ERROR(X).
*Example.* COMP_ERROR(1.0) has the value 0.157 (approximately)."
[315:24+] Add
"ERROR (X)
*Description.* Error 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
error function,
2 divided by sqrt(pi) times the integral
from 0 to x of exp( -t*t) dt.
*Example.* ERROR(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 0.
*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. It shall
have the same kind 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 ), taking
precautions against unwarranted overflows
and underflows.
*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 0.
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
of the same type kind parameter
as X. It is an INTENT(OUT) argument.
SIGNGAM is assigned +1.0 if the GAMMA function
is positive, and is assigned -1.0
if the GAMMA function is negative.
*Example.* CALL LOG_GAMMA(1.0, LG) assigns the value
0.765 (approximately) to LG."