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

# coth

Use the `coth()` function to calculate the hyperbolic cotangent of a numeric value. The hyperbolic cotangent is the reciprocal of the hyperbolic tangent function.

## Syntax

```sql
coth(<number>)
```

## Parameters

| Name     | Type           | Required | Description                                                                                    |
| -------- | -------------- | -------- | ---------------------------------------------------------------------------------------------- |
| `number` | integer, float | Yes      | The numeric value for which to calculate the hyperbolic cotangent. The value must not be zero. |

## Returns

**Type**: float

**Description**: The `coth()` function returns the hyperbolic cotangent of the input value, which is equivalent to `cosh(x) / sinh(x)` or `1 / tanh(x)`. 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 `coth()` function accepts any real number except zero, where the hyperbolic cotangent is undefined.
* **Undefined at Zero**: `coth(0)` is undefined and returns `infinity`, `NaN`, or `null`.
* **Null Handling**: If the input expression is `null`, the function returns `null`.
* **Asymptotic Behavior**: As `x` approaches positive infinity, `coth(x)` approaches `1.0`. As `x` approaches negative infinity, `coth(x)` approaches `-1.0`.
* **Symmetry**: The function is odd, meaning `coth(-x) = -coth(x)`.
* **Common Use Cases**: This function is typically used within the `alter` stage for mathematical modeling, heat transfer calculations, and scientific computations.

## Examples

### Example 1: Calculate hyperbolic cotangent of literal values

**Goal**: Calculate the hyperbolic cotangent for specific numeric literals to verify known mathematical results.

**XQL code**:

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

**Explanation**: You use `coth()` on three different literal values. `coth(1)` returns approximately `1.3130`, `coth(2)` returns approximately `1.0373`, and `coth(-1)` returns approximately `-1.3130`, demonstrating the odd symmetry of the function.

**Output**:

| RESULT1 | RESULT2 | RESULT3  |
| ------- | ------- | -------- |
| 1.31304 | 1.03731 | -1.31304 |

### Example 2: Calculate hyperbolic cotangent from a field value

**Goal**: Calculate the hyperbolic cotangent of values stored in a dataset field, filtering out zero values.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| filter numeric_value != 0
| alter coth_result = coth(numeric_value)
| fields event_id, numeric_value, coth_result
| limit 3
```

**Explanation**: This query filters out zero values (where hyperbolic cotangent is undefined), then computes the hyperbolic cotangent for each remaining value in the `numeric_value` field.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | COTH\_RESULT |
| --------- | -------------- | ------------ |
| 101       | 0.5            | 2.16396      |
| 102       | 1.0            | 1.31304      |
| 103       | 3.0            | 1.00497      |

### Example 3: Verify coth as reciprocal of tanh

**Goal**: Demonstrate that `coth(x)` equals `1 / tanh(x)` by computing both and comparing.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| filter numeric_value != 0
| alter coth_val = coth(numeric_value)
| alter reciprocal_tanh = divide(1, tanh(numeric_value))
| fields event_id, numeric_value, coth_val, reciprocal_tanh
| limit 3
```

**Explanation**: This query computes both `coth(numeric_value)` and `1 / tanh(numeric_value)` to verify they produce the same result, confirming the mathematical identity `coth(x) = 1 / tanh(x)`.

**Output**:

| EVENT\_ID | NUMERIC\_VALUE | COTH\_VAL | RECIPROCAL\_TANH |
| --------- | -------------- | --------- | ---------------- |
| 101       | 0.5            | 2.16396   | 2.16396          |
| 102       | 1.0            | 1.31304   | 1.31304          |
| 103       | 3.0            | 1.00497   | 1.00497          |

## 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**: [`tanh`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/tanh.md), [`cosh`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/cosh.md), [`sinh`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/sinh.md), [`cot`](https://cortex-docs.paloaltonetworks.com/xql-command-reference-guide/readme/functions/cot.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/coth.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.
