sech
Use the sech() function to calculate the hyperbolic secant of a numeric value. The hyperbolic secant is the reciprocal of the hyperbolic cosine function.
Syntax
sech(<number>)Parameters
number
integer, float
Yes
The numeric value for which to calculate the hyperbolic secant. Any real number is valid.
Returns
Type: float
Description: The sech() function returns the hyperbolic secant of the input value, which is equivalent to 1 / cosh(x). The result is always in the range (0, 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
sech()function accepts any real number as input.Null Handling: If the input expression is
null, the function returnsnull.Symmetry: The function is even, meaning
sech(-x) = sech(x).Maximum Value:
sech(0)returns1.0, which is the maximum value of the function.Asymptotic Behavior: As
xapproaches positive or negative infinity,sech(x)approaches0.Result Range: The output is always > 0 and ≤ 1.
Common Use Cases: This function is typically used within the
alterstage for mathematical modeling, signal processing, and scientific computations.
Examples
Example 1: Calculate hyperbolic secant of literal values
Goal: Calculate the hyperbolic secant for specific numeric literals to verify known mathematical results.
XQL code:
Explanation: sech(0) returns 1.0 (the maximum value). sech(1) and sech(-1) both return approximately 0.6481, demonstrating the even symmetry of the function.
Output:
1.0
0.64805
0.64805
Example 2: Calculate hyperbolic secant from a field value
Goal: Calculate the hyperbolic secant of values stored in a dataset field.
XQL code:
Explanation: This query computes the hyperbolic secant for each value in the duration_seconds field. No filtering is needed since sech() accepts any real number.
Output:
101
0.0
1.0
102
1.0
0.64805
103
3.0
0.09933
Example 3: Verify sech as reciprocal of cosh
Goal: Demonstrate that sech(x) equals 1 / cosh(x) by computing both and comparing.
XQL code:
Explanation: This query computes both sech(numeric_value) and 1 / cosh(numeric_value) to verify they produce the same result, confirming the mathematical identity sech(x) = 1 / cosh(x).
Output:
101
0.0
1.0
1.0
102
1.0
0.64805
0.64805
103
2.0
0.26580
0.26580
Related articles
Last updated
Was this helpful?
