Return the mathematical constant e (Euler's number, approximately 2.71828).
E()
## Overview Returns the mathematical constant e (Euler's number) as a DOUBLE. E is a niladic function (it takes no arguments) and exposes the base of the natural logarithm directly in SQL. Use E() in continuous-compounding formulas, in Boltzmann-factor calculations, and anywhere the base of the natural logarithm is more explicit than EXP(1). The returned value is the closest DOUBLE to the mathematical e, which is approximately 2.718281828459045. ## Behavior - Takes no arguments. - Returns a DOUBLE with the closest representable value to e. - Deterministic: every call returns the same DOUBLE. - Equal to EXP(1) to within one ULP. ## Numeric precision - The returned DOUBLE is the correctly rounded approximation of e to double precision. - The relative error versus true e is less than 2^-53. - For extended-precision work, compute in DECIMAL or arbitrary-precision arithmetic. ## Compatibility - Conforms to the SQL standard niladic function E(). - Matches the IEEE 754 double-precision value of e used by typical mathematical libraries.
-- Return the value of e
SELECT E();
-- Result: 2.718281828459045
-- Verify: e^1 equals E()
SELECT EXP(1), E();
-- Result: 2.718281828459045, 2.718281828459045
-- Verify: LN(E()) equals 1
SELECT LN(E());
-- Result: 1.0
-- Continuous compounding formula
SELECT 1000 * POWER(E(), 0.05 * 10) AS future_value;
-- Result: 1648.7212707001282
-- Column use: Boltzmann-factor style weighting
SELECT state_id, POWER(E(), -energy / kT) AS weight
FROM physics.simulation.thermal_states;