Logarithm Change of Base Calculator
A logarithm answers the question: to what power must I raise the base to get this number? The logarithm base 2 of 8 is 3 because 2 cubed equals 8. The logarithm base 10 of 1,000 is 3 because 10 cubed is 1,000. Most scientific calculators can compute two bases: base e (the natural logarithm, ln) and base 10 (the common logarithm, log). For any other base, you use the change of base formula: log base b of x equals ln(x) divided by ln(b). This works because logarithms in any base are proportional, differing only by a constant multiplier. Common base choices include base 2 in computer science (for binary data, information theory and big-O analysis), base 10 in chemistry (pH), acoustics (decibels) and engineering, and base e throughout calculus, statistics and natural growth and decay models. This calculator computes log base b of x for any positive base b (other than 1) and any positive x. It shows the result to four decimal places, the natural log and log10 of the same input for comparison, the two values used in the change of base fraction, and a verification that b raised to the result equals x. The default example is log base 8 of 32, which equals exactly 5/3.
Formula: log_b(x) = ln(x) / ln(b). Both x and b must be positive; b cannot equal 1.
How it works
The change of base formula is log_b(x) = ln(x) / ln(b). JavaScript's Math.log() computes natural logarithms. Both ln(x) and ln(b) are computed, and the result is their ratio. For verification, Math.pow(b, result) should equal x; any small discrepancy from the expected value reflects floating-point rounding. The exact fraction approximation checks if the result is close to a simple ratio p/q with q from 1 to 20 and displays it when found. Common log (base 10) is computed as Math.log10(x).
Worked example
log base 8 of 32. ln(32) = 3.4657 and ln(8) = 2.0794. Dividing: 3.4657 / 2.0794 = 1.6667 (to 4 decimal places). This is exactly 5/3 because ln(32) = 5 x ln(2) and ln(8) = 3 x ln(2), so the ln(2) terms cancel. Verification: 8 to the power of 5/3 = (8^(1/3))^5 = 2^5 = 32. log10(32) = 1.5051. These match the defaults pre-filled above.
Related calculators
- Completing the Square: rewrite a quadratic in vertex form and find its roots.
- Binomial Expansion: expand (a+b) to the power n using Pascal's triangle coefficients.
- Cross Multiplication: solve proportions a/b = c/d for any unknown.
- Percent Error Calculator: percentage deviation from a true value.