Logarithm Calculator
The logarithm logₐ(x) answers the question: to what power must the base a be raised to get x? This calculator uses the change-of-base formula logₐ(x) = ln(x)/ln(a) and verifies the answer by raising the base back to that power.
Any base, from the two that exist
A logarithm answers a question about exponents: to what power must the base be raised to reach this value? Written logₐ(x), it is the exponent that turns a into x, which makes it the exact inverse of raising a to a power.
This calculator evaluates that for any base you choose, not only the two that hardware provides. It shows the conversion it performs, the result, and a check that raising the base back to that power recovers the value you started from.
Calculators and programming languages generally offer only base e and base 10, because those are the two implemented in hardware. A logarithm in base 2, base 3 or base 7 has to be built from one of them.
The change of base formula does that in a single division, and the tool shows both natural logarithms before dividing them. Seeing those two values separately makes it clear the result is a ratio rather than an operation of its own.
How to use this calculator
- Enter the base Any positive number other than 1. Base 2 for information and computing, base 10 for orders of magnitude, base e for calculus — but any positive value is accepted.
- Enter the value Strictly positive. Zero and negatives have no real logarithm in any base, and are rejected with an explicit message rather than returning a non-finite number.
- Read the change-of-base line It shows the two natural logarithms before the division. Their ratio is the answer, and seeing both makes an implausible result easy to attribute.
- Check the verification line The base is raised back to the computed power and the result shown. It should reproduce your value, which confirms the whole calculation in one step.
The formula, and where it comes from
logₐ(x) = ln(x) / ln(a) logₐ(x) = y ⟺ aʸ = x domain: a > 0, a ≠ 1, x > 0
The second statement is the definition. A logarithm and an exponential are the same relationship read in opposite directions, and every property of logarithms follows from that equivalence rather than being a separate rule to learn.
The change of base formula converts between bases by a single division. It holds for any base in the numerator and denominator, provided both are the same — the natural logarithm is used here only because it is the one available, and base 10 throughout would give an identical answer.
The domain conditions are not arbitrary restrictions but statements about when the question has an answer. A positive base raised to any real power stays positive, so no exponent produces zero or a negative value, and asking for one has no real solution.
The exclusion of base 1 is separate. Every power of 1 is 1, so the base can never reach anything else, and the formula reflects that by dividing by ln(1), which is zero. Both readings say the same thing: a base of 1 carries no information.
What each input means
- a Base — form field “Base b”
- The number being raised to a power. Must be positive and different from 1. A base between 0 and 1 is valid and reverses the sign of every result.
- x Value — form field “Value x”
- The number to reach. Strictly positive; no real logarithm exists otherwise.
- y Result
- The exponent satisfying the definition. It may be negative, fractional or irrational, and is rarely a whole number.
Worked examples
Every number below is produced by the same calculation engine the tool above runs. Nothing here is typed by hand, so the walkthrough cannot drift from what you get when you enter the same values yourself.
An exact power of two
Compute the logarithm of 32 in base 2. Since 32 is 2 raised to the fifth power, the answer should be exactly 5.
Inputs Base b = 2, Value x = 32
- Expression log₂(32)
- Change of base logₐ(x) = ln(x) / ln(a) = 3.46574 / 0.693147
- Result = 5
- Check 2^5 ≈ 32
Result log₂(32) = 5
The two natural logarithms are both irrational, and their ratio nonetheless comes out as a clean 5. That is the change-of-base formula working correctly: the irrationality is an artefact of the route, not of the answer.
The verification line raises 2 back to the fifth power and recovers 32. Because the intermediate values were computed in floating point, that check confirms the rounding has not disturbed a result that ought to be exact.
A result that is not a whole number
Compute the logarithm of 10 in base 3. Since 10 lies between 9 and 27, the answer must fall between 2 and 3.
Inputs Base b = 3, Value x = 10
- Expression log₃(10)
- Change of base logₐ(x) = ln(x) / ln(a) = 2.30259 / 1.09861
- Result = 2.0959
- Check 3^2.0959 ≈ 10
Result log₃(10) = 2.0959
The result is a little over 2, closer to 2 than to 3 because 10 is much nearer 9 than 27. Bracketing between the neighbouring whole powers is a good sanity check on any logarithm before reading the decimals.
This is the ordinary case. Whole-number logarithms only occur when the value happens to be an exact power of the base, which textbook examples select for and real data almost never provides.
Reading the result
Where the result is negative
Whenever the value is smaller than 1, with a base above 1. Reaching a fraction requires a negative exponent, since a positive one only makes a base above 1 larger. A base between 0 and 1 reverses that.
A logarithm compresses multiplication into addition
The logarithm of a product is the sum of the logarithms, which is the property the whole subject was invented for. It is also why logarithmic scales make quantities spanning many orders of magnitude readable on one axis.
Precision of the answer
The result is a ratio of two floating-point values shown to six significant figures. Where it should be a whole number it comes back clean, but the verification line is the honest confirmation rather than the tidy appearance of the result.
When you would use this
Counting halvings or doublings
How many times a quantity must be halved to fall below a threshold is a base-2 logarithm. The same question in base 10 counts factors of ten, and the algorithm-analysis use of log₂ is exactly this counting.
Reading a logarithmic scale
Decibels, pH and earthquake magnitude are all logarithms of an underlying ratio. Converting between a scale reading and the physical quantity means evaluating or inverting a logarithm in the appropriate base.
Assumptions and limitations
What this calculator assumes
- The base is positive and not equal to 1, and the value is strictly positive.
- Only real logarithms are computed; complex results for negative values are out of scope.
- The answer is obtained by dividing two natural logarithms, which is exact in principle and subject to floating-point rounding in practice.
- The verification step raises the base back to the computed power and compares against the input.
Where it stops being the right tool
- One logarithm at a time: expressions combining several, or the logarithm of an expression, must be evaluated in stages.
- No symbolic answer — a result of one half is shown as a decimal rather than as a fraction.
- Logarithms of zero and of negative numbers are refused rather than returned as complex values or as negative infinity.
Common mistakes
Swapping the base and the value
Why it happens. Both fields take a number and the notation puts the base in an unusual position, subscripted and first. Swapping them produces the reciprocal of the intended answer, which is a plausible-looking number.
How to avoid it. Ask which number is being raised to a power — that is the base. The verification line settles it: it should reproduce the value, not the base.
Expecting a whole-number answer
Why it happens. Textbook examples are chosen so the value is an exact power of the base, which builds an expectation that logarithms come out clean. Almost none do.
How to avoid it. Bracket the answer between the neighbouring whole powers of the base first. If the value is not exactly one of them, the logarithm is irrational.
Taking the logarithm of a non-positive number
Why it happens. Nothing about the expression looks impossible, and other calculators return an error code or a non-finite value rather than an explanation.
How to avoid it. Check the value is above zero. No real power of a positive base is ever zero or negative, so the question has no real answer rather than a hard one.
Learn why this works
Key terms
Frequently asked questions
What is the change of base formula?
logₐ(x) = ln(x) / ln(a). It rewrites a logarithm in any base as a ratio of two natural logarithms, which is how a base other than e or 10 is evaluated at all. Any consistent base in the numerator and denominator gives the same result.
What bases and values are allowed?
The domain is a base that is positive and not equal to 1, with a strictly positive value. A base of 1 never changes, so it can reach no other number, and no real power of a positive base is ever zero or negative.
Can the result be negative?
Yes, whenever the value lies between 0 and 1 with a base greater than 1 — reaching a fraction takes a negative exponent. With a base between 0 and 1 the relationship reverses and values above 1 give negative results instead.
Why is the answer verified?
Because the calculation routes through two floating-point logarithms, and raising the base back to the computed power is an independent check that rounding has not disturbed the result. It should return the value you entered.