Skip to content

Logarithm Calculator

log₁₀(100) — the common logarithm

2


Check
102 ≈ 100

Estimates for educational purposes — not financial, medical, or legal advice. See terms.

Compute the logarithm of any positive value in any positive base (except 1). Three presets cover the most common cases: log base 10, natural log (base e), and log base 2. Any other base you type is handled by change-of-base under the hood.

What this tool does

Two inputs: a value (x) and a base (b). The result is log_b(x) — the exponent you’d need to raise b to in order to get x. Below the result, the tool shows a verification row computing b raised to that result, which should return the original value (modulo floating-point precision). That’s a useful sanity check when you’re not sure you got the question right.

The three preset buttons jump the base to a common value:

  • log₁₀ — base 10, the common logarithm used in chemistry, acoustics, seismology, and scientific notation
  • ln — base e ≈ 2.71828, the natural logarithm used in calculus and exponential growth / decay
  • log₂ — base 2, the binary logarithm used in computer science, information theory, and anything involving binary trees or halving

You can also just type the base manually — 3, 7, 0.5, or any other positive number ≠ 1.

Example: pH of a solution

pH is defined as −log₁₀ of the hydrogen ion concentration in mol/L. If a solution has [H⁺] = 0.001 mol/L, paste 0.001 with base 10 to get log₁₀(0.001) = −3. Negate that: pH = 3 (an acidic solution). If the concentration is 10⁻⁷ (neutral water), you’d get log₁₀(0.0000001) = −7, so pH = 7 as expected.

The negation step is conventional in chemistry — pH is always the negative log of the concentration so the numbers come out as small positive values instead of large negatives. This tool gives you the raw logarithm; you flip the sign yourself.

Example: bit width of an integer

You need to know how many bits it takes to represent a number in binary. The answer is ⌈log₂(n+1)⌉ — the base-2 logarithm, rounded up. For n = 1000, paste 1001 with base 2 (presets: log₂) to get about 9.967; round up to 10 bits. Check: 2¹⁰ = 1024, which is indeed just enough to cover 1000 — verifiable in one step with the exponent calculator.

More generally: log₂(n) tells you how many times you can halve n before you reach 1. It’s the classic measure of algorithmic depth for binary search, heaps, and balanced trees.

Example: decibels

dB = 10 × log₁₀(P/P₀), where P is the measured power and P₀ is a reference power. For a signal that’s 100× stronger than the reference, paste 100 with base 10 to get log₁₀(100) = 2, multiply by 10 → 20 dB. For 1000× → 30 dB. Every 10 dB is one order of magnitude, which is why the log scale is useful for quantities that span huge ranges.

Change of base

For any base that isn’t 10, e, or 2, the tool uses the identity log_b(x) = ln(x) / ln(b). This lets you compute a logarithm in a base your calculator doesn’t have a dedicated button for — log₃(27) = ln(27) / ln(3) ≈ 3.0, log₇(49) = ln(49) / ln(7) = 2, and so on. The tool does this automatically when the base you type isn’t one of the presets.

The presets use the browser’s dedicated Math.log10 / Math.log / Math.log2 functions, which are very slightly more accurate than the change-of-base formula because they skip the division. For everyday values the difference is invisible — the change-of-base result matches to 15+ decimal places.

What this tool does not do

It doesn’t handle complex numbers. Log of a negative number is a valid complex value, but the tool throws a domain error rather than returning a complex result. For that, you need a computer algebra system like WolframAlpha or SymPy.

It doesn’t show a step-by-step derivation for arbitrary bases beyond the verification row. It computes the answer and shows a check, which covers the “did I get the right answer?” question but not the “can you explain why?” question. For worked-example tutorials, a maths textbook or Khan Academy will be more useful.

It doesn’t do antilog (the inverse, b^y given y). Use the exponent calculator for that — it goes the other direction on the same relationship.

It doesn’t handle logarithms of zero or negative values. These are mathematically undefined over the real numbers, so the tool surfaces a domain error instead of silently returning NaN or negative infinity.

Frequently asked questions

What does log base b of x actually mean?

It's the exponent you'd need to raise b to in order to get x. 'log base 10 of 100 = 2' means 10 raised to the 2nd power is 100. 'log base 2 of 8 = 3' means 2 cubed is 8. The logarithm inverts exponentiation — if you know b^y = x, then log_b(x) = y. That's why the calculator shows a verification row with b^result, so you can see the round trip.

What's the difference between log, ln, and log2?

They're all logarithms with different bases. 'log' usually means log base 10 (the common logarithm), used in chemistry (pH), acoustics (decibels), and seismology (Richter scale). 'ln' means log base e (the natural logarithm), where e ≈ 2.71828 is Euler's number — it shows up in calculus, compound interest, and anything involving exponential growth. 'log2' means log base 2 (the binary logarithm), used in computer science for algorithmic complexity, information theory (bits), and anything involving binary trees.

Why can't I take the log of zero or a negative number?

Because there's no real-number exponent that turns a positive base into zero or a negative. b^y approaches zero as y goes to negative infinity but never reaches it, and it's always positive for positive b. So log_b(0) is undefined (informally, negative infinity), and log_b(-5) has no real answer — it would need complex numbers, which this tool doesn't handle. The calculator throws a domain error for both cases instead of returning NaN silently.

Why can't the base be 1?

Because 1 raised to any power is still 1. That means there's no unique answer to 'what power of 1 gives me x?' — if x = 1 every answer works, and if x ≠ 1 no answer works. So log base 1 is undefined by definition. The calculator rejects base 1 along with base ≤ 0.

How does the tool compute arbitrary bases?

Via the change-of-base identity: log_b(x) = ln(x) / ln(b). The browser's built-in Math.log gives you natural log, and the ratio of two natural logs gives you the log in any base. For the common cases of base 10, e, and 2, the tool uses Math.log10, Math.log, and Math.log2 directly, which are slightly more accurate because they avoid the division step. For any other base — 3, 7, 0.5, whatever — it falls through to change-of-base.