log1pl Function

Calculates the natural logarithm of a long double precision floating-point value plus 1.

Include

<math.h>

Prototype

long double log1pl(long double x);

Argument

x
any positive value for which to return the log

Return Value

Returns the natural logarithm of x+1. The result of log1pl(x) is generally expected to be more accurate than that of logl(x+1) when the magnitude of x is small.

Remarks

A domain error occurs if x is less than 1. A range error might occur if the argument equals 1.

Example

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  double x, y;

  errno = 0;
  x = 2.0;
  y = log1pl(x);
  if(errno)
    perror("Error");
  printf("The result of log1pl(%f) is %f\n", x, y);

  errno = 0;
  x = 0.0;
  y = log1pl(x);
  if(errno)
    perror("Error");
  printf("The result of log1pl(%f) is %f\n", x, y);

  errno = 0;
  x = -2.0;
  y = log1pl(x);
  if(errno)
    perror("Error");
  printf("The result of log1pl(%f) is %f\n", x, y);
}

Example Output

The result of log1pl(2.000000) is 1.098612
The result of log1pl(0.000000) is 0.000000
Error: domain error
The result of log1pl(-2.000000) is nan