Math Runs locally Ready to use Built-in examples No tracking

Log Calculator

Compute logarithms with base 10, e, 2 or a custom base, with automatic domain validation.

A logarithm is a way of doing subtraction in a world built on multiplication, which is why earthquake magnitudes, decibels, pH and algorithm complexity all use one. Two things trip people up by hand: what to do when the base is neither 10 nor e, and whether the argument is allowed to be zero or negative. Switch between the common bases, type any base you like, and invalid inputs are reported rather than silently returning NaN.

The domain is the whole point: the argument must be greater than zero, and the base must be greater than zero and not equal to 1 — so log(0), log(−5) and log base 1 are all undefined, and this tool says so instead of producing a number. For a base you cannot reach on a calculator, the change-of-base identity log_b(x) = ln x / ln b does the job.

How to use

  1. Choose a common base (10, e or 2) or enter a custom one.
  2. Enter the argument and read the result.
  3. If the input falls outside the domain, read the reason rather than a value.
  4. For an unusual base, apply the change-of-base identity to check the answer by hand.

How it works

Common and natural logarithms

Pick a base: lg defaults to base 10, ln to base e ≈ 2.71828, and log2 is common in information theory and algorithm complexity.

Custom bases

Custom base: for log5(125), choose "Custom", enter 5 as the base and 125 as the argument — the result is 3.

The change-of-base formula

Change of base: log_b(x) = lg(x) ÷ lg(b). The tool computes exactly this, so any base is handled precisely.

Code example

JavaScript One implementation via the change-of-base formula

const log = (x, base = 10) => Math.log(x) / Math.log(base);

log(100);          // 4.605 (Math.log is the natural log, ln)
log(100, 10);      // 2 (log10)
log(1024, 2);      // 10 (log2)
log(243, 3);       // 5 (any base)
// Math.log(x) is ln in JS; log10 and log2 have dedicated functions:
// Math.log10(x), Math.log2(x)

Python math.log takes a base argument

import math

math.log(100)        # 4.605 (ln)
math.log(100, 10)    # 2.0 (log10)
math.log(1024, 2)    # 10.0
math.log10(100)      # 2.0 (dedicated, faster and more accurate)
math.log2(1024)      # 10.0

# A domain error raises ValueError outright rather than silently returning a complex number

FAQ

What is the difference between log and ln?

In most textbooks log means the base-10 common logarithm (also written lg), while ln specifically means the base-e natural logarithm. Engineering and scientific work leans on ln more often.

Why do 0 and negative numbers have no logarithm?

The logarithm answers "b raised to what power equals x" — but any real power of a positive b is greater than 0, so for x ≤ 0 no logarithm exists. The tool reports the input as out of domain.

Why can't the base be 1?

Every power of 1 is 1 and can never equal x (except x = 1), so such a "logarithm" is meaningless — the definition excludes base 1.

What is the definition of a logarithm?

If a^b = N (with a > 0, a ≠ 1, N > 0), then b = log_a N. The logarithm is the inverse of exponentiation: it asks how many times the base must be multiplied to reach the number. For example log₂ 8 = 3 because 2³ = 8.

How is the change-of-base formula used?

log_a N = log_b N ÷ log_b a. Its value is converting any base into the ready-made common or natural log on a calculator: log₂ 8 = ln 8 ÷ ln 2 = 3. Use it whenever your calculator has no base-switch key.

What are logarithms used for?

Logs turn multiplication into addition and powers into multiplication. Sound decibels, earthquake magnitudes, solution pH, compound-interest periods and algorithm complexity (O(log n)) are all built on them. When data spans wildly different magnitudes, comparing on a log scale is far more informative.

Where do lg and ln each get used?

lg (base 10) suits decimal orders of magnitude — decibels, pH, the Richter scale. ln (base e) shows up in continuous growth, compound interest, probability and calculus, where it differentiates and converts most cleanly. Both are staples of engineering calculation.