Mathematics - Logarithm Function (log)

Math Domain


<math>log_b(n)</math> is the number (#) of times you divide n by b until you get down to 1.

If you see log, you must think trees


With the base 2 where <math>log_2 n</math> 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

<MATH> \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} </MATH>


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

Log 2 N


<MATH> b^n = a </MATH>

  • The log is defined as:

<MATH> n = log_b(a) </MATH>

log x without an explicit base may also refer to the natural logarithm.


From multiplication to addition

Logarithms permit to replace multiplication by addition.

<MATH> log_b(x \times y) = log_b(x) + log_b(y) </MATH>

It was more comfortable to carry at a time the calculator does not exist.

Base modification

<MATH> log_b(a) = \frac{log_2(a)}{log_2(b)} = \frac{log_e(a)}{log_e(b)} = \dots = \frac{log_x(a)}{log_x(b)} </MATH>

Log base 2 approximation

<MATH> log_2(x) \approx log_e(x) + log_{10}(x) </MATH> where:

Computer Language

In most of the computer language:

  • the log function returns the natural logaritm
  • there is also precomputed value in order to help to change base thanks to the division law.

For instance, in javascript, Math.log(x) returns the natural logarithm and to get the log on base 10, you would use the LN10 constant (ie ln(10))

function log10(val) {
  return Math.log(val) / Math.LN10;

Documentation / Reference

Discover More
Thomas Bayes
Data Mining - Entropy (Information Gain)

The degree to which a system has no pattern is known as entropy. A high-entropy source is completely chaotic, is unpredictable, and is called true randomness. Entropy is a function “Information”...
Model Funny
Function - Binary Function/Operation

A binary operation is an scalar operation with two arguments (arity of two) that produces one value. They are creating a binary relation. the addition operator, the multiplication operator ...
Math Domain
Mathematics - Exponential (Euler's number)

is the scientific constant, the exponential. Euler's number The number e is an important mathematical constant that is the base of the natural logarithm. The number e can be defined to be: the unique...
Data System Architecture
Mathematics - Exponentiation (square, cube) - Power

Exponentiation is a binary operation involving two numbers: the base (b) the exponent (n) (or index or power). In text notation or computer language, generally the exponentiation operator...
Math Domain
Mathematics - Natural Logarithm

The natural logarithm is the logarithm function where the base has the value e Its value is the area under the graph of the hyperbola with equation y = 1/x between x = 1 and x = a. The number e can...
Data System Architecture
Number - (Arithmetical | Numerical | Mathematical) Operators

Number operators Addition (+) Addition in an compound assignment form += Subtraction (-) Division (/) Python: Multiplication () Truncating integer division (//) ...
Data System Architecture
Number - Root function

The root function is the inverse operation of the exponentiation. With the below exponentiation of the base b to the power of n the base b can be defined back with the root function as: nlogarithm...
Merge Sort
Ordinal Data - Merge sort Algorithm

John von Neumann invented merge sort in 1945. It requires O(n log n) comparisons. A sorting algorithm for rearranging lists (or any other data structure that can only be accessed sequentially, e.g. file...
Data System Architecture
Tree - (Recursion|Induction) Algorithm

A recursive algorithms invoke themselves as a subroutine with a smaller input. The idea of the recursion tree method is to write out all of the work done by the recursive algorithm in a tree structure,...

Share this page:
Follow us:
Task Runner