Content-type: text/html Man page of libm

libm

Section: Interface Libraries (3LIB)
Updated: 12 Jul 2006
Index Return to Main Contents
 

NAME

libm - C math library  

SYNOPSIS

c99 [ flag... ] file... -lm [ library... ] 
 

DESCRIPTION

Functions in this library provide common elementary mathematical functions and floating point environment routines defined by System V, ANSI C, POSIX, and so on. See standards(5). Additional functions in this library provide extended support for handling floating point exceptions.  

INTERFACES

The shared object libm.so.2 provides the public interfaces defined below. See intro(3) for additional information on shared object interfaces.

acosacosf
acoshacoshf
acoshlacosl
asinasinf
asinhasinhf
asinhlasinl
atanatan2
atan2fatan2l
atanfatanh
atanhfatanhl
atanlcabs
cabsfcabsl
cacoscacosf
cacoshcacoshf
cacoshlcacosl
cargcargf
carglcasin
casinfcasinh
casinhfcasinhl
casinlcatan
catanfcatanh
catanhfcatanhl
catanlcbrt
cbrtfcbrtl
ccosccosf
ccoshccoshf
ccoshlccosl
ceilceilf
ceillcexp
cexpfcexpl
cimagcimagf
cimaglclog
clogfclogl
conjconjf
conjlcopysign
copysignfcopysignl
coscosf
coshcoshf
coshlcosl
cpowcpowf
cpowlcproj
cprojfcprojl
crealcrealf
creallcsin
csinfcsinh
csinhfcsinhl
csinlcsqrt
csqrtfcsqrtl
ctanctanf
ctanhctanhf
ctanhlctanl
erferfc
erfcferfcl
erfferfl
expexp2
exp2fexp2l
expfexpl
expm1expm1f
expm1lfabs
fabsffabsl
fdimfdimf
fdimlfeclearexcept
fegetenvfegetexceptflag
fegetroundfeholdexcept
feraiseexceptfesetenv
fesetexceptflagfesetround
fetestexceptfeupdateenv
fex_get_handlingfex_get_log
fex_get_log_depthfex_getexcepthandler
fex_log_entryfex_merge_flags
fex_set_handlingfex_set_log
fex_set_log_depthfex_setexcepthandler
floorfloorf
floorlfma
fmaffmal
fmaxfmaxf
fmaxlfmin
fminffminl
fmodfmodf
fmodlfrexp
frexpffrexpl
gammagamma_r
gammafgammaf_r
gammalgammal_r
hypothypotf
hypotlilogb
ilogbfilogbl
isnanj0
j0fj0l
j1j1f
j1ljn
jnfjnl
ldexpldexpf
ldexpllgamma
lgamma_rlgammaf
lgammaf_rlgammal
lgammal_rllrint
llrintfllrintl
llroundllroundf
llroundllog
log10log10f
log10llog1p
log1pflog1pl
log2log2f
log2llogb
logbflogbl
logflogl
lrintlrintf
lrintllround
lroundflroundl
matherrmodf
modffmodfl
nannanf
nanlnearbyint
nearbyintfnearbyintl
nextafternextafterf
nextafterlnexttoward
nexttowardfnexttowardl
powpowf
powlremainder
remainderfremainderl
remquoremquof
remquolrint
rintfrintl
roundroundf
roundlscalb
scalbfscalbl
scalblnscalblnf
scalblnlscalbn
scalbnfscalbnl
signgamsigngamf
signgamlsignificand
significandfsignificandl
sinsincos
sincosfsincosl
sinfsinh
sinhfsinhl
sinlsqrt
sqrtfsqrtl
tantanf
tanhtanhf
tanhltanl
tgammatgammaf
tgammaltrunc
truncftruncl
y0y0f
y0ly1
y1fy1l
ynynf
ynl

The following interfaces are unique to the x86 and x64 versions of this library:

fegetprecfesetprec

 

ACCURACY

ISO/IEC 9899:1999, also known as C99, specifies the functions listed in the following tables and states that the accuracy of these functions is "implementation-defined". The information below characterizes the accuracy of these functions as implemented in libm.so.2. For each function, the tables provide an upper bound on the largest error possible for any argument and the largest error actually observed among a large sample of arguments. Errors are expressed in "units in the last place", or ulps, relative to the exact function value for each argument (regarding the argument as exact). Ulps depend on the precision of the floating point format: if y is the exact function value, x and x' are adjacent floating point numbers such that x < y < x', and x'' is the computed function value, then provided x, x', and x'' all lie in the same binade, the error in x'' is |y - x''| / |x - x'| ulps. In particular, when the error is less than one ulp, the computed value is one of the two floating point numbers adjacent to the exact value.

