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

# cosh

Use the `cosh()` function to calculate the hyperbolic cosine of a numeric value.

## Syntax

```sql
cosh(<number>)
```

## Parameters

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

## Returns

**Type**: float

**Description**: The `cosh()` function returns the hyperbolic cosine of the input value. The result is always greater than or equal to 1. 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 `cosh()` function accepts any real number as input.
* **Null Handling**: If the input expression is `null`, the function returns `null`.
* **Symmetry**: The function is even, meaning `cosh(-x) = cosh(x)`.
* **Identity Value**: `cosh(0)` always returns `1.0`.
* **Result Range**: The output is always ≥ 1, since the hyperbolic cosine is defined as `(e^x + e^(-x)) / 2`.
* **Overflow**: For very large input values, the result may overflow to infinity.
* **Common Use Cases**: This function is typically used within the `alter` stage for mathematical modeling, catenary curve calculations, and scientific computations.

## Examples

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

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

**XQL code**:

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

**Explanation**: You use `cosh()` on three different literal values. `cosh(0)` returns `1.0`. `cosh(1)` and `cosh(-1)` both return approximately `1.5431`, demonstrating the even symmetry of the function.

**Output**:

| RESULT1 | RESULT2 | RESULT3 |
| ------- | ------- | ------- |
| 1.0     | 1.54308 | 1.54308 |

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

**Goal**: Calculate the hyperbolic cosine of values stored in a dataset field.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter cosh_result = cosh(duration_seconds)
| fields event_id, duration_seconds, cosh_result
| limit 3
```

**Explanation**: This query computes the hyperbolic cosine for each value in the `duration_seconds` field using `cosh()` in the `alter` stage. No filtering is needed since `cosh()` accepts any real number.

**Output**:

| EVENT\_ID | DURATION\_SECONDS | COSH\_RESULT |
| --------- | ----------------- | ------------ |
| 101       | 0.0               | 1.0          |
| 102       | 1.0               | 1.54308      |
| 103       | 2.0               | 3.76220      |

### Example 3: Verify relationship between cosh and acosh

**Goal**: Demonstrate that `acosh()` is the inverse of `cosh()` by applying both functions sequentially.

**XQL code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter cosh_val = cosh(duration_seconds)
| alter acosh_cosh_val = acosh(cosh_val)
| fields event_id, duration_seconds, cosh_val, acosh_cosh_val
| limit 3
```

**Explanation**: This query first computes `cosh()` of `duration_seconds`, then applies `acosh()` to the result. The final value `acosh_cosh_val` should equal the absolute value of the original `duration_seconds`, confirming the inverse relationship.

**Output**:

| EVENT\_ID | DURATION\_SECONDS | COSH\_VAL | ACOSH\_COSH\_VAL |
| --------- | ----------------- | --------- | ---------------- |
| 101       | 1.0               | 1.54308   | 1.0              |
| 102       | 2.0               | 3.76220   | 2.0              |
| 103       | 3.0               | 10.06766  | 3.0              |

## Related articles

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