Skip to content

log - Compute logarithm to any base

Logarithms are used for everything, from modelling compound interest, exponential growth, and decay, to finding the pH level of substance, to knowing the magnitude of an earthquake. DataPrime supports logarithms using the log function.

This function returns the logarithm of a given number, to a given base.

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 log base to use, for example 2 will compute log to base 2
numbernumbertrueThe value whose logarithm we wish to find

Example - Basic usage

The log command is simple and intuitive to use:

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

This command will create a new field, log_field which is equal to the log to base 2 of some_value.

Note

some_value MUST be a numerical type.