log1p

Natural logarithm of one plus the argument.

Syntax

R = log1p(x)

Inputs

x
Type: double | complex
Dimension: scalar | vector | matrix

Outputs

R
The returned values.
Type: double | complex
Dimension: scalar | vector | matrix.

Example

Show that log1p(x + 1) has better accuracy than log(x) for small real values of x

.
x = 1e-18;
a = log(x+1)
a = 0
b = log1p(x)
b = 1e-18

The value of a has lost precision, but b has not.