1.\" Copyright (c) 1985 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" from: @(#)math.3 6.10 (Berkeley) 5/6/91 33.\" $FreeBSD$ 34.\" 35.Dd January 11, 2005 36.Dt MATH 3 37.Os 38.if n \{\ 39.char \[sr] "sqrt 40.\} 41.Sh NAME 42.Nm math 43.Nd "floating-point mathematical library" 44.Sh LIBRARY 45.Lb libm 46.Sh SYNOPSIS 47.In math.h 48.Sh DESCRIPTION 49These functions constitute the C math library. 50.Sh "LIST OF FUNCTIONS" 51Each of the following 52.Vt double 53functions has a 54.Vt float 55counterpart with an 56.Ql f 57appended to the name and a 58.Vt "long double" 59counterpart with an 60.Ql l 61appended. 62As an example, the 63.Vt float 64and 65.Vt "long double" 66counterparts of 67.Ft double 68.Fn acos "double x" 69are 70.Ft float 71.Fn acosf "float x" 72and 73.Ft "long double" 74.Fn acosl "long double x" , 75respectively. 76.de Cl 77. Bl -column "isgreaterequal" "bessel function of the second kind of the order 0" 78.Em "Name Description" 79.. 80.Ss Algebraic Functions 81.Cl 82cbrt cube root 83fma fused multiply-add 84hypot Euclidean distance 85sqrt square root 86.El 87.Ss Classification Functions 88.Cl 89fpclassify classify a floating-point value 90isfinite determine whether a value is finite 91isinf determine whether a value is infinite 92isnan determine whether a value is \*(Na 93isnormal determine whether a value is normalized 94.El 95.Ss Exponent Manipulation Functions 96.Cl 97frexp extract exponent and mantissa 98ilogb extract exponent 99ldexp multiply by power of 2 100scalbln adjust exponent 101scalbn adjust exponent 102.El 103.Ss Extremum- and Sign-Related Functions 104.Cl 105copysign copy sign bit 106fabs absolute value 107fdim positive difference 108fmax maximum function 109fmin minimum function 110signbit extract sign bit 111.El 112.\" .Ss Not a Number 113.\" .Cl 114.\" nan return quiet \*(Na) 0 115.\" .El 116.Ss Residue and Rounding Functions 117.Cl 118ceil integer no less than 119floor integer no greater than 120fmod positive remainder 121llrint round to integer in fixed-point format 122llround round to nearest integer in fixed-point format 123lrint round to integer in fixed-point format 124lround round to nearest integer in fixed-point format 125modf extract integer and fractional parts 126nearbyint round to integer (silent) 127nextafter next representable value 128.\" nexttoward next representable value (silent) 129remainder remainder 130.\" remquo remainder with partial quotient 131rint round to integer 132round round to nearest integer 133trunc integer no greater in magnitude than 134.El 135.Pp 136The 137.Fn ceil , 138.Fn floor , 139.Fn llround , 140.Fn lround , 141.Fn round , 142and 143.Fn trunc 144functions round in predetermined directions, whereas 145.Fn llrint , 146.Fn lrint , 147and 148.Fn rint 149round according to the current (dynamic) rounding mode. 150For more information on controlling the dynamic rounding mode, see 151.Xr fenv 3 152and 153.Xr fesetround 3 . 154.Ss Silent Order Predicates 155.Cl 156isgreater greater than relation 157isgreaterequal greater than or equal to relation 158isless less than relation 159islessequal less than or equal to relation 160islessgreater less than or greater than relation 161isunordered unordered relation 162.El 163.Ss Transcendental Functions 164.Cl 165acos inverse cosine 166acosh inverse hyperbolic cosine 167asin inverse sine 168asinh inverse hyperbolic sine 169atan inverse tangent 170atanh inverse hyperbolic tangent 171atan2 atan(y/x); complex argument 172cos cosine 173cosh hyperbolic cosine 174erf error function 175erfc complementary error function 176exp exponential base e 177.\" exp2 exponential base 2 178expm1 exp(x)\-1 179j0 Bessel function of the first kind of the order 0 180j1 Bessel function of the first kind of the order 1 181jn Bessel function of the first kind of the order n 182lgamma log gamma function 183log natural logarithm 184log10 logarithm to base 10 185log1p log(1+x) 186.\" log2 base 2 logarithm 187pow exponential x**y 188sin trigonometric function 189sinh hyperbolic function 190tan trigonometric function 191tanh hyperbolic function 192tgamma gamma function 193y0 Bessel function of the second kind of the order 0 194y1 Bessel function of the second kind of the order 1 195yn Bessel function of the second kind of the order n 196.El 197.Pp 198Unlike the algebraic functions listed earlier, the routines 199in this section may not produce a result that is correctly rounded. 200In general, an unbounded number of digits of a value taken by a 201transcendental function may be needed to determine the correctly rounded 202result. 203.Sh SEE ALSO 204.Xr fenv 3 , 205.Xr ieee 3 206.Sh HISTORY 207A math library with many of the present functions appeared in 208.At v7 . 209The library was substantially rewritten for 210.Bx 4.3 211to provide 212better accuracy and speed on machines supporting either VAX 213or IEEE 754 floating-point. 214Most of this library was replaced with FDLIBM, developed at Sun 215Microsystems, in 216.Fx 1.1.5 . 217Additional routines, including ones for 218.Vt float 219and 220.Vt long double 221values, were written for or imported into subsequent versions of FreeBSD. 222.Sh BUGS 223Several functions required by 224.St -isoC-99 225are missing, and many functions are not available in their 226.Vt "long double" 227variants. 228.Pp 229On some architectures, trigonometric argument reduction is not 230performed accurately, resulting in errors greater than 1 231.Em ulp 232for large arguments to 233.Fn cos , 234.Fn sin , 235and 236.Fn tan . 237