beetlebug▾
/

tcl::mathfunc log1pTcl 9.1 only

Gives the natural logarithm of 1 plus a number.

tcl::mathfunc::log1p NUMBER
expr {log1p(NUMBER)}

Description

Gives log(1 + NUMBER). For a NUMBER near zero it keeps the digits that the sum loses. log1p(-1) is -Inf, and a number below -1 is a domain error.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredA number, -1 or more.

Returns

A float.

Examples

% expr {log1p(1e-10)}
9.999999999500001e-11

% expr {log1p(1)}
0.6931471805599453

% expr {log1p(-1)}
-Inf

Errors

% expr {log1p(-2)}
domain error: argument not in valid range
-errorcode ARITH DOMAIN {domain error: argument not in valid range}

% expr {log1p("x")}
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER

Facts

Capability
None.
Tcl release
Tcl 9.1 only.
Since
ztcl 1.0.0-beta.1

See also