Function Reference

LN

MySQL equivalent:

Returns the natural logarithm of a number, that is to base e.

PostgreSQL 17.5
LN(num)

Parameters

numnumeric | double precision
Positive number

Return value

A number of the same type as num (double precision or numeric); an error for 0 and negative numbers

Examples

Logarithm of e and 10

PostgreSQL 17.5
SELECT LN(EXP(1)) AS ln_e,
	LN(10) AS ln_10;
ln_eln_10
12.302585092994046

Years to double a deposit at 7%

PostgreSQL 17.5
SELECT ROUND((LN(2) / LN(1.07))::numeric, 1) AS years_to_double;
years_to_double
10.2

Details

The reverse function is EXP. A logarithm to another base is computed by LOG(base, num), the base-10 one by LOG10. In MySQL the natural logarithm is also returned by LOG with one argument.

See also