GNU Info

Info Node: (libc.info)Exponents and Logarithms

(libc.info)Exponents and Logarithms


Next: Hyperbolic Functions Prev: Inverse Trig Functions Up: Mathematics
Enter node , (file) or (file)node

Exponentiation and Logarithms
=============================

 - Function: double exp (double X)
 - Function: float expf (float X)
 - Function: long double expl (long double X)
     These functions compute `e' (the base of natural logarithms) raised
     to the power X.

     If the magnitude of the result is too large to be representable,
     `exp' signals overflow.

 - Function: double exp2 (double X)
 - Function: float exp2f (float X)
 - Function: long double exp2l (long double X)
     These functions compute `2' raised to the power X.
     Mathematically, `exp2 (x)' is the same as `exp (x * log (2))'.

 - Function: double exp10 (double X)
 - Function: float exp10f (float X)
 - Function: long double exp10l (long double X)
 - Function: double pow10 (double X)
 - Function: float pow10f (float X)
 - Function: long double pow10l (long double X)
     These functions compute `10' raised to the power X.
     Mathematically, `exp10 (x)' is the same as `exp (x * log (10))'.

     These functions are GNU extensions.  The name `exp10' is
     preferred, since it is analogous to `exp' and `exp2'.

 - Function: double log (double X)
 - Function: float logf (float X)
 - Function: long double logl (long double X)
     These functions compute the natural logarithm of X.  `exp (log
     (X))' equals X, exactly in mathematics and approximately in C.

     If X is negative, `log' signals a domain error.  If X is zero, it
     returns negative infinity; if X is too close to zero, it may
     signal overflow.

 - Function: double log10 (double X)
 - Function: float log10f (float X)
 - Function: long double log10l (long double X)
     These functions return the base-10 logarithm of X.  `log10 (X)'
     equals `log (X) / log (10)'.


 - Function: double log2 (double X)
 - Function: float log2f (float X)
 - Function: long double log2l (long double X)
     These functions return the base-2 logarithm of X.  `log2 (X)'
     equals `log (X) / log (2)'.

 - Function: double logb (double X)
 - Function: float logbf (float X)
 - Function: long double logbl (long double X)
     These functions extract the exponent of X and return it as a
     floating-point value.  If `FLT_RADIX' is two, `logb' is equal to
     `floor (log2 (x))', except it's probably faster.

     If X is de-normalized, `logb' returns the exponent X would have if
     it were normalized.  If X is infinity (positive or negative),
     `logb' returns oo.  If X is zero, `logb' returns oo.  It does not
     signal.

 - Function: int ilogb (double X)
 - Function: int ilogbf (float X)
 - Function: int ilogbl (long double X)
     These functions are equivalent to the corresponding `logb'
     functions except that they return signed integer values.

Since integers cannot represent infinity and NaN, `ilogb' instead
returns an integer that can't be the exponent of a normal floating-point
number.  `math.h' defines constants so you can check for this.

 - Macro: int FP_ILOGB0
     `ilogb' returns this value if its argument is `0'.  The numeric
     value is either `INT_MIN' or `-INT_MAX'.

     This macro is defined in ISO C99.

 - Macro: int FP_ILOGBNAN
     `ilogb' returns this value if its argument is `NaN'.  The numeric
     value is either `INT_MIN' or `INT_MAX'.

     This macro is defined in ISO C99.

   These values are system specific.  They might even be the same.  The
proper way to test the result of `ilogb' is as follows:

     i = ilogb (f);
     if (i == FP_ILOGB0 || i == FP_ILOGBNAN)
       {
         if (isnan (f))
           {
             /* Handle NaN.  */
           }
         else if (f  == 0.0)
           {
             /* Handle 0.0.  */
           }
         else
           {
             /* Some other value with large exponent,
                perhaps +Inf.  */
           }
       }

 - Function: double pow (double BASE, double POWER)
 - Function: float powf (float BASE, float POWER)
 - Function: long double powl (long double BASE, long double POWER)
     These are general exponentiation functions, returning BASE raised
     to POWER.

     Mathematically, `pow' would return a complex number when BASE is
     negative and POWER is not an integral value.  `pow' can't do that,
     so instead it signals a domain error. `pow' may also underflow or
     overflow the destination type.

 - Function: double sqrt (double X)
 - Function: float sqrtf (float X)
 - Function: long double sqrtl (long double X)
     These functions return the nonnegative square root of X.

     If X is negative, `sqrt' signals a domain error.  Mathematically,
     it should return a complex number.

 - Function: double cbrt (double X)
 - Function: float cbrtf (float X)
 - Function: long double cbrtl (long double X)
     These functions return the cube root of X.  They cannot fail;
     every representable real value has a representable real cube root.

 - Function: double hypot (double X, double Y)
 - Function: float hypotf (float X, float Y)
 - Function: long double hypotl (long double X, long double Y)
     These functions return `sqrt (X*X + Y*Y)'.  This is the length of
     the hypotenuse of a right triangle with sides of length X and Y,
     or the distance of the point (X, Y) from the origin.  Using this
     function instead of the direct formula is wise, since the error is
     much smaller.  See also the function `cabs' in Note: Absolute
     Value.

 - Function: double expm1 (double X)
 - Function: float expm1f (float X)
 - Function: long double expm1l (long double X)
     These functions return a value equivalent to `exp (X) - 1'.  They
     are computed in a way that is accurate even if X is near zero--a
     case where `exp (X) - 1' would be inaccurate owing to subtraction
     of two numbers that are nearly equal.

 - Function: double log1p (double X)
 - Function: float log1pf (float X)
 - Function: long double log1pl (long double X)
     These functions returns a value equivalent to `log (1 + X)'.  They
     are computed in a way that is accurate even if X is near zero.

   ISO C99 defines complex variants of some of the exponentiation and
logarithm functions.

 - Function: complex double cexp (complex double Z)
 - Function: complex float cexpf (complex float Z)
 - Function: complex long double cexpl (complex long double Z)
     These functions return `e' (the base of natural logarithms) raised
     to the power of Z.  Mathematically, this corresponds to the value

     exp (z) = exp (creal (z)) * (cos (cimag (z)) + I * sin (cimag (z)))

 - Function: complex double clog (complex double Z)
 - Function: complex float clogf (complex float Z)
 - Function: complex long double clogl (complex long double Z)
     These functions return the natural logarithm of Z.
     Mathematically, this corresponds to the value

     log (z) = log (cabs (z)) + I * carg (z)

     `clog' has a pole at 0, and will signal overflow if Z equals or is
     very close to 0.  It is well-defined for all other values of Z.

 - Function: complex double clog10 (complex double Z)
 - Function: complex float clog10f (complex float Z)
 - Function: complex long double clog10l (complex long double Z)
     These functions return the base 10 logarithm of the complex value
     Z. Mathematically, this corresponds to the value

     log (z) = log10 (cabs (z)) + I * carg (z)

     These functions are GNU extensions.

 - Function: complex double csqrt (complex double Z)
 - Function: complex float csqrtf (complex float Z)
 - Function: complex long double csqrtl (complex long double Z)
     These functions return the complex square root of the argument Z.
     Unlike the real-valued functions, they are defined for all values
     of Z.

 - Function: complex double cpow (complex double BASE, complex double
          POWER)
 - Function: complex float cpowf (complex float BASE, complex float
          POWER)
 - Function: complex long double cpowl (complex long double BASE,
          complex long double POWER)
     These functions return BASE raised to the power of POWER.  This is
     equivalent to `cexp (y * clog (x))'


automatically generated by info2www version 1.2.2.9