What a logarithm is
A logarithm is the inverse operation of exponentiation. The logarithm of a number x in base b, written as logₜ(x), is the exponent that b needs to be raised to in order to produce x. For example, log₁₀(1000) = 3, because 10³ = 1000. If exponentiation answers "what is the result of raising a base to an exponent," the logarithm answers the reverse question: "what exponent do I need to raise this base to, to get this result."
The change-of-base formula
Since calculators and most programming languages only implement the natural logarithm (ln) natively, a logarithm in any other base is calculated using the change-of-base formula: logₜ(x) = ln(x) / ln(b). That's how this calculator produces a result for any custom base you enter.
Log, ln, and log2: the most common bases
Common logarithm (base 10): usually just written as "log", widely used in engineering, scales like pH and decibels, and scientific notation.
Natural logarithm (base e): written as "ln", where e is Euler's number (approximately 2.71828). It shows up naturally in calculus, continuous exponential growth, and continuously compounded interest.
Binary logarithm (base 2): written as "log2", widely used in computer science, since it describes how many times a value can be divided in half, directly related to data structures and algorithms.
Worked example
If an investment doubles in value every year, the base-2 logarithm of the total growth factor tells you how many years that took. For example, if the investment multiplied by 8, log₂(8) = 3, so the doubling happened 3 times, meaning 3 years.
Logarithms and the pH scale
The pH of a solution is defined as the negative base-10 logarithm of the molar concentration of hydrogen ions (H+): pH = −log₁₀[H+]. This logarithmic scale is used because the H+ concentration can vary by many orders of magnitude between acidic and basic solutions, and the logarithm compresses that enormous range into a more practical scale from 0 to 14. A difference of just 1 in pH represents a 10-fold difference in actual H+ concentration.