Logarithm to any base

Enter base a and argument x. The logarithm loga(x) is the exponent y such that ay = x. The result uses y = ln(x)/ln(a). For a = 2 and x = 8 the value is 3. For a = 10 and x = 100 the value is 2. In the reals you need x > 0 and a > 0 with a ≠ 1.

Input

Result

Enter base a and argument x.

Base a must be > 0 and ≠ 1. Argument x must be > 0. Outside the domain a real logarithm does not exist — the calculator reports an error instead of showing a misleading zero (which would collide with loga(1) = 0).

How it works

How log₂(8) is computed
a2
x8
ln(x)/ln(a)ln 8 / ln 2
y3

A logarithm with base a, written log_a(x), is the exponent y that satisfies a^y = x. In other words: what power of a returns x. The definition requires x > 0 and a > 0, a ≠ 1. Then the exponential map t ↦ a^t is a bijection from ℝ onto (0, ∞) and has inverse log_a. That domain choice and the change-of-base formula are standard in the NIST Digital Library of Mathematical Functions, §4.1 (logarithms), and in the classical Abramowitz and Stegun tables.

The calculator uses two numbers you enter: base a (the “Base a” field) and argument x (the “Argument x” field). The calculator computes y = ln(x) / ln(a), that is ln(x)/ln(a). The same value equals log₁₀(x)/log₁₀(a). For a = 2 and x = 8 the result is 3, because 2³ = 8. For a = 10 and x = 100 the result is 2. For a = 3 and x = 27 a notebook gives exactly 3; in floating-point arithmetic the quotient is sometimes 3.0000000000000004, so the panel shows many decimals near 3.

When a = 1, a ≤ 0, or x ≤ 0, a real logarithm does not exist. An earlier version of the calculator returned 0 then, which collided with the valid result log_a(1) = 0 on an allowed base. Now the calculator reports an error: a bad base or a non-positive argument does not get a false zero. A period and a comma in the fields are equivalent.

Special cases follow from the choice of a. For a = 10 the function is the common (decimal) logarithm. For a = e ≈ 2.718281828459045 the result is the natural logarithm ln(x). For a = 2 the result is the binary logarithm used with bits and trees. Neighboring log₁₀ and ln pages keep those bases fixed; here you choose a yourself.

Logarithm laws follow from the power laws. For fixed a and positive arguments: log_a(xy) = log_a(x) + log_a(y), log_a(x/y) = log_a(x) − log_a(y), log_a(x^k) = k·log_a(x). Change of base: if y = log_a(x), then a^y = x; taking any allowed base-c log yields y·log_c(a) = log_c(x), so y = log_c(x)/log_c(a). The result panel also shows the check a^y, which returns close to x.

In computer science log₂ describes bit-scale magnitude. In chemistry log₁₀ appears in pH and pKa. This calculator does not compute pH or tree depth — only y = log_a(x) from two fields, via change of base.

Formula

y = loga(x) if and only if ay = x, with x > 0, a > 0, a ≠ 1.

Change-of-base formula: loga(x) = ln(x) / ln(a) = log₁₀(x) / log₁₀(a). Symbol a is the base (the “Base a” field). Symbol x is the argument (the “Argument x” field). Symbol y is the result. Computation: ln(x) / ln(a).

Mathematical model: logarithm to base a via change of base, matching NIST DLMF §4.1 and Abramowitz and Stegun (chapter 4).

Theory, change of base, and laws

Definition

The logarithm of x to base a is the exponent y satisfying aʸ = x. Notation: y = log_a(x). In the reals one requires x > 0 and a > 0, a ≠ 1. The change-of-base formula reduces everything to ln: log_a(x) = ln(x)/ln(a) = log₁₀(x)/log₁₀(a). The calculator evaluates ln(x)/ln(a) and also shows log₁₀ variants.

When a = e one recovers ln; when a = 10 — log₁₀; when a = 2 — the binary logarithm lb/ld. NIST DLMF §4.6 and Abramowitz & Stegun state the change-of-base identity as standard. MathWorld (Logarithm) lists the same conditions on a and x.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Historical and conceptual context

