Logarithm Calculator
Compute the logarithm of any positive number in any positive base using the change-of-base formula. Logarithms are the inverse of exponentiation and the natural language of orders of magnitude, sound intensity, pH, earthquake energy, and algorithmic complexity.
About this calculator
The logarithm log_b(x) answers the question "to what power must base b be raised to produce x?" Formally, log_b(x) = y means bʸ = x. This calculator uses the change-of-base identity log_b(x) = ln(x) / ln(b), where ln is the natural logarithm (base e ≈ 2.71828), to compute logs in any base from JavaScript's built-in Math.log function. Variables: number (x) is the value whose logarithm you want; base (b) is the base of the logarithm. Both must be positive, and the base must not equal 1. Edge cases: log_b(1) = 0 for any valid base; log_b(b) = 1; log_b(0) is undefined (limit is -∞); log of a negative number is undefined in the reals (complex logs exist but are not what most calculators return). The three most-used bases are base 10 (common log, used in chemistry pH and engineering decibels), base e (natural log, used in calculus and physics because its derivative is 1/x), and base 2 (binary log, used in computer science for algorithmic complexity and information theory). Logarithmic identities worth memorising: log(xy) = log x + log y; log(x/y) = log x − log y; log(xⁿ) = n · log x; log_b(x) = 1 / log_x(b). Logs compress multiplicative differences into additive ones, which is why they appear in any context spanning many orders of magnitude (Richter scale, decibels, star brightness, neuron firing rates). Real-world calibrations: a 10× change in x corresponds to a +1 in log₁₀; a doubling corresponds to about +0.301 in log₁₀ or +1 in log₂.
How to use
Example 1 — Common log (base 10). Compute log₁₀(100). Enter Number = 100, Base = 10. Using change of base: ln(100) / ln(10) = 4.6052 / 2.3026 = 2.0000. ✓ The answer is 2 because 10² = 100. Common logs let you read off orders of magnitude directly: log₁₀(1000) = 3, log₁₀(1,000,000) = 6, log₁₀(0.001) = -3. Example 2 — Natural log. Compute ln(e²) (also written as log_e(e²)). Enter Number = e² ≈ 7.389, Base = e ≈ 2.71828. Result: ln(7.389) / ln(2.71828) ≈ 2.000 / 1.000 = 2.0. ✓ Or directly: log_b(bⁿ) = n for any base, so log_e(e²) = 2 trivially. The natural log shows up everywhere in calculus and probability — derivative of ln(x) is 1/x, integral of 1/x is ln|x|, and the exponential family of distributions all involve e or ln.
Frequently asked questions
What is the difference between log and ln?
Both are logarithms; they differ only in the base. "log" by itself usually means log₁₀ (base 10, the common log, used in chemistry, engineering, and applied math) in non-mathematical contexts, but many pure mathematicians use "log" to mean ln (natural log, base e). "ln" unambiguously means log_e — natural log, the inverse of the natural exponential eˣ. In computer science contexts, "log" often means log₂ (binary log). When reading a paper or textbook, always check the convention in use; bases differ by a constant multiplicative factor (log_b(x) = log_c(x) · log_c(b) — wait, more precisely log_b(x) = log_c(x) / log_c(b)), so the shape of any logarithmic curve is the same regardless of base, but the numerical values differ.
Why is the natural log "natural"?
Because the function f(x) = eˣ is the unique exponential whose derivative equals itself: d/dx(eˣ) = eˣ. As a consequence, the inverse function ln(x) has derivative 1/x — the simplest possible rational function derivative. This makes the natural log the "natural" choice for calculus: integrals of 1/x, solutions to differential equations like dy/dx = ky (exponential growth), and the formula for entropy in physics all involve ln. The base e ≈ 2.71828 emerges as the limit of (1 + 1/n)ⁿ as n → ∞ — the value you get from continuously compounded interest at 100% per period. It is also the base for which the exponential function and its inverse log are most symmetric, with the simplest derivatives. The number e was named by Euler in 1736 and is one of the most important constants in mathematics, alongside π and i.
How do I solve equations with logarithms?
Use the inverse property: if log_b(x) = y then x = bʸ. For example, to solve log₂(x) = 5, raise 2 to the power 5: x = 32. For equations with logs on both sides, set the arguments equal: log_b(f) = log_b(g) implies f = g. Common identities for combining logs: log_b(xy) = log_b(x) + log_b(y) (logarithm of a product is the sum of logarithms), log_b(x/y) = log_b(x) − log_b(y), log_b(xⁿ) = n · log_b(x). Always check the domain: log is only defined for positive arguments, so any solution that makes a log's input zero or negative must be rejected as extraneous. When solving exponential equations like 2ˣ = 7, take the log of both sides: x · log(2) = log(7), so x = log(7) / log(2) ≈ 2.807 (regardless of base — change-of-base cancels out).
What are the most common mistakes people make with logarithms?
The first is forgetting that log of a negative number or zero is undefined in the real numbers — taking log(0) gives -∞ as a limit but is not a number, and log of a negative gives a complex result. The second is mis-applying the product/quotient/power rules: log(x + y) is NOT log(x) + log(y); the rule only works for products. The third is base confusion — using ln when the problem wanted log₁₀, or vice versa, which scales the answer by a constant factor (about 2.303×). The fourth is dropping the implicit base 10 when reading "log" in scientific contexts but treating it as ln when reading "log" in pure-math contexts; always clarify before computing. The fifth is taking the log of expressions with negative or zero solutions without checking domain — solutions that make the log undefined are extraneous and must be discarded.
When should I not use this calculator?
Skip it for log of a negative or zero argument — the result is undefined in the reals; for complex logs use a CAS or a complex-arithmetic library. Do not use it when the base is 1 or non-positive — these are not valid logarithm bases (log_1 is undefined because 1 raised to any power is 1, never anything else). It is the wrong tool for discrete-log problems in cryptography (find x such that gˣ ≡ h mod p) — those need specialised algorithms (baby-step giant-step, Pohlig-Hellman, index calculus). Avoid it for high-precision logarithms requiring more than ~15 decimal digits — JavaScript's double-precision floats cannot represent more than that; use an arbitrary-precision library. Finally, do not use it for symbolic algebra (solve for x in log_b(f(x)) = g(x) with f, g, b as symbols) — that needs a computer algebra system.