Wiki

Logarithm Calculator: Log₁₀, Natural Log & Custom Base

Calculate logarithms in any base using the change-of-base formula. Covers log₁₀, ln, and custom bases with verification.

Verified against Khan Academy - Logarithms on 25 Feb 2026 Updated 25 February 2026 3 min read
Open calculator
Read in other languages (4)

Summary

A logarithm answers the question: “What power must I raise this base to in order to get that number?” If b^y = x, then log_b(x) = y. Logarithms are the inverse of exponentiation, just as subtraction is the inverse of addition. They appear throughout science and engineering — the Richter scale (earthquakes), decibels (sound), pH (chemistry), and information theory (bits) all use logarithmic scales. This calculator computes logarithms in any base, including the two most common: base 10 (common logarithm, log) and base e (natural logarithm, ln).

How it works

The calculator uses the change-of-base formula to compute logarithms in any base. Since JavaScript natively provides Math.log (natural log, base e) and Math.log10 (common log, base 10), any other base is computed by converting:

  1. Common logarithm (log_10) — computed directly using Math.log10. Answers “10 raised to what power gives x?”
  2. Natural logarithm (ln) — computed directly using Math.log. Answers “e raised to what power gives x?” where e is approximately 2.71828.
  3. Custom base — uses the change-of-base formula: log_b(x) = ln(x) / ln(b). This works because if b^y = x, then y * ln(b) = ln(x), so y = ln(x) / ln(b).

The calculator also provides a verification step: it raises the base to the computed logarithm and confirms the result matches the original input (within floating-point precision).

Why logarithms matter

Logarithms convert multiplication into addition and exponentiation into multiplication. This property made them essential for computation before electronic calculators (via slide rules and log tables) and remains fundamental in:

  • Computer science — algorithm complexity (O(log n) for binary search)
  • Information theory — entropy measured in bits (log base 2)
  • Finance — continuous compounding uses natural logarithms
  • Signal processing — decibels use base-10 logarithms
  • Chemistry — pH = -log_10[H+]

The formulas

log_b(x) = y means b^y = x

Where

b= Base of the logarithm (must be positive, cannot be 1)
x= The argument (must be positive)
y= The exponent that b must be raised to in order to equal x
Change of base: log_b(x) = ln(x) / ln(b)

Where

log_b(x)= Logarithm of x in base b
ln(x)= Natural logarithm of x (base e)
ln(b)= Natural logarithm of the base b

Key logarithm identities

IdentityFormulaExample
Log of 1log_b(1) = 0log_10(1) = 0
Log of baselog_b(b) = 1ln(e) = 1
Log of a powerlog_b(b^n) = nlog_10(10^3) = 3
Product rulelog_b(xy) = log_b(x) + log_b(y)log(20) = log(4) + log(5)
Quotient rulelog_b(x/y) = log_b(x) - log_b(y)log(5) = log(10) - log(2)
Power rulelog_b(x^n) = n * log_b(x)log(1000) = 3 * log(10)

Worked examples

Calculate log_2(8)

1

Ask: 2 raised to what power equals 8?

2^1 = 2, 2^2 = 4, 2^3 = 8

= 3

2

Verify using change-of-base formula

log_2(8) = ln(8) / ln(2) = 2.0794 / 0.6931 = 3.0000

= 3

3

Verify by raising base to result

2^3 = 8 -- matches the original input

= Verified

Result

log_2(8) = 3 because 2^3 = 8

Calculate log_10(1000)

1

Ask: 10 raised to what power equals 1000?

10^1 = 10, 10^2 = 100, 10^3 = 1000

= 3

2

Alternatively, count the zeros

1000 has 3 zeros, so log_10(1000) = 3

= 3

3

Verify by raising base to result

10^3 = 1000 -- matches the original input

= Verified

Result

log_10(1000) = 3 because 10^3 = 1000

Calculate ln(e^5)

1

Apply the power rule: ln(e^n) = n * ln(e)

ln(e^5) = 5 * ln(e)

= 5 * ln(e)

2

Recall that ln(e) = 1

5 * 1 = 5

= 5

3

Verify by computing e^5

e^5 = 2.71828^5 = 148.413, and ln(148.413) = 5.0000

= Verified

Result

ln(e^5) = 5 because e raised to the 5th power returns e^5

Inputs explained

  • Argument (x) — the number you want to take the logarithm of. Must be positive; the logarithm of zero or a negative number is undefined in the real numbers. (Technically, logarithms of negative numbers exist in the complex plane, but this calculator handles real values only.)
  • Base (b) — the base of the logarithm. Common choices are 10 (common log, written “log”), e (natural log, written “ln”), and 2 (binary log, written “lg” or “log_2”). Must be positive and cannot be 1 (because 1^y = 1 for all y, making the logarithm undefined).
  • Preset bases — quick-select buttons for the three most common bases: 10, e, and 2.

Outputs explained

  • Logarithm value — the computed result, log_b(x). For example, log_2(8) = 3.
  • Verification — the calculator shows b^result and confirms it equals x (within rounding), providing a sanity check.
  • Equivalent expressions — for convenience, the result is also shown in the other two common bases. For example, if you compute log_2(8) = 3, it also shows log_10(8) = 0.9031 and ln(8) = 2.0794.
  • Inverse — the calculator shows b^y = x as the equivalent exponential form, reinforcing the relationship between logarithms and exponents.

Assumptions & limitations

  • Positive arguments only — log_b(x) is defined only for x > 0 in the real number system. The calculator returns an error for zero or negative inputs.
  • Base restrictions — the base must be positive and not equal to 1. A base of 1 would make the logarithm undefined (since 1^y = 1 for all y, no power of 1 can produce any value other than 1).
  • Floating-point precision — results are accurate to approximately 15 significant digits. For values very close to 1, the result will be very close to 0, and small rounding differences may appear.
  • Very large or small arguments — arguments larger than approximately 10^308 or smaller than 10^(-308) exceed JavaScript’s floating-point range and will produce Infinity or -Infinity respectively.
  • No complex logarithms — the logarithm of a negative number (e.g., log(-1) = i*pi) is a complex number and is not computed by this calculator. Use a complex number calculator for such cases.

Sources

Academic
Khan Academy - Logarithmsaccessed 25 Feb 2026
Academic
Wolfram MathWorld - Logarithmaccessed 25 Feb 2026
logarithm log natural-log math