MathsAlgebra

Logarithm
calculator.

Work out a log in any base, or the number or base behind it, with exact answers and every step.

How it’s worked out

A logarithm answers one question: what power turns the base into your number? Writing it as a power is the definition:

logb⁡x\displaystyle \log_{b} x=y\displaystyle {}= ymeans\displaystyle \text{means}by\displaystyle b^{y}=x\displaystyle {}= x
  • b is the base. It must be positive and cannot be 1, because 1 to any power is still 1.
  • x is the number you take the log of. It must be greater than 0.
  • y is the log, the power itself. It can be any number, including negatives and fractions.

Most calculators only have two log buttons: ln, the natural log with base e (about 2.71828), and log, the common log with base 10. Any other base goes through the change-of-base formula:

logb⁡x\displaystyle \log_{b} x=ln⁡xln⁡b\displaystyle {}= \frac{\ln x}{\ln b}=log10⁡xlog10⁡b\displaystyle {}= \frac{\log_{10} x}{\log_{10} b}

It comes straight from the definition. Take the natural log of both sides of by = x. The power comes down as a factor, so y × ln b = ln x, and dividing by ln b leaves y. Any base works in place of e, which is why the common-log version gives the same answer. The working on this page shows both.

When the unknown is the base or the number, undo the power instead. The base is the yth root of x, and the number, called the antilog, is the base raised to y:

b\displaystyle b=x1y\displaystyle {}= x^{\frac{1}{y}}=xy\displaystyle {}= \sqrt[y]{x}x\displaystyle x=by\displaystyle {}= b^{y}

Some logs have an exact value. If b and x are both powers of one number, the log is a fraction. For example 8 = 2³ and 4 = 2², so 8² and 4³ are both 64, and log₈ 4 is exactly 23\tfrac{2}{3}. The tool confirms each exact answer with whole-number arithmetic, not by rounding a decimal:

LogExactDecimalWhy
log2⁡8\log_{2} 8333Whole number: 2³ = 8
log4⁡2\log_{4} 212\frac{1}{2}0.5Fraction: 4 to the power 12\tfrac{1}{2} is √4 = 2
log8⁡4\log_{8} 423\frac{2}{3}0.6667Fraction: 8² and 4³ are both 64
log10⁡0.001\log_{10} 0.001−3-3−3Negative: 0.001 is 1 over 10³
log3⁡50\log_{3} 50none3.5609No exact form: decimal only

For bases 10, 2 and e the tool uses the dedicated library routines rather than dividing two logs, and it snaps exact whole powers, so log₅ 125 shows as 3 rather than 3.0000000000000004.

Worked examples

How many guesses does a binary search need?

Maya has a sorted list of 1,000,000 customer records. Binary search checks the middle record and throws away half the list each time. The number of halvings is log₂ 1,000,000 = 19.9316.

You cannot make part of a guess, so round up: 20 comparisons always find a record. The check works: 220 = 1,048,576 covers a million, while 219 = 524,288 falls short.

Open this example in the tool

What does a pool reading of pH 7.4 mean?

Jordan tests the pool and reads pH 7.4. pH is the negative common log of the hydrogen ion concentration, so log₁₀[H⁺] = −7.4. That is a Number x problem: the antilog of −7.4 in base 10.

The answer is 10−7.4 = 3.981 × 10⁻⁸ mol/L. Pure water at pH 7 has 1 × 10⁻⁷ mol/L, about 2.51 times as much. A change of 0.4 on the pH scale is a factor of 2.51, and a full step of 1 is a factor of 10.

Open this example in the tool

What yearly growth doubles money in 10 years?

Priya's investment doubled in 10 years. If it grew by the same factor b each year, then b10 = 2, which is log base b of 2 = 10. The unknown is the base.

The 10th root of 2 gives b = ¹⁰√2 ≈ 1.0718, a rise of about 7.18% a year. The check: 1.071773 raised to the power 10 is 2.

Open this example in the tool

Reading your result

The whole part counts powers of the base. log₁₀ 4,500 is about 3.65. The 3 says 4,500 lies between 10³ and 10⁴, so it has 4 digits before the decimal point. The table under the tool shows the other half of the story: multiply x by 10 and the log goes up by exactly 1, so 45,000 gives 4.65 and 450,000 gives 5.65.

Negative logs mean a number between 0 and 1 when the base is above 1. log₁₀ 0.01 is −2 because 0.01 is 1 over 10². A log of 0 always means x = 1, and a log of 1 means x equals the base.

A base between 0 and 1 flips the signs. The curve falls instead of rising, so numbers above 1 get negative logs: log base 0.5 of 8 is −3. A negative power of a half doubles instead of halving: 0.5 to the power −3 is 2³ = 8.

Exact or decimal. Exact is the form an answer key prints: a whole number, a stacked fraction such as 12\tfrac{1}{2} or a root such as √10. Most logs are irrational, so the tool says when there is no exact form and shows the decimal. Choose 3, 6, 9 or 12 significant figures. For a log, 4 to 6 figures is plenty; for an antilog such as a concentration, 3 figures usually matches the precision of the measurement.

The rules behind these readings are in Stewart, Redlin and Watson's Precalculus, section 4.3, and the NIST Digital Library of Mathematical Functions, section 4.2.

Common mistakes

  • Pressing the wrong button. On most calculators LOG is base 10 and LN is base e. ln 20 is 2.9957, but log₁₀ 20 is only 1.301.
  • Splitting the log of a sum. log₁₀(2 + 8) is log₁₀ 10 = 1. Adding log₁₀ 2 and log₁₀ 8 gives log₁₀ 16 = 1.2041 instead, because the rule only splits a product.
  • Dividing inside the log. Change of base divides two logs: ln 8 ÷ ln 2 = 3. It is not the log of a quotient, and ln(8 ÷ 2) = ln 4 is only 1.3863.
  • Mixing up the roles. log₂ 8 = 3 means 2³ = 8. It does not mean 8³ or 3², so check which number is the base before you rewrite it as a power.
  • Taking the log of 0 or a negative number. No power of a positive base reaches 0 or goes below it, so these logs are not real numbers. The tool says so instead of returning an error code.
  • Dropping the minus sign in pH. pH 7.4 means log₁₀[H⁺] = −7.4. Using +7.4 gives a concentration that is far too large.
  • Rounding the logs too early. Keep the full values of ln x and ln b until the last division. Rounding both to one decimal place can move the answer in its second decimal place.

Questions people ask

They are the same operation with different bases. log usually means base 10, ln means base e (about 2.71828) and log₂ means base 2. They differ only by a constant factor: ln x is always about 2.302585 times log₁₀ x, and log₂ x is about 3.321928 times log₁₀ x.

Sources