For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

cosh

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

Syntax

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:

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:

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:

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

Last updated

Was this helpful?