How this works
A logarithm is the inverse of exponentiation: log_b(x) is the exponent you would raise b to in order to get x. Three bases dominate practical use. Base 10 (the "common log", written log) is the workhorse for orders of magnitude, decibels, pH and seismology — log₁₀(1000) = 3 because 10³ = 1000. The natural log (ln, base e ≈ 2.71828) is the choice for calculus, continuous growth processes and most pure mathematics, because differentiating ln(x) gives 1/x with no awkward constants. Base 2 (the "binary log", written log₂ or lg) shows up in computer science, information theory, and any half-life or doubling-time problem — log₂(1024) = 10 because 2¹⁰ = 1024. The calculator above handles all three plus any custom base, and lets you batch-transform a column of values with one click.
Conversion between bases is one multiplication: log_a(x) = log_b(x) / log_b(a) for any other base. The most useful instance is log₁₀(x) = ln(x) / ln(10) ≈ ln(x) × 0.4343, which lets you do natural-log calculations in your head and convert at the end if you need a base-10 answer. Log laws — log(ab) = log(a) + log(b), log(a/b) = log(a) − log(b), log(aⁿ) = n × log(a) — work for any base; this is why logs were invented as a 17th-century shortcut for multiplication, before electronic calculators made the trick obsolete for arithmetic. Today the laws still matter conceptually: every time you take a log of a product, you turn it into a sum, which is what makes log axes useful for showing data that spans many orders of magnitude.
Three practical points. (1) log(0) is undefined and log(negative number) is undefined for real-valued logs — the calculator returns "undefined" rather than guessing. If you have zeros in data you want to log-transform, the standard fix is "log(x + 1)" (sometimes written log1p) which leaves zero at zero and shifts everything else by an imperceptible amount; the calculator doesn't auto-apply this because the choice should be deliberate. (2) The "log" notation alone is ambiguous. In maths and engineering it usually means base 10; in pure mathematics, statistics and most programming languages it means natural log; in CS contexts it sometimes means base 2. When in doubt, write log₁₀, ln, or log₂ explicitly. (3) Log-transforming data is a common move in statistics when the underlying distribution is right-skewed — incomes, reaction times, gene expression counts, particle sizes. The transformation often makes a skewed distribution look approximately normal, which lets you use methods (t-tests, linear regression) that assume normality. The downside is that you've changed the units; if you're comparing log-transformed group means and need the result in original units, take the antilog of the difference, not the difference of antilogs.
The formula
b is the base (must be positive and not equal to 1), x is the argument (must be positive — log of zero or a negative number is undefined for real values). log₁₀ is the common logarithm (used in pH, decibels, magnitudes), ln = log_e is the natural logarithm (e ≈ 2.71828), log₂ is the binary logarithm. The change-of-base formula is what powers calculators internally — your phone almost certainly only stores ln, and computes log₁₀(x) as ln(x)/ln(10) and log_b(x) as ln(x)/ln(b) on the fly.
Example calculation
- Compute log₁₀(1000) — what power of 10 gives 1000?
- Since 10³ = 1000, log₁₀(1000) = 3.
- Cross-check: ln(1000) ≈ 6.9078, ln(10) ≈ 2.3026, so log₁₀(1000) = 6.9078 / 2.3026 = 3.000 ✓
Frequently asked questions
When should I use log₁₀ vs ln vs log₂?
Pick the base that matches what you're measuring. Use log₁₀ when the underlying scale is decimal — pH (each unit = 10× hydrogen ion concentration), decibels (each 10 dB = 10× power), Richter magnitude, orders of magnitude. Use ln when you're doing calculus or modelling continuous processes (compound interest, radioactive decay, population growth) — the natural log is "natural" because it makes the math clean (derivative of ln(x) is 1/x with no constants). Use log₂ when you're halving or doubling — half-lives, doubling times in cell biology, information content in bits, complexity classes in computer science. For exploratory data analysis, the choice often doesn't matter for the conclusion (a log axis with any base looks similar) but does matter for interpretability — pick the base that lets your audience read off intuitive numbers like "doubled" (log₂) or "tenfold" (log₁₀).
How do I log-transform data with zeros in it?
log(0) is undefined (negative infinity in the limit), so you can't take the log of zero directly. The standard fixes, in order of preference: (1) log(x + 1), often written log1p — this leaves zero at zero (because log(1) = 0) and shifts everything else by an imperceptible amount on the log scale for typical data. Built into most stats packages as `log1p(x)`. (2) log(x + small constant) — pick a small positive number (often half the smallest non-zero value in your data) and add it before logging. Less principled than log1p but useful when zeros represent below-detection-limit values rather than true absences. (3) Replace zeros with NA and exclude — only valid if zeros are truly missing rather than meaningful. The calculator above does not auto-apply any of these because the choice should be deliberate and depend on what your zeros mean — pre-process your data first, then paste the cleaned values into the list-mode input.
What's the difference between log and ln?
"ln" is unambiguous — it always means the natural log, base e ≈ 2.71828. "log" without a subscript is the ambiguous one, and what it means depends on context. In high-school maths, engineering and most calculator labels, plain "log" means base 10 (the common logarithm). In university-level pure mathematics, statistics, and most programming languages (Python, R, MATLAB, C's `log()`), plain "log" means the natural log — which is why scripts that look like they should give base-10 results sometimes don't. In computer science, "log" sometimes implicitly means base 2, especially in algorithm complexity (O(log n) is base-agnostic for orders of growth). When in doubt, write the base explicitly: log₁₀, ln, or log₂. The calculator above never uses ambiguous "log" — every result tells you the base.
Can I take the log of a negative number?
Not for real-valued logs. log_b(x) for any positive base b is only defined when x > 0; the function asks "what power of b gives x?", and any positive base raised to any real power is itself positive, so no real exponent reaches a negative number. The calculator returns "undefined" for negative or zero inputs rather than guessing. There is a complex-valued extension — for instance, ln(−1) = iπ in complex numbers, and ln(−x) = ln(x) + iπ — but it's rarely what you want unless you're specifically working in complex analysis or signal processing. If your data has negative values you want to log-scale (e.g. for plotting), the standard tricks are: take logs of absolute values and colour by sign, use a "signed log" function like sign(x) × log(1 + |x|), or use a symmetric log axis (symlog) that's linear near zero and logarithmic in the tails. Pick the one that matches what you're actually trying to show.