LN
Syntax
LN(X)
Description
Returns the natural logarithm of X, which is the logarithm of X to the base e. If X is less than or equal to 0, it returns NULL and generates a warning Invalid argument for logarithm.
This function is equivalent to LOG(X).
Examples
SELECT LN(-10), LN(0), LN(10), LN(-3.14), LN(3.14);
+---------+-------+-------------------+-----------+-------------------+
| LN(-10) | LN(0) | LN(10) | LN(-3.14) | LN(3.14) |
+---------+-------+-------------------+-----------+-------------------+
| NULL | NULL | 2.302585092994046 | NULL | 1.144222799920162 |
+---------+-------+-------------------+-----------+-------------------+
1 row in set, 3 warnings (0.001 sec)
SHOW WARNINGS;
+---------+------+--------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------+
| Warning | 3020 | Invalid argument for logarithm |
| Warning | 3020 | Invalid argument for logarithm |
| Warning | 3020 | Invalid argument for logarithm |
+---------+------+--------------------------------+
3 rows in set (0.005 sec)