Different bases match different scales: bits (a = 2), decades (a = 10), nepers (a = e). In computer science log₂ appears in complexity and Shannon entropy (in bits). Algebraically all real logarithms differ only by a constant.

Conceptually the calculator rejects a ≤ 0 and a = 1 (then aʸ is not a bijection ℝ → (0, ∞) in the usual sense). Negative x are rejected in ℝ.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Formal properties

Domain: x > 0, a > 0, a ≠ 1. Codomain: ℝ. For a > 1 the map is increasing; for 0 < a < 1 it is decreasing. log_a(a) = 1, log_a(1) = 0, log_a(aʸ) = y.

Identities: log_a(xy) = log_a x + log_a y; log_a(xʳ) = r log_a x; log_a(1/x) = −log_a x; log_a(x) = 1/log_x(a) when x ≠ 1. Change: log_a x = log_b x / log_b a.

Derivative in x: ∂/∂x log_a x = 1/(x ln a).

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Full derivation

Step 1. Let y = log_a x, so x = aʸ = e^{y ln a} (for a > 0, a ≠ 1).

Step 2. ln x = y ln a ⇒ y = ln x / ln a, provided ln a ≠ 0 (i.e. a ≠ 1).

Step 3. Hence the computation ln(x)/ln(a). Equivalently log₁₀(x)/log₁₀(a).

Step 4 (correctness). a^{ln x / ln a} = e^{(ln x / ln a)·ln a} = e^{ln x} = x — the definition of the inverse of powering (DLMF §4.6).

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Special cases

Examples: log₂(8) = 3; log₃(81) = 4; log₁₀(1000) = 3; log_{0.5}(8) = −3; log_e(e⁵) = 5. log_a(a) = 1 for every admissible a.

Errors: x ≤ 0; a ≤ 0; a = 1. When a is near 1, ln a ≈ 0 and the result is numerically ill-conditioned.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Numerical and computational notes

The quotient of two ln calls inherits floating-point arithmetic error; for a ≈ 1 or x ≈ 1 the relative error can be large even though the formula is correct. Comma and period are equivalent.

The panel shows ln x, ln a, log₁₀ x, log₁₀ a. The calculator does not return a complex Log.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

Related concepts and authorities

Related: ln, log₁₀, exp, nth root (inverse of x^{1/n}). Entropy and bits are interpretations of log₂, not a separate formula.

Authorities: NIST DLMF §4.6; Abramowitz & Stegun, Chapter 4; MathWorld — Logarithm; Wikipedia — Change of base. Educational tool.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Comparisons with classical tables (Abramowitz and Stegun) and with the NIST DLMF are meaningful for moderate values; near domain edges ulp differences are expected and do not indicate a conceptual defect of the calculator. MathWorld and Concrete Mathematics (Knuth) remain reference points for the definitions and notation used in the sections above.

How to use

  1. Enter base a, for example 2 (a > 0, a ≠ 1).
  2. Enter argument x, for example 8 (x > 0).
  3. Click Calculate or wait for the live result. 2 and 8 give 3. 10 and 100 give 2. 3 and 27 give a value near 3.
  4. Check the panel: ln(x), ln(a), the ratio, the equivalent log₁₀ form, and the ay check. The at plot marks the point (y, x).
  5. Base 1, a ≤ 0, or x ≤ 0 does not pass. Separate pages keep fixed bases 10 and e.

Symbol glossary

loga(x) is the exponent y with ay = x. It is computed as ln(x)/ln(a). For a = 2 and x = 8 the result is 3.

a
Base in the “Base a” field. Must be > 0 and ≠ 1. Examples: 2, 10, 3, 0.5, e.
x
Argument in the “Argument x” field. Must be > 0. Examples: 8, 100, 27, 1, 0.25.
y
Result loga(x) = ln(x)/ln(a). For 2 and 8 it is 3; for 2 and 1 it is 0.
ln
Natural logarithm (base e). Used here only for the change of base: ln in the browser.

Examples

Example 1

  • a = 2
  • x = 8

3

What is log₂(8)? 3.

Example 2

  • a = 10
  • x = 100

2

What is log₁₀(100)? 2.

Example 3

  • a = 3
  • x = 27

