Reference log()

log()

Calculates the natural logarithm (the base-e logarithm) of a number.

log() expects the n parameter to be a value greater than 0 because the natural logarithm is defined that way.

log() can also be used in shaders with p5.strands. The following example uses log() to create a decelerating color transition on a shape.

Examples

Syntax

log(n)

Parameters

n
Number: number greater than 0.

Returns

Number: natural logarithm of n.

Related References