log1+ ( x -- y ) (original) (raw)

log1+ ( x -- y )
Factor handbook » The language » Numbers » Mathematical functions » Powers and logarithms

Prev: log ( x -- y )
Next: log10 ( x -- y )

Vocabulary
math.functions

Inputs

x a number

Outputs

y a number

Word description
Takes the natural logarithm of 1 + x. Outputs negative infinity if 1 + x is zero. This word may be more accurate than 1 + log for very small values of x.

Definition

IN: math.functions

GENERIC: log1+ ( x -- y )

Methods

USING: kernel math math.functions math.libm ;

M: float log1+
dup -1.0 >= [ flog1+ ] [ 1.0 + 0.0 rect> log ] if ; inline

USING: kernel math math.functions ;

M: object log1+ 1 + log ; inline