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

# asin

Use the `asin()` function to calculate the principal value of the inverse sine (arcsine) of a numerical expression.

## Syntax

```sql
asin(<numeric_expression>)
```

## Parameters

| Name                 | Type           | Required | Description                                                                                                        |
| -------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------ |
| `numeric_expression` | integer, float | Yes      | The numerical value for which to calculate the arcsine. The value must be within the range of -1 to 1 (inclusive). |

## Returns

**Type**: float

**Description**: The `asin()` function returns the principal value of the arcsine 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 input `numeric_expression` must fall within the closed interval \[-1, 1].
* **Out of Range Behavior**: If the input is outside the range of -1 to 1, the function returns `NaN` (Not a Number) or `null`.
* **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()`.
* **Common Use Cases**: This function is typically used within the `alter` stage for geometric calculations, spatial analysis, or normalizing data vectors.

## Examples

### Example 1: Calculate arcsine of literal values

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

**XQL code**:

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

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

**Output**:

| RESULT1 | RESULT2 | RESULT3 |
| ------- | ------- | ------- |
| 0.0     | 1.5708  | -1.5708 |

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

**Goal**: Calculate the arcsine of values stored in a specific field, ensuring they are within the valid mathematical range.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| filter duration_seconds >= -1 and duration_seconds <= 1
| alter arc_sin_val = asin(duration_seconds)
| fields event_id, duration_seconds, arc_sin_val
| limit 3
```

**Explanation**: This query first filters the dataset to ensure `duration_seconds` contains only values between -1 and 1, then computes the arcsine for each and stores it in `arc_sin_val`.

**Output**:

| EVENT\_ID | DURATION\_SECONDS | ARC\_SIN\_VAL |
| --------- | ----------------- | ------------- |
| 101       | 0.5               | 0.5236        |
| 102       | -0.3              | -0.3047       |
| 103       | 1.0               | 1.5708        |

## Related articles

* **Stages**: [`alter`](/xql-command-reference-guide/readme/stages/alter.md), [`filter`](/xql-command-reference-guide/readme/stages/filter.md), [`fields`](/xql-command-reference-guide/readme/stages/fields.md), [`limit`](/xql-command-reference-guide/readme/stages/limit.md)
* **Functions**: [`sin()`](/xql-command-reference-guide/readme/functions/sin.md), [`acos()`](/xql-command-reference-guide/readme/functions/acos.md), `atan()`
* **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/asin.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.
