Skip to content

log

Description

Returns the logarithm of a number to a specified base. Common uses include modeling compound interest, exponential growth or decay, pH levels, and earthquake magnitudes.

Syntax

Like many functions in DataPrime, log supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

log(base: number, number: number): number
(base: number).log(number: number): number

Arguments

NameTypeRequiredDescription
basenumbertrueThe logarithmic base (e.g. 2 for log base 2)
numbernumbertrueThe value whose logarithm will be computed

Example

Description

Use case: Compute a log base 2 transformation

Calculate the log base 2 of a numerical field and store the result in a new field.

{
    "some_value": 16
}

Example query

create log_field from log(2, some_value)
create log_field from 2.log(some_value)

Example output

{
    "some_value": 16,
    "log_field": 4
}