ln: Logarithmic and exponential functions

View source: R/ln.R

lnR Documentation

Logarithmic and exponential functions

Description

ln() computes natural logarithm, lg() computes base 10 logarithm, and lb() computes binary (base 2) logarithm.

ln1p() and lg1p() computes ln(x + 1) and lg(x + 1) accurately also for ⁠|x| << 1⁠.

E is the Euler constant and is equal to exp(1).

Usage

ln(x)

lg(x)

lb(x)

ln1p(x)

lg1p(x)

E

Arguments

x

A numeric or complex vector.

Format

An object of class numeric of length 1.

Details

Those functions are synonyms of log(), log10(), log2(), log1p() for those who prefer the shorter notation. Beginners sometimes make confusion between log() and log10(). Using ln() for natural logarithms instead of log() eliminates this confusion. E is provided for convenience as exp(1), although the use of exp() is usually familiar enough to everyone.

See Also

log()

Examples

ln(exp(3))              # Same as log(exp(3))
lg(10^3)                # Same as log10(10^3)
lb(1:3)                 # Wrapper for log2()

ln1p(c(0, 1, 10, 100))  # Wrapper for log1p()
lg1p(c(0, 1, 10, 100))  # log10(x + 1), but optimized for x << 1

E^4                     # Similar to exp(4), but different calculation!

SciViews/SciViews documentation built on Sept. 16, 2023, 10:26 p.m.