≈ 3

What is log₃(27)? ≈ 3 (exactly 3 on paper).

Example 4

  • a = 2
  • x = 1

0

What is log₂(1)? 0.

Example 5

  • a = 2
  • x = 16

4

What is log₂(16)? 4.

Example 6

  • a = 0.5
  • x = 8

−3

What is log_{1/2}(8)? −3.

Example 7

  • a ≈ e
  • x = 20

≈ ln(20)

What is logₑ(20)? ≈ ln(20).

Example 8

  • a = 2
  • x = 0.25

−2

What is log₂(0.25)? −2.

Related calculators

Common questions

What is the domain of a logarithm with base a?

The argument x must be greater than 0. The base a must be greater than 0 and not equal to 1. Outside that range a real logarithm does not exist — the calculator reports an error instead of showing a misleading zero.

What is log₂(8)?

The result is 3, because 2³ = 8. The calculator divides ln(8) by ln(2). That is the first example on this page.

What is log₁₀(100)?

The result is 2, because 10² = 100. Here you enter base 10 yourself; you do not need to open the separate common-logarithm page.

What is log₃(27)?

In a notebook the result is exactly 3. In floating-point arithmetic ln(27)/ln(3) is sometimes 3.0000000000000004, so the panel shows many decimal places near 3.

What is the change-of-base formula?

log_a(x) = ln(x)/ln(a) = log₁₀(x)/log₁₀(a). Proof: if y = log_a(x), then a^y = x; taking any allowed base-c log of both sides yields y·log_c(a) = log_c(x), so y = log_c(x)/log_c(a).

Why are base 1 or a ≤ 0 rejected?

For a = 1 we have ln(1) = 0, so the division cannot run. For a ≤ 0 a real logarithm is undefined. An older build returned 0 and collided with the valid result log_a(1) = 0.

How is this different from log₁₀ and ln?

On the common-logarithm page the base is always 10. On the natural-logarithm page the base is e. Here you enter any allowed base a. For a = 10 the result matches log₁₀; for a ≈ 2.71828 it matches ln.

What are the product, quotient, and power laws?

For a fixed base a: log_a(xy) = log_a(x) + log_a(y), log_a(x/y) = log_a(x) − log_a(y), log_a(x^k) = k·log_a(x), when the arguments are positive. These identities follow from the power laws and appear in NIST DLMF §4.1–4.7.

What are log₂(1) and log₂(0.25)?

log₂(1) = 0, because every allowed base to the power 0 equals 1. log₂(0.25) = −2, because 2^(−2) = 1/4. A fractional argument between 0 and 1 gives a negative result when a > 1.

Does a comma in 2.0 work?

Yes. 2.0 and 2,0 with argument 8 both give 3. A period and a comma in the fields are equivalent.

Do the currency and unit settings in the page header affect the result?

No. The result depends only on base a and argument x. The currency and unit settings in the page header do not affect this result.

What does base 0.5 with argument 8 give?

log_{0.5}(8) = −3, because (1/2)^(−3) = 8. A base in (0, 1) is allowed; the function is then decreasing.

How do I calculate a logarithm to any base?

Use change of base: log_a(x) = ln(x)/ln(a) with x > 0, a > 0 and a ≠ 1. For log₂(8): ln(8)/ln(2) = 3, because 2³ = 8.

What is log₅(125)?

3, because 5³ = 125. Enter a = 5 and x = 125; checking a^y should return 125.

What is log₂(16)?

4, because 2⁴ = 16. That is Example 5 on this page.

Does a logarithm of a negative number exist in the reals?

No. The argument x must be positive. For x ≤ 0 the calculator shows an error instead of a complex value.

Does this page compute an antilog or the power aʸ?

No. Here only y = log_a(x). The inverse aʸ = x belongs on the power or exponential calculator.

The result is loga(x) = ln(x)/ln(a): for a = 2 and x = 8 the exponent is 3. The check ay returns to x. Fixed bases 10 and e live on the common logarithm and natural logarithm pages.

Knowledge sources

The definition, domain, change-of-base formula, and laws below come from established mathematical references.

Page Updated November 2, 2026.