# Mathematics - Logarithm Function (log)

logarithms permit to replace multiplication by addition. More comfortable to carry at a time the calculator does not exist.

If you see log, you must think trees

## 3 - $log_2 n$

$log_2 n$ is the # of times you divide n by 2 until you get down to 1.

You keep repeating dividing by two and you count how many times you divide by two until you get a number that drops below one

$$\begin{array}{rrl} log_2 (42) = 5.39 &&&\\ 1- & 42/2 & = & 21 \\ 2- & 21/2 & = & 10.5 \\ 3- & 10.5 / 2 & = & 5.25 \\ 4- & 5.25/2 & = & 2.625 \\ 5- & 2.625/2 & = & 1.3125 \\ 6- & 1.3125/2 & = & 0.65625 \\ \end{array}$$

The logarithm is much, much smaller than the input. log is running much, much, much slower than the identity function. $$\begin{array}{rrl} log_2 (10) & \approx & 3 \\ log_2 (100) & \approx & 7 \\ log_2 (1000) & \approx & 10 \\ \end{array}$$

## 4 - Documentation / Reference

log_2(x) is approximately log_e(x) + log_10(x)