The bounds and observed errors listed below apply only in the default floating point modes. Specifically, on SPARC, these bounds assume the rounding direction is round-to-nearest and non-standard mode is disabled. On x86, the bounds assume the rounding direction is round-to-nearest and the rounding precision is round-to-64-bits. Moreover, on x86, floating point function values are returned in a floating point register in extended double precision format, but the bounds below assume that the result value is then stored to memory in the format corresponding to the function's type. On x64, the bounds assume the rounding direction in both the x87 floating point control word and the MXCSR is round-to-nearest, the rounding precision in the x87 control word is round-to-64-bits, and the FTZ and DAZ modes are disabled.

The error bounds listed below are believed to be correct, but smaller bounds might be proved later. The observed errors are the largest ones currently known, but larger errors might be discovered later. Numbers in the notes column refer to the notes following the tables.  

Real Functions

 

Single precision real functions (SPARC, x86, and x64)

error boundlargest error
function (ulps)observed (ulps)notes
acosf1.0< 1
acoshf1.0< 1
asinf1.0< 1
asinhf1.0< 1
atanf1.0< 1
atan2f1.0< 1
atanhf1.0< 1
cbrtf1.0< 1
cosf1.0< 1
coshf1.0< 1
erff1.0< 1
erfcf1.0< 1
expf1.0< 1
exp2f1.0< 1
expm1f1.0< 1
hypotf1.0< 1
lgammaf1.0< 1
logf1.0< 1
log10f1.0< 1
log1pf1.0< 1
log2f1.0< 1
powf1.0< 1
sinf1.0< 1
sinhf1.0< 1
sqrtf0.50.500[1]
tanf1.0< 1
tanhf1.0< 1
tgammaf1.0< 1

 

Double precision real functions (SPARC and x64)

error boundlargest error
function (ulps)observed (ulps)notes
acos1.0< 1
acosh4.01.878
asin1.0< 1
asinh7.01.653
atan1.0<1
atan22.51.475
atanh4.01.960
cbrt1.0< 1
cos1.0< 1
cosh3.01.168
erf4.00.959
erfc6.02.816
exp1.0< 1
exp22.01.050
expm11.0< 1
hypot1.0< 1
lgamma61.55.629[2]
log1.0< 1
log103.51.592
log1p1.0< 1
log21.0< 1
pow1.0< 1
sin1.0< 1
sinh4.02.078
sqrt0.50.500[1]
tan1.0< 1
tanh3.52.136
tgamma1.0< 1

 

Double precision real functions (x86)

error boundlargest error
function (ulps)observed (ulps)notes
acos1.0< 1
acosh4.01.694
asin1.0< 1
asinh7.01.493
atan1.0< 1
atan21.0< 1
atanh4.01.445
cbrt1.0< 1
cos1.0< 1
cosh3.01.001
erf4.00.932
erfc6.02.728
exp1.0< 1
exp21.0< 1
expm11.0< 1
hypot1.0< 1
lgamma61.52.654[2]
log1.0< 1
log101.0< 1
log1p1.0< 1
log21.0< 1
pow1.0< 1
sin1.0< 1
sinh4.01.458
sqrt0.50030.500[1]
tan1.0< 1
tanh3.51.592
tgamma1.0< 1

 

Quadruple precision real functions (SPARC)

error boundlargest error
function (ulps)observed (ulps)notes
acosl3.51.771
acoshl8.01.275
asinl4.02.007
asinhl9.01.823
atanl1.0< 1
atan2l2.51.102
atanhl4.01.970
cbrtl1.0< 1
cosl1.0< 1
coshl3.50.985
erfl2.00.779
erfcl68.513.923
expl1.0< 1
exp2l2.00.714
expm1l2.01.020
hypotl1.0< 1
lgammal18.52.916[2]
logl1.0< 1
log10l3.51.156
log1pl2.01.216
log2l3.51.675
powl1.0< 1
sinl1.0< 1
sinhl4.51.589
sqrtl0.50.500[1]
tanl4.52.380
tanhl4.51.692
tgammal1.0< 1

 

Extended precision real functions (x86 and x64)

error boundlargest error
function (ulps)observed (ulps)notes
acosl3.01.868
acoshl8.02.352
asinl3.01.716
asinhl9.02.346
atanl1.0< 1
atan2l1.0< 1
atanhl4.02.438
cbrtl1.0< 1
cosl1.0< 1
coshl3.51.288
erfl1.0< 1
erfcl78.513.407
expl3.51.291
exp2l1.50.807
expm1l4.01.936
hypotl3.52.087
lgammal22.54.197[2]
logl2.00.881
log10l2.01.284
log1pl5.02.370
log2l1.0< 1
powl32770.04478.132
sinl1.0< 1
sinhl4.52.356
sqrtl0.50.500[1]
tanl4.52.366
tanhl4.52.417
tgammal1.0< 1

 

Notes:

