log -- Compute the Natural Logarithm

SYNOPSIS

 #include <math.h>

 double log(double x);
 

DESCRIPTION

log computes the natural log of its argument x. The x argument must be a positive double-precision, floating-point number. The natural log is the inverse of the exponential function.

RETURN VALUE

log returns the natural log of its argument x, expressed as a double-precision, floating-point number.

DIAGNOSTICS

The run-time library writes an error message to the standard error file (stderr) if x is a negative number or 0. In this case, the function returns -HUGE_VAL, the largest negative floating-point number that can be represented.

If an error occurs in log, the _matherr routine is called. You supply your own version of _matherr to suppress the diagnostic message or modify the value returned.

EXAMPLE

This example computes the natural log of 10, using log:
  #include <math.h>
  #include <stdio.h>

  main()
  {
     double y, val;
     val = 10.0;
     y = log(val);
     printf("log(%f) = %fn", val, y);
  }

 

RELATED FUNCTIONS

log10, _matherr

SEE ALSO

Mathematical Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.