> 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/atan.md).

# atan

Use the `atan()` function to calculate the principal value of the inverse tangent (arctangent) of a numerical expression.

## Syntax

```sql
atan(<numeric_expression>)
```

## Parameters

| Name                 | Type           | Required | Description                                                                          |
| -------------------- | -------------- | -------- | ------------------------------------------------------------------------------------ |
| `numeric_expression` | integer, float | Yes      | The numerical value for which to calculate the arctangent. Any real number is valid. |

## Returns

**Type**: float

**Description**: The `atan()` function returns the principal value of the arctangent of the input in radians. The resulting value is within the range (-π/2, π/2).

## 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 `atan()` function accepts any real number as input.
* **Null Handling**: If the input expression is `null`, the function returns `null`.
* **Radians to Degrees**: The result is provided in radians. To convert the result to degrees, multiply the return value by `180 / PI()`.
* **Symmetry**: The function is odd, meaning `atan(-x) = -atan(x)`.
* **Common Use Cases**: This function is typically used within the `alter` stage for geometric calculations, angle computations, and spatial analysis. For computing the angle from Cartesian coordinates, use `atan2()` instead.

## Examples

### Example 1: Calculate arctangent of literal values

**Goal**: Calculate the inverse tangent for specific numerical literals to see the radian results.

**XQL code**:

```sql
dataset = xdr_data
| limit 1
| alter result1 = atan(0), result2 = atan(1), result3 = atan(-1)
| fields result1, result2, result3
```

**Explanation**: You use `atan()` on three different literal values. `atan(0)` returns `0.0`, `atan(1)` returns approximately `0.7854` (π/4), and `atan(-1)` returns approximately `-0.7854` (-π/4).

**Output**:

| RESULT1 | RESULT2 | RESULT3 |
| ------- | ------- | ------- |
| 0.0     | 0.7854  | -0.7854 |

### Example 2: Calculate arctangent from a field value

**Goal**: Calculate the arctangent of values stored in a specific field.

**XQL code**:

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

**Explanation**: This query computes the arctangent for each value in the `numeric_value` field and stores it in `arc_tan_val`. Since `atan()` accepts any real number, no filtering is needed.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | ARC\_TAN\_VAL |
| --------- | -------------- | ------------- |
| 101       | 0.5            | 0.4636        |
| 102       | -2.0           | -1.1071       |
| 103       | 100.0          | 1.5608        |

### Example 3: Convert arctangent result to degrees

**Goal**: Calculate the arctangent and convert the result from radians to degrees.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter atan_radians = atan(numeric_value)
| alter atan_degrees = multiply(atan_radians, divide(180, pi()))
| fields event_id, numeric_value, atan_radians, atan_degrees
| limit 3
```

**Explanation**: This query first calculates the arctangent in radians, then converts it to degrees by multiplying by `180 / π`. For example, `atan(1)` in radians is approximately `0.7854`, which converts to `45.0` degrees.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | ATAN\_RADIANS | ATAN\_DEGREES |
| --------- | -------------- | ------------- | ------------- |
| 101       | 1.0            | 0.7854        | 45.0          |
| 102       | -1.0           | -0.7854       | -45.0         |
| 103       | 0.0            | 0.0           | 0.0           |

## Related articles

* **Stages**: [`alter`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/stages/alter.md), [`filter`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/stages/filter.md), [`fields`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/stages/fields.md), [`limit`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/stages/limit.md)
* **Functions**: [`tan`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/tan.md), [`atan2`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/atan2.md), [`asin`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/asin.md), [`acos`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/acos.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
