newlib-cygwin/newlib/libm/mathfp/mathfp.tex

233 lines
5.4 KiB
TeX
Raw Normal View History

2000-02-18 03:39:52 +08:00
@node Math
@chapter Mathematical Functions (@file{math.h})
This chapter groups a wide variety of mathematical functions. The
corresponding definitions and declarations are in @file{math.h}.
Two definitions from @file{math.h} are of particular interest.
@enumerate
@item
The representation of infinity as a @code{double} is defined as
@code{HUGE_VAL}; this number is returned on overflow by many functions.
@item
The structure @code{exception} is used when you write customized error
handlers for the mathematical functions. You can customize error
handling for most of these functions by defining your own version of
@code{matherr}; see the section on @code{matherr} for details.
@end enumerate
@cindex system calls
@cindex support subroutines
@cindex stubs
@cindex OS stubs
Since the error handling code calls @code{fputs}, the mathematical
subroutines require stubs or minimal implementations for the same list
of OS subroutines as @code{fputs}: @code{close}, @code{fstat},
@code{isatty}, @code{lseek}, @code{read}, @code{sbrk}, @code{write}.
@xref{syscalls,,System Calls, libc.info, The Red Hat newlib C Library},
2000-02-18 03:39:52 +08:00
for a discussion and for sample minimal implementations of these support
subroutines.
Alternative declarations of the mathematical functions, which exploit
specific machine capabilities to operate faster---but generally have
less error checking and may reflect additional limitations on some
machines---are available when you include @file{fastmath.h} instead of
@file{math.h}.
@menu
* version:: Version of library
* acos:: Arccosine
* acosh:: Inverse hyperbolic cosine
* asin:: Arcsine
* asinh:: Inverse hyperbolic sine
* atan:: Arctangent
* atan2:: Arctangent of y/x
* atanh:: Inverse hyperbolic tangent
* jN:: Bessel functions (jN, yN)
* cbrt:: Cube root
* copysign:: Sign of Y, magnitude of X
* cosh:: Hyperbolic cosine
* erf:: Error function (erf, erfc)
* exp:: Exponential
* expm1:: Exponential of x, - 1
* fabs:: Absolute value (magnitude)
* floor:: Floor and ceiling (floor, ceil)
* fmod:: Floating-point remainder (modulo)
* frexp:: Split floating-point number
* gamma:: Logarithmic gamma function
* hypot:: Distance from origin
* ilogb:: Get exponent
* infinity:: Floating infinity
* isnan:: Check type of number
* ldexp:: Load exponent
* log:: Natural logarithms
* log10:: Base 10 logarithms
* log1p:: Log of 1 + X
* matherr:: Modifiable math error handler
* modf:: Split fractional and integer parts
* nan:: Floating Not a Number
* nextafter:: Get next representable number
* pow:: X to the power Y
* remainder:: remainder of X divided by Y
* scalbn:: scalbn
* sin:: Sine or cosine (sin, cos)
* sinh:: Hyperbolic sine
* sqrt:: Positive square root
* tan:: Tangent
* tanh:: Hyperbolic tangent
@end menu
@page
@node version
@section Version of library
There are four different versions of the math library routines: IEEE,
POSIX, X/Open, or SVID. The version may be selected at runtime by
setting the global variable @code{_LIB_VERSION}, defined in
@file{math.h}. It may be set to one of the following constants defined
in @file{math.h}: @code{_IEEE_}, @code{_POSIX_}, @code{_XOPEN_}, or
@code{_SVID_}. The @code{_LIB_VERSION} variable is not specific to any
thread, and changing it will affect all threads.
The versions of the library differ only in how errors are handled.
In IEEE mode, the @code{matherr} function is never called, no warning
messages are printed, and @code{errno} is never set.
In POSIX mode, @code{errno} is set correctly, but the @code{matherr}
function is never called and no warning messages are printed.
In X/Open mode, @code{errno} is set correctly, and @code{matherr} is
called, but warning message are not printed.
In SVID mode, functions which overflow return 3.40282346638528860e+38,
2003-10-20 Bob Wilson <bob.wilson@acm.org> * libc/locale/locale.c: Use double quotes in code. * libc/locale/locale.tex: Likewise. * libc/libc.texinfo: Hyphenate "floating-point". * libc/machine/necv70/necv70.tex: Likewise. * libc/stdio/sprintf.c: Likewise. * libc/stdio/sscanf.c: Likewise. * libc/stdlib/atof.c: Likewise. * libc/stdlib/ldtoa.c: Fix comment typo. * libc/stdlib/div.c: Use @ifnottex instead of @ifinfo. * libc/stdlib/ldiv.c: Likewise. * libm/common/s_expm1.c: Likewise. * libm/common/s_ilogb.c: Hyphenate "floating-point". Use "nonzero". * libm/common/s_infinity: Hyphenate "double- and single-precision". * libm/common/s_nan.c: Likewise. Also correct the FUNCTION summary. * libm/common/s_nextafter.c: Fix typo. Hyphenate "double-precision" and "floating-point". * libm/common/s_scalbn.c: Correct the FUNCTION summary. * libm/math/e_pow.c: Fix comment typo. * libm/math/math.tex: Hyphenate "single-precision" and "floating-point". * libm/math/s_asinh.c: Use @ifnottex instead of @ifinfo. * libm/math/s_atan.c: Likewise. * libm/math/s_frexp.c: Likewise. Also use "nonzero". * libm/math/s_isnan.c: Hyphenate "single-precision" and "floating-point". Use "nonzero". * libm/math/s_ldexp.c: Use @ifnottex instead of @ifinfo. * libm/math/w_acos.c: Likewise. * libm/math/w_acosh.c: Likewise. * libm/math/w_asin.c: Likewise. * libm/math/w_atan2.c: Likewise. * libm/math/w_atanh.c: Likewise. * libm/math/w_cosh.c: Likewise. * libm/math/w_exp.c: Likewise. * libm/math/w_exp2.c: Likewise. Add missing @end and missing @tex version of 2^x in the description. * libm/math/w_fmod.c: Use @ifnottex instead of @ifinfo. * libm/math/w_gamma.c: Likewise. * libm/math/w_hypot.c: Likewise. * libm/math/w_j0.c: Likewise. * libm/math/w_sinh.c: Likewise. * libm/math/w_pow.c: Replace "exp1.0nt" with "exponent". * libm/mathfp/mathfp.tex: Hyphenate "single-precision" and "floating-point". * libm/mathfp/e_acosh.c: Use @ifnottex instead of @ifinfo. * libm/mathfp/e_atanh.c: Likewise. * libm/mathfp/e_hypot.c: Likewise. * libm/mathfp/er_lgamma.c: Likewise. * libm/mathfp/s_acos.c: Likewise. * libm/mathfp/s_asine.c: Likewise. * libm/mathfp/s_asinh.c: Likewise. * libm/mathfp/s_atan.c: Likewise. * libm/mathfp/s_atan2.c: Likewise. * libm/mathfp/s_atangent.c: Likewise. * libm/mathfp/s_cosh.c: Likewise. * libm/mathfp/s_exp.c: Likewise. * libm/mathfp/s_fmod.c: Likewise. * libm/mathfp/s_frexp.c: Likewise. Also use "nonzero". * libm/mathfp/s_isnan.c: Hyphenate "single-precision" and "floating-point". Use "nonzero". * libm/math/s_pow.c: Replace "exp1.0nt" with "exponent". * libm/mathfp/s_ldexp.c: Use @ifnottex instead of @ifinfo. * libm/mathfp/s_sineh.c: Likewise. * libm/mathfp/w_jn.c: Likewise.
2003-10-21 02:46:38 +08:00
the maximum single-precision floating-point value, rather than infinity.
2000-02-18 03:39:52 +08:00
Also, @code{errno} is set correctly, @code{matherr} is called, and, if
@code{matherr} returns 0, warning messages are printed for some errors.
For example, by default @samp{log(-1.0)} writes this message on standard
error output:
@example
log: DOMAIN error
@end example
The library is set to X/Open mode by default.
@page
@include mathfp/sacos.def
@page
@include mathfp/eacosh.def
@page
@include mathfp/sasine.def
@page
@include mathfp/sasinh.def
@page
@include mathfp/satan.def
@page
@include mathfp/satan2.def
@page
@include mathfp/eatanh.def
@page
@include mathfp/wjn.def
@page
@include common/scbrt.def
@page
@include common/scopysign.def
2000-02-18 03:39:52 +08:00
@page
@include mathfp/scosh.def
@page
@include mathfp/serf.def
@page
@include mathfp/sexp.def
@page
@include common/sexpm1.def
2000-02-18 03:39:52 +08:00
@page
@include mathfp/sfabs.def
@page
@include mathfp/sfloor.def
@page
@include mathfp/sfmod.def
@page
@include mathfp/sfrexp.def
@page
@include mathfp/erlgamma.def
@page
@include mathfp/ehypot.def
@page
@include common/silogb.def
@page
@include common/sinfinity.def
2000-02-18 03:39:52 +08:00
@page
@include common/sisnan.def
2000-02-18 03:39:52 +08:00
@page
@include mathfp/sldexp.def
@page
@include mathfp/slogarithm.def
@page
@include mathfp/slog10.def
@page
@include common/slog1p.def
@page
@include common/smatherr.def
@page
@include common/smodf.def
@page
@include common/snan.def
@page
@include common/snextafter.def
2000-02-18 03:39:52 +08:00
@page
@include mathfp/spow.def
@page
@include mathfp/eremainder.def
@page
@include common/sscalbn.def
2000-02-18 03:39:52 +08:00
@page
@include mathfp/ssqrt.def
@page
@include mathfp/ssine.def
@page
@include mathfp/ssineh.def
@page
@include mathfp/stan.def
@page
@include mathfp/stanh.def