# MySQL LN() function

## LN() function

MySQL LN() returns the natural logarithm of a number that is the base e logarithm of the number. The return value will be NULL when the value of the number is less than or equal to 0.

The EXP() is the inverse of this LN().

This function is useful in -

• In finance, the LN() function is used to calculate continuous compound interest, which is interest compounded continuously, as opposed to at discrete intervals.
• In probability theory and statistics, the natural logarithm is used in various distributions (e.g., normal distribution, log-normal distribution) and likelihood functions.
• The LN() function is used to solve equations where an unknown exponent is in the form of an exponent of 'e'.
• The natural logarithm is essential in solving equations and performing complex calculations involving the mathematical constant 'e'.
• This constant appears in various areas of mathematics, particularly in calculus and differential equations.
• In economics, the natural logarithm is often used to transform variables into a form where percentage changes represent constant growth rates.

Syntax:

```LN (N);
```

Where N is a number.

Syntax Diagram:

MySQL Version: 8.0

Pictorial presentation of MySQL IN() function

Example of MySQL IN() function

Code:

``````SELECT LN(3);
```
```

Explanation

The above MySQL statement returns the natural logarithm of 3.

Output:

```mysql> SELECT LN(3);
+------------------+
| LN(3)            |
+------------------+
| 1.09861228866811 |
+------------------+
1 row in set (0.00 sec)
```

Example : LN() function with negative value

Code:

``````SELECT LN(-3);
```
```

Explanation:

The above MySQL statement returns NULL because the value specified in the argument is less than 0.

Output:

```mysql> SELECT LN(-3);
+--------+
| LN(-3) |
+--------+
|   NULL |
+--------+
1 row in set (0.00 sec)
```

All Mathematical Functions

Previous: FLOOR()
Next: LOG()

﻿