cosh
Use the cosh() function to calculate the hyperbolic cosine of a numeric value.
Syntax
cosh(<number>)Parameters
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 returnsnull.Symmetry: The function is even, meaning
cosh(-x) = cosh(x).Identity Value:
cosh(0)always returns1.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
alterstage 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:
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:
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:
101
1.0
1.54308
1.0
102
2.0
3.76220
2.0
103
3.0
10.06766
3.0
Related articles
Last updated
Was this helpful?
