y=log2x Graph of the Binary Logarithm y=log2x
y=log2x is the logarithm with base 2: it gives the power to which 2 must be raised to obtain x. For example 23=8, so log28=3. It is the inverse of the exponential y=2x.
Domain and range
The argument x must be positive, so the domain is x>0 and the range is all real numbers. Since the base exceeds 1 the function increases monotonically, and it is negative for 0<x<1.
Doubling adds one
| x | log2x |
|---|
| 21 | −1 |
| 1 | 0 |
| 2 | 1 |
| 4 | 2 |
| 8 | 3 |
Each time x doubles, the value gains exactly 1.
Monotonicity and asymptote
As x→0+ the function diverges to −∞, so the y-axis, the line x=0, is a vertical asymptote. As x→+∞ it keeps rising slowly to +∞. The derivative is as follows.
y′=xln21 It is always positive, and the second derivative is negative, so the graph is concave down. At (1,0) the tangent has slope y′(1)=ln21≈1.4427.
Symmetry with the exponential
The graph is symmetric to that of 2x in the line y=x: where 2x shoots upward, log2x only creeps.
Change of base
By the change-of-base formula it is a constant multiple of the natural logarithm.
log2x=ln2lnx≈1.4427lnx It therefore differs from lnx or log10x only by a vertical stretch, and the shape is the same.
Applications
The base-2 logarithm is especially important in computer science.
- The bit, the unit of information, is measured with log2
- Distinguishing n alternatives requires log2n bits
- Binary search and merge sort, which halve the problem at every step, run in O(log2n) time
- A musical octave, a doubling of frequency, is measured the same way
Learning that an event of probability p has occurred carries −log2p bits of information, which is the basis of Shannon entropy.