[1] On SPARC and x64, sqrtf, sqrt, and sqrtl are correctly rounded in accordance with IEEE 754. On x86, sqrtl is correctly rounded, sqrtf is correctly rounded provided the result is narrowed to single precision as discussed above, but sqrt might not be correctly rounded due to "double rounding": when the intermediate value computed to extended precision lies exactly halfway between two representable numbers in double precision, the result of rounding the intermediate value to double precision is determined by the round-ties-to-even rule. If this rule causes the second rounding to round in the same direction as the first, the net rounding error can exceed 0.5 ulps. (The error is bounded instead by 0.5*(1 + 2^-11) ulps.)

[2] Error bounds for lgamma and lgammal apply only for positive arguments.

 

Complex functions

The real-valued complex functions cabsf, cabs, cabsl, cargf, carg, and cargl are equivalent to the real functions hypotf, hypot, hypotl, atan2f, atan2, and atan2l, respectively. The error bounds and observed errors given above for the latter functions also apply to the former.

The complex functions listed below are complex-valued. For each function, the error bound shown applies separately to both the real and imaginary parts of the result. (For example, both the real and imaginary parts of cacosf(z) are accurate to within 1 ulp regardless of their magnitudes.) Similarly, the largest observed error shown is the largest error found in either the real or the imaginary part of the result.  

Single precision complex functions (SPARC and x64)

error boundlargest error
function (ulps)observed (ulps)notes
cacosf, cacoshf1< 1[1]
casinf, casinhf1< 1
catanf, catanhf6< 1
ccosf, ccoshf102.012
cexpf32.239
clogf3< 1
cpowf---< 1[2]
csinf, csinhf102.009
csqrtf4< 1
ctanf, ctanhf136.987

 

Single precision complex functions (x86)

error boundlargest error
function (ulps)observed (ulps)notes
cacosf, cacoshf1< 1[1]
casinf, casinhf1< 1
catanf, catanhf6< 1
ccosf, ccoshf101.984
cexpf31.984
clogf3< 1
cpowf---< 1[2]
csinf, csinhf101.973
csqrtf4< 1
ctanf, ctanhf134.657

 

Double precision complex functions (SPARC and x64)

error boundlargest error
function (ulps)observed (ulps)notes
cacos, cacosh93.831[1]
casin, casinh93.732
catan, catanh64.179
ccos, ccosh103.832
cexp32.255
clog32.870
cpow--[2]
csin, csinh103.722
csqrt43.204
ctan, ctanh137.143

 

Double precision complex functions (x86)

error boundlargest error
function (ulps)observed (ulps)notes
cacos, cacosh93.624[1]
casin, casinh93.624
catan, catanh62.500
ccos, ccosh102.929
cexp32.147
clog31.927
cpow--[2]
csin, csinh102.918
csqrt41.914
ctan, ctanh134.630

 

Quadruple precision complex functions (SPARC)

error boundlargest error
function (ulps)observed (ulps)notes
cacosl, cacoshl93[1]
casinl, casinhl93
catanl, catanhl63
ccosl, ccoshl103
cexpl32
clogl32
cpowl--[2]
csinl, csinhl103
csqrtl43
ctanl, ctanhl135

 

Extended precision complex functions (x86 and x64)

error boundlargest error
function (ulps)observed (ulps)notes
cacosl, cacoshl92[1]
casinl, casinhl92
catanl, catanhl62
ccosl, ccoshl103
cexpl32.699
clogl31
cpowl--[2]
csinl, csinhl103
csqrtl41.452
ctanl, ctanhl135

 

Notes:

[1] The complex hyperbolic trigonometric functions are equivalent by symmetries to their circular trigonometric counterparts. Because the implementations of these functions exploit these symmetries, corresponding functions have the same error bounds and observed errors.

[2] For large arguments, the results computed by cpowf, cpow, and cpowl can have unbounded relative error. It might be possible to give error bounds for specific domains, but no such bounds are currently available. The observed errors shown are for the domain {(z,w) : max(|Re z|, |Im z|, |Re w|, |Im w|) <= 1}.

 

FILES

/lib/libm.so.2 shared object

/lib/64/libm.so.2 64-bit shared object

 

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPEATTRIBUTE VALUE
AvailabilitySUNWlibmsr
MT-LevelSafe with exceptions

As described on the lgamma(3M) manual page, gamma() and lgamma() and their float and long double counterparts are Unsafe. All other functions in libm.so.2 are MT-Safe.  

SEE ALSO

intro(3), lgamma(3M), math.h(3HEAD), attributes(5), standards(5)


 

Index

NAME
SYNOPSIS
DESCRIPTION
INTERFACES
ACCURACY
Real Functions
Single precision real functions (SPARC, x86, and x64)
Double precision real functions (SPARC and x64)
Double precision real functions (x86)
Quadruple precision real functions (SPARC)
Extended precision real functions (x86 and x64)
Notes:
Complex functions
Single precision complex functions (SPARC and x64)
Single precision complex functions (x86)
Double precision complex functions (SPARC and x64)
Double precision complex functions (x86)
Quadruple precision complex functions (SPARC)
Extended precision complex functions (x86 and x64)
Notes:
FILES
ATTRIBUTES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 02:38:41 GMT, October 02, 2010