# `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](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
log(base: number, number: number): number
```

```dataprime
(base: number).log(number: number): number
```

## Arguments

| Name   | Type   | Required | Description                                    |
| ------ | ------ | -------- | ---------------------------------------------- |
| base   | number | **true** | The logarithmic base (e.g. `2` for log base 2) |
| number | number | **true** | The value whose logarithm will be computed     |

## Example

**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.

### Example data

```json
{
    "some_value": 16
}
```

### Example query

```dataprime
create log_field from log(2, some_value)
```

```dataprime
create log_field from 2.log(some_value)
```

### Example output

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