log1p

log1p(x)

log1p(x, base)

Try it yourself:

See also:

log1p(): Accurate log(1 + x)

log1p() calculates log(1+x) with improved accuracy when x is close to zero. Directly adding a tiny x to 1 can lose significant digits in floating-point arithmetic, making log1p preferable in numerical and statistical formulas.

Domain and use

For real arithmetic, x must be greater than −1. log1p(0) is zero. It is useful for small percentage changes, probability formulas, and stable transformations. Its natural companion is expm1(), which accurately calculates exp(x)−1.

Use log() for ordinary values where the expression is not specifically 1+x. For very small inputs, retain full precision and avoid rounding until output with format().

Try Log1p in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions