How this logarithm calculator works
A logarithm is the inverse of raising a base to a power. The base b is the number being multiplied, and the logarithm tells you the exponent. Formally, if by = x, then logb(x) = y. So the log answers "what power turns the base into x?".
To compute a logarithm in any base, this tool uses the change-of-base formula: logb(x) = ln(x) / ln(b). Natural logs are used internally because every JavaScript engine provides Math.log (base e); dividing by ln(b) rescales the result to your chosen base. The convenience table always shows the three most common logs — base 10 (log), base e (ln) and base 2 (log2) — for the number you entered.
Reference note: the number x must be greater than 0, and the base b must be greater than 0 and not equal to 1. The logarithm of a zero or negative number is undefined over the real numbers, and base 1 has no valid logarithm because 1 raised to any power is always 1.
Frequently asked questions
- What is a logarithm?
- A logarithm answers the question: to what power must I raise the base to get this number? If b raised to the power y equals x, then log base b of x equals y. For example, because 10³ = 1000, log base 10 of 1000 is 3.
- What is the difference between log and ln?
- Both are logarithms; they differ only in the base. "log" usually means the common logarithm, base 10, while "ln" is the natural logarithm, base e (about 2.71828). So log of 1000 is 3, while ln of e is 1.
- What is the change-of-base formula?
- It lets you compute a logarithm in any base using natural logs: log base b of x equals ln(x) divided by ln(b). It works with base 10 too: log base b of x equals log10(x) divided by log10(b). This is exactly how the calculator handles custom bases.
- What is log base 2?
- Log base 2 of x, sometimes written lb(x) or log2(x), is the exponent you raise 2 to in order to get x. For example, log base 2 of 8 is 3 because 2³ = 8. It is widely used in computing and information theory.
- Why can't you take the log of a negative number?
- For a positive base, raising the base to any real power always gives a positive result, so there is no real exponent that produces a negative number or zero. That is why the log of zero or a negative number is undefined over the real numbers.
- What is the log of 1?
- The logarithm of 1 is 0 in every valid base, because any non-zero base raised to the power 0 equals 1. So log10(1), ln(1) and log2(1) are all 0.