All topics
Foundational

Algebra · the inverse of growth

Logarithm Calculator

Enter a number and a base, and the calculator below tells you the power you would have to raise that base to. It also shows the three logarithms you meet most often, and where your number sits on a scale that counts by multiplying.

Click to begin

Explained like you're twelve. Explained like you've just finished school. Explained like you're at university.

By . Last updated .

Algebra · Napier, 1614

A logarithm asks the only question an exponent leaves open: what power was that?

Logarithm calculator

\(\log_b x = y\) means exactly \(b^y = x\). Any base can be reached from any other by the change of base rule, \(\log_b x = \dfrac{\ln x}{\ln b}\), which is how this calculator, and your phone, actually do it.

log₁₀ 1000
log₁₀ x (common)
ln x (natural)
log₂ x (binary)

On the scale above, every step of the same length is a multiplication by ten rather than an addition. That is the whole trick of a log scale, and it is why one ruler can hold a thousandth and a million at once without the small end vanishing.

What is a logarithm?

You already know how to do powers. Ten times ten times ten is a thousand, and we write that as 10 to the power 3. A logarithm just runs that backwards. It looks at 1000 and asks how many tens were multiplied together to get there. The answer is 3.

So when you see log of 1000 equals 3, read it as a question and an answer: "what power of ten makes a thousand?", "three". Try 100 and you get 2. Try 10 and you get 1. Every time you multiply by ten, the logarithm goes up by one.

That last sentence is why logarithms are everywhere. They turn multiplying into adding, and they squash huge ranges down to a comfortable size. An earthquake of magnitude 6 is not a bit stronger than a magnitude 5, it shakes ten times harder, because the Richter scale is a log scale. Loudness in decibels and acidity in pH work the same way.

The calculator above does this for any base you like, not just ten. Change the base and you change the question: "how many twos do I multiply?" or "how many threes?" The strip at the bottom shows your number sitting on a log scale, where equal spacing means equal multiplying.

How do you work out a logarithm in any base?

The definition is a single line: \(\log_b x = y\) exactly when \(b^y = x\), for a base \(b > 0\) with \(b \neq 1\) and an argument \(x > 0\). The logarithm is the inverse function of exponentiation, so the two undo each other: \(b^{\log_b x} = x\) and \(\log_b(b^y) = y\).

The restrictions are not arbitrary. There is no real power of a positive base that produces zero or a negative number, so \(x\) must be positive. Base 1 is excluded because \(1^y\) is always 1, so it could never reach anything else.

Three rules do most of the work, and they all come from the corresponding rules for powers:

\[ \log_b(xy) = \log_b x + \log_b y, \qquad \log_b\!\left(\frac{x}{y}\right) = \log_b x - \log_b y, \qquad \log_b(x^k) = k\log_b x. \]

The first is the historically important one. Before calculators, multiplying two six-digit numbers by hand was slow and error-prone, so you looked up both logarithms in a table, added them, and looked the answer back up. That is also exactly what a slide rule does mechanically, and it is why Napier's tables were such a big deal for astronomy and navigation.

Three bases dominate in practice. Base 10 (written \(\log\) or \(\log_{10}\)) suits anything measured in orders of magnitude. Base 2 counts doublings, so it is the natural language of computing and information. Base \(e \approx 2.71828\) gives the natural logarithm \(\ln\), which is the one calculus prefers, because the slope of \(\ln x\) is exactly \(1/x\). To get any other base from the ones your calculator has, use change of base: \(\log_b x = \ln x / \ln b\).

Logarithms, exponentials and scales of measurement

Defining it properly

Treating \(\log\) as the inverse of \(b^y\) is circular unless you have already defined irrational exponents. The cleaner route defines the natural logarithm as an integral, \(\ln x = \int_1^x \frac{dt}{t}\) for \(x > 0\), from which everything follows without assuming anything about powers. The product rule becomes a change of variable in the integral, monotonicity is immediate because the integrand is positive, and \(\exp\) is then defined as the inverse of \(\ln\). The number \(e\) arrives as the unique value with \(\ln e = 1\), rather than as a mysterious constant to memorise.

Why the natural log is the natural one

\(\frac{d}{dx}\ln x = 1/x\) with no stray constant, whereas \(\frac{d}{dx}\log_b x = 1/(x\ln b)\) carries a conversion factor. That single fact is why \(e\) shows up in every process whose rate is proportional to its own size: radioactive decay, compound interest, charging capacitors, population growth before resources bite. Solving \(dy/dt = ky\) gives \(y = y_0 e^{kt}\), and taking logs of both sides linearises it, which is why plotting such data on a log axis turns the curve into a straight line whose slope is the rate constant.

Logarithms as the unit of information and disorder

Shannon's entropy \(H = -\sum p_i \log_2 p_i\) and Boltzmann's \(S = k_B \ln W\) are the same mathematical move made in two fields. Both need a quantity that is additive when independent systems are combined, while the number of possible states multiplies. The logarithm is essentially the only continuous function that converts multiplication into addition, so it is forced on you rather than chosen. The base is then just a choice of unit: base 2 gives bits, base \(e\) gives nats, and \(k_B\ln\) gives joules per kelvin.

Complex arguments and the branch cut

Extending to complex numbers, \(\ln z = \ln|z| + i\arg z\), and because \(\arg z\) is only defined up to multiples of \(2\pi\), the complex logarithm is multivalued. Choosing a principal branch, usually \(-\pi < \arg z \leq \pi\), makes it a function again but introduces a branch cut along the negative real axis where it jumps discontinuously. This is the source of a familiar class of bugs and paradoxes, including the fake proof that \(1 = -1\) obtained by applying \(\log(xy) = \log x + \log y\) carelessly to negative numbers. The identity that holds unconditionally on the reals holds only modulo \(2\pi i\) on the complex plane.

A note on computation

Multiplying many small probabilities underflows to zero quickly in floating point, so likelihoods are almost always accumulated as sums of logarithms instead. Doing that safely requires the log-sum-exp trick, factoring out the largest term before exponentiating, which is a standard component in statistical software and in the softmax layer of a neural network. Libraries also provide \(\text{log1p}(x)\) for \(\ln(1+x)\), because for tiny \(x\) the naive expression loses all its significant digits in the addition.

Related: Calculus · Entropy · or go back to all topics.

Sources