Binary logarithm (log₂)
Calculate the base-2 logarithm, essential in computing.
Co je binary logarithm
The binary logarithm log₂x is the logarithm with base 2 – it tells how many times a number can be halved before reaching one, or to what power to raise two. It is key in computing.
Where it is used in practice
- Computing: the number of bits needed to encode n values is log₂n.
- Algorithm complexity – binary search and sorting have complexity log₂n.
- Music: an octave is a doubling of frequency, i.e. log₂ of the ratio.
Good to know
log₂ 2 = 1, log₂ 8 = 3 (because 2³ = 8), log₂ 1024 = 10. Adding one bit doubles the number of possible values.
Logarithm and power are inverse operations
The logarithm is the inverse function of the power. Picturing it this way makes logarithms much easier to understand: logₐx = y ⟺ aʸ = x. For example log₂8 = 3, because 2³ = 8. The logarithm thus “unpacks” the exponent.
Rules of logarithms
In detail with examples: rules of logarithms.
Tip: a logarithm turns multiplication into addition – which is why logarithm tables and slide rules were once used to multiply large numbers quickly.