MariaDB LN() Function

In MariaDB, LN() is a built-in function that returns the natural logarithm of a given value.

The natural logarithm is the logarithm based on Euler’s number e, and e is approximately equal to 2.71828. Please refer to EXP() and LOG().

MariaDB LN() Syntax

Here is the syntax of the MariaDB LN() function:

LN(number)

LN(number) is equivalent to LOG(number).

Parameters

number

Required. A number used to calculate the natural logarithm. The value must be greater than 0.

If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'LN'.

Return value

The MariaDB LN() function returns the natural logarithm of the specified number.

If the parameter number is less than or equal to 0, the LN() function will return NULL.

If the parameter number is NULL, the LN() function will return NULL.

MariaDB LN() Examples

This statement shows the basic usage of the MariaDB LN() function:

SELECT
    LN(1),
    LN(2),
    LN(0),
    LN(-1),
    LN(NULL)\G

Output:

   LN(1): 0
   LN(2): 0.6931471805599453
   LN(0): NULL
  LN(-1): NULL
LN(NULL): NULL

Conclusion

In MariaDB, LN() is a built-in function that returns the natural logarithm of a given value.