exp
Use the exp() function to calculate the value of Euler's number e raised to the power of a numeric value.
Syntax
exp(<number>)Parameters
number
integer, float
Yes
The exponent to which e (approximately 2.71828) is raised. Any real number is valid.
Returns
Type: float
Description: The exp() function returns e raised to the power of the input value (e^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
exp()function accepts any real number as input.Null Handling: If the input expression is
null, the function returnsnull.Identity Value:
exp(0)always returns1.0, sincee^0 = 1.Inverse Relationship: The
exp()function is the inverse of the natural logarithmln(). That is,exp(ln(x)) = xforx > 0.Overflow: For very large positive input values, the result may overflow to infinity.
Underflow: For very large negative input values, the result approaches
0.0.Common Use Cases: This function is typically used within the
alterstage for exponential growth/decay modeling, probability calculations, and scientific computations.
Examples
Example 1: Calculate exponential of literal values
Goal: Calculate e raised to specific powers to verify known mathematical results.
XQL code:
Explanation: You use exp() on three different literal values. exp(0) returns 1.0, exp(1) returns approximately 2.71828 (the value of e), and exp(-1) returns approximately 0.36788 (1/e).
Output:
1.0
2.71828
0.36788
Example 2: Calculate exponential from a field value
Goal: Calculate the exponential of values stored in a dataset field.
XQL code:
Explanation: This query computes e raised to the power of each value in the duration_seconds field using exp() in the alter stage. No filtering is needed since exp() accepts any real number.
Output:
101
0.0
1.0
102
1.0
2.71828
103
2.0
7.38906
Example 3: Verify inverse relationship with ln
Goal: Demonstrate that exp() and ln() are inverse functions by applying both sequentially.
XQL code:
Explanation: This query first computes the natural logarithm of numeric_value, then applies exp() to the result. The final value exp_ln_val should match the original numeric_value, confirming the inverse relationship exp(ln(x)) = x.
Output:
101
5.0
1.60944
5.0
102
10.0
2.30259
10.0
103
100.0
4.60517
100.0
Related articles
Datasets:
xdr_data
Last updated
Was this helpful?
