Logarithm Calculator (log / ln / log₂ / any base)
Enter a positive value x and a custom base a to get logₐ(x), alongside the natural log ln(x) (base e), the common log log₁₀(x) (base 10) and the binary log log₂(x) (base 2). The change-of-base formula logₐ(x) = ln(x) ÷ ln(a) is shown with the actual numbers substituted, and an inverse check aʸ = x lets you confirm the result. Useful for high-school / college math homework, solving exponential growth and decay equations, and the calculations behind pH, decibels, the Richter scale and information entropy.
For example: log₁₀(1000) = 3, log₂(1024) = 10, ln(e) = 1.
x and a must be positive numbers, and a ≠ 1.
Natural log ln(x)
6.907755
Base e ≈ 2.71828 — used in calculus, continuous growth and decay.
Common log log₁₀(x)
3
Base 10 — used for pH, decibels, the Richter scale.
Binary log log₂(x)
9.965784
Base 2 — used in computer science, information theory, musical octaves.
log₅(x)
4.292030
Computed via change of base: logₐ(x) = ln(x) ÷ ln(a).
Change-of-base formula
log₅(1000) = ln(1000) ÷ ln(5) = 6.907755 ÷ 1.609438 = 4.292030
Inverse check
5^4.292030 = 1000
Going the other way: aʸ = x (use this to verify the log).
Formula
logₐ(x) = ln(x) ÷ ln(a) // change-of-base formula ln(x) = logₑ(x) // natural log, base e ≈ 2.71828 log₁₀(x) = log(x) // common log (the unqualified "log" in most science texts) log₂(x) // binary log, common in CS Inverse: a^logₐ(x) = x
- · Domain: x must be > 0, and the base a must be > 0 with a ≠ 1. Zero, negative inputs, and a = 1 (which makes ln(a) = 0 and the denominator blow up) are all flagged as invalid.
- · Useful values to memorise: log₁₀(1000) = 3, log₂(1024) = 10, log₂(1,000,000) ≈ 19.93, ln(e) = 1, ln(2) ≈ 0.6931.
- · Change of base: logₐ(x) = ln(x) ÷ ln(a) = log₁₀(x) ÷ log₁₀(a). A real-world scientific calculator only needs one of the ln or log buttons — the rest is one division.
- · Logarithms turn multiplication into addition: ln(xy) = ln(x) + ln(y), ln(x/y) = ln(x) − ln(y), ln(xⁿ) = n · ln(x). This is exactly why Napier invented logarithms in the early 1600s — to speed up multi-digit astronomical multiplications.
- · Common scientific uses: pH = −log₁₀([H⁺]); decibels L_dB = 10 · log₁₀(P / P_ref); the Richter scale of earthquakes is log₁₀ (one step ≈ 31.6× more energy); information entropy uses log₂ (bits); compound-interest doubling time t = ln(M) ÷ ln(1 + r).
- · Implementation uses JavaScript's built-in Math.log (natural log). Other bases are derived by change of base. Integer powers like log₂(1024) sometimes round to 9.99999999… in floating-point — the display uses toPrecision(8), so they show as clean integers.
- · References: high-school math textbook definition; IEEE 754 double-precision (which Math.log targets); MDN documentation for Math.log / Math.LN10 / Math.LN2.
Frequently asked
When "log" is written with no base, does it mean log₁₀?
It depends on context — this is a notorious convention trap. 1) In high-school physics, chemistry, and engineering texts (pH, decibels, Richter scale), plain "log" means log₁₀. 2) In university pure-math, calculus and probability, "log" usually means ln (= logₑ). 3) In computer science, information theory and complexity analysis, "log" sometimes means log₂. To avoid confusion the textbook safe move is to write the base explicitly (log₁₀ / ln / log₂). This calculator just shows all four at once, so you don't have to guess.
How do I compute logₐ(x) for an arbitrary base using only ln or log₁₀?
Use the change-of-base formula: logₐ(x) = ln(x) ÷ ln(a) = log₁₀(x) ÷ log₁₀(a). For example, to compute log₅(1000) — divide ln(1000) ÷ ln(5) ≈ 6.9078 ÷ 1.6094 ≈ 4.2920. The "inverse check" panel below shows 5^4.2920 ≈ 1000, confirming the answer. In practice this is why phone calculators ship with only "log" (= log₁₀) and "ln" keys — change of base covers every other base.
Why is log(x) undefined for x = 0 or negative x?
A logarithm is the inverse of exponentiation — logₐ(x) asks "what power of a equals x?" If a > 0 and a ≠ 1, then aʸ is always positive no matter what y is, so it can never equal zero or a negative number. Over the reals, log(x) is therefore undefined for x ≤ 0. The limit as x → 0⁺ goes to −∞, which is why the y-axis is a vertical asymptote on the graph. Logs of negative numbers do exist in the complex plane (Euler's identity: ln(−1) = iπ), but that is outside ordinary high-school / college work. This tool flags such inputs as invalid.
Why can't the base a equal 1?
If a = 1, then 1 raised to any power is still 1 — so log₁(x) has no solution for x ≠ 1 (no y satisfies 1ʸ = x), and is indeterminate for x = 1 (every y works). The change-of-base formula also collapses: ln(1) = 0, putting a zero in the denominator. Negative bases are excluded for a related reason — fractional powers like (−2)^0.5 = √(−2) = i√2 leave the reals. So the standard definition of a logarithm requires a > 0 and a ≠ 1.
Related tools
Percentage Calculator
Percent of, percent change, and percent add/subtract in one.
GCD & LCM Calculator
Enter 2–6 positive integers to get the greatest common divisor (HCF / GCD) and least common multiple (LCM), with the Euclidean step chain shown.
Average Calculator (Mean / Median / Mode)
Enter a list of numbers to get the mean, median, mode, range plus standard deviation, variance and total.
Quadratic Equation Solver
Enter the coefficients of ax² + bx + c = 0 to find the real or complex roots, discriminant and vertex.
Password Strength (Entropy) Calculator
Estimate a password's bit entropy, brute-force time and strength tier. All computation happens in your browser.
Scientific Notation Converter
Convert between standard decimal numbers and scientific notation, with significant figures and order of magnitude.
Permutations & Combinations (nPr / nCr) Calculator
Compute permutations P(n,r), combinations C(n,r) and factorial n! — useful for probability problems, lottery odds and combinatorics homework.
Standard Deviation Calculator
Paste a list of numbers to compute mean, median, sample and population variance and standard deviation — with the working shown.
Triangle Calculator (SSS / SAS / ASA)
Solve a triangle from 3 sides, 2 sides + 1 angle, or 2 angles + 1 side — area, perimeter and remaining parts via the law of sines / cosines.
Pythagorean Theorem Calculator
Given any two sides of a right triangle (two legs, or one leg plus the hypotenuse), instantly find the third side, area, perimeter and the two non-right angles.
Circle Calculator (radius / diameter / circumference / area)
Enter any one of radius, diameter, circumference or area to get the other three — useful for design, engineering and DIY.
Roman Numeral Converter
Two-way conversion between Arabic numbers (1–3999) and Roman numerals (I, V, X, L, C, D, M) — handy for typesetting, chapter titles and homework.
Slope & Line Equation Calculator (y = mx + b from Two Points)
Enter two points (x₁, y₁) and (x₂, y₂) to instantly get the slope, y-intercept, line equation y = mx + b, distance, and midpoint — a classroom staple for algebra and coordinate geometry.
Birthday Paradox Calculator
Enter group size n to see the probability that at least two people share a birthday — the classic birthday problem.
Z-Score (Standard Score) Calculator
Enter a value, the mean and the standard deviation to compute the z-score and the corresponding normal-distribution percentile and probabilities.
Screen Pixel Density (PPI) Calculator
Enter the screen resolution and diagonal size to get pixel density (PPI), real width/height, dot pitch and total pixel count.
Hong Kong Mark Six Odds Calculator
Enter the number of tickets / selections and see the actual probability of hitting first, second … prizes in a Mark Six (6-of-49) draw.
Decimal to Fraction Converter
Convert any decimal (including repeating decimals) to a simplified fraction and a mixed number.
Sphere Volume & Surface Area Calculator
Give a sphere any one of radius, diameter, surface area or volume and instantly get the other three — plus the great-circle circumference and area.
Cylinder Volume & Surface Area Calculator
Enter the radius and height of a cylinder to get volume (π r²h), lateral surface, base area and total surface area.
Prime Factorization Calculator
Factor any integer from 2 up to 10¹² into primes, see the canonical exponent form, count and list all divisors.
Geometric Mean Calculator
Compute the n-th root of the product of n positive numbers — the right average for growth rates, returns and ratios — alongside the arithmetic mean for comparison.
Fibonacci Sequence Calculator
Enter any integer n from 0 to 1500 to instantly compute F(n) and F(n−1) with BigInt precision, the consecutive-term ratio (converging to the golden ratio φ) and the first 30 terms of the sequence.