> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/cbrt.md).

# cbrt

Use the `cbrt()` function to calculate the cube root of a numeric value.

## Syntax

```sql
cbrt(<number>)
```

## Parameters

| Name     | Type           | Required | Description                                                                                                   |
| -------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------- |
| `number` | integer, float | Yes      | The numeric value for which to calculate the cube root. Any real number is valid, including negative numbers. |

## Returns

**Type**: float

**Description**: The `cbrt()` function returns the cube root of the input value. If the input is `null`, the function returns `null`.

## Usage notes

* **Input type**: XQL doesn't support NaN or infinite values as input and these value types also can not be returned.
* **Valid Input Range**: The `cbrt()` function accepts any real number, including negative numbers and zero.
* **Null Handling**: If the input expression is `null`, the function returns `null`.
* **Negative Numbers**: Unlike square root (`sqrt()`), the cube root of a negative number is a valid real number. For example, `cbrt(-8)` returns `-2.0`.
* **Identity Values**: `cbrt(0)` returns `0.0`, `cbrt(1)` returns `1.0`, and `cbrt(-1)` returns `-1.0`.
* **Common Use Cases**: This function is typically used within the `alter` stage for mathematical transformations, volume calculations, and data normalization.

## Examples

### Example 1: Calculate cube root of literal values

**Goal**: Calculate the cube root for specific numeric literals to verify known mathematical results.

**XQL code**:

```sql
dataset = xdr_data
| limit 1
| alter result1 = cbrt(8), result2 = cbrt(27), result3 = cbrt(-8)
| fields result1, result2, result3
```

**Explanation**: You use `cbrt()` on three different literal values. `cbrt(8)` returns `2.0`, `cbrt(27)` returns `3.0`, and `cbrt(-8)` returns `-2.0`, demonstrating that the function handles negative inputs correctly.

**Output**:

| RESULT1 | RESULT2 | RESULT3 |
| ------- | ------- | ------- |
| 2.0     | 3.0     | -2.0    |

### Example 2: Calculate cube root from a field value

**Goal**: Calculate the cube root of values stored in a dataset field.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter cube_root_val = cbrt(numeric_value)
| fields event_id, numeric_value, cube_root_val
| limit 3
```

**Explanation**: This query computes the cube root for each value in the `numeric_value` field using `cbrt()` in the `alter` stage and stores the result in `cube_root_val`. No filtering is needed since `cbrt()` accepts any real number.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | CUBE\_ROOT\_VAL |
| --------- | -------------- | --------------- |
| 101       | 125.0          | 5.0             |
| 102       | -27.0          | -3.0            |
| 103       | 1000.0         | 10.0            |

### Example 3: Combine cube root with other operations

**Goal**: Use the cube root function as part of a larger mathematical expression.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter volume = multiply(numeric_value, multiply(numeric_value, numeric_value))
| alter side_length = cbrt(volume)
| fields event_id, numeric_value, volume, side_length
| limit 3
```

**Explanation**: This query first cubes the `numeric_value` to simulate a volume, then applies `cbrt()` to recover the original side length. The result in `side_length` should match the original `numeric_value`, demonstrating that `cbrt()` is the inverse of cubing.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | VOLUME | SIDE\_LENGTH |
| --------- | -------------- | ------ | ------------ |
| 101       | 3.0            | 27.0   | 3.0          |
| 102       | 5.0            | 125.0  | 5.0          |
| 103       | 10.0           | 1000.0 | 10.0         |

## Related articles

* **Stages**: [`alter`](/xql-command-reference-guide/readme/stages/alter.md), [`fields`](/xql-command-reference-guide/readme/stages/fields.md), [`limit`](/xql-command-reference-guide/readme/stages/limit.md)
* **Functions**: [`sqrt()`](/xql-command-reference-guide/readme/functions/sqrt.md), [`pow()`](/xql-command-reference-guide/readme/functions/pow.md), [`multiply()`](/xql-command-reference-guide/readme/functions/multiply.md)
* **Datasets**: [`xdr_data`](https://docs-cortex.paloaltonetworks.com/r/Cortex-XQL-Schema-Reference-Guide/Introduction)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/cbrt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
