CCalclabhub

Algebra

How To Calculate A Logarithm

A logarithm asks what power a base must be raised to in order to produce a given number, and it turns multiplication into addition.

Quick Answer

log_b(x) = ln(x) / ln(b)

x
The number whose logarithm you want
b
The base, which must be positive and not equal to 1
ln
Natural logarithm, the logarithm to base e
log
Common logarithm, the logarithm to base 10

The base-b logarithm of x is the power b must be raised to in order to give x. Because 10 raised to the power 3 gives 1000, the base-10 logarithm of 1000 is 3. Any base can be evaluated with the change of base rule, dividing the natural log of the number by the natural log of the base.

What Is A Logarithm?

A logarithm is the inverse of raising a number to a power. Asking for the base-10 logarithm of 1000 is the same as asking what power of ten produces 1000, and the answer is 3 because ten cubed is one thousand. Nothing about the operation is mysterious; it is a question about exponents written in reverse.

The notation log base b of x names the base explicitly. A base-10 logarithm is called the common logarithm and is often written without a base at all. A base-e logarithm, where e is 2.718281828459045, is called the natural logarithm and is written ln. A base-2 logarithm is the binary logarithm, and it counts doublings.

Only positive numbers have real logarithms. There is no power of ten that produces a negative number, and no power that produces zero, so the logarithm of either is undefined over the real numbers. The domain restriction catches people out when a formula has been rearranged and a negative value slips in.

The base must be positive and cannot be 1. A base of 1 is useless because 1 raised to any power is still 1, so no value other than 1 can ever be produced. A base between 0 and 1 works but flips the direction of the function, making larger inputs produce smaller logarithms.

The change of base rule is what makes arbitrary bases practical. Since calculators supply natural and common logarithms directly, the base-b logarithm is computed as ln of the number divided by ln of the base. That ratio is the same whichever logarithm you use on both sides, so dividing log of the number by log of the base works equally well.

Logarithms turn multiplication into addition, which is the property that made them famous. The logarithm of a product equals the sum of the logarithms, the logarithm of a quotient equals the difference, and the logarithm of a power equals the exponent multiplied by the logarithm. Before mechanical calculators, that identity let navigators and astronomers multiply large numbers by adding their logarithms in a table.

The natural logarithm earns its name because it appears whenever a quantity grows or decays in proportion to its own size. Compound interest, radioactive decay and population growth all produce expressions where the unknown sits in an exponent, and taking a natural logarithm on both sides is the standard way to bring it down where ordinary algebra can reach it.

Doubling time is a natural application. The number of doublings needed to reach a target is the base-2 logarithm of the ratio between the target and the starting value, so going from 1 to 1000 takes 9.965784284662087 doublings. Ten doublings overshoots to 1024, which is why powers of two look like round numbers in computing.

Logarithmic scales compress a huge range into a readable one. The Richter scale, decibels, pH and stellar magnitude are all logarithms, and each step on those scales multiplies the underlying quantity by a fixed factor rather than adding to it. Reading them correctly means remembering that the numbers add while the quantities multiply.

The logarithm of 1 is always zero, in every base, because any base raised to the power zero is 1. That fixed point is worth remembering as a sanity check: a logarithm that should be zero and is not signals either a wrong base or a wrong input.

Formula

log_b(x) = y means b^y = x

The logarithm is the exponent. Reading the equation backwards is often the fastest way to evaluate a simple logarithm by hand.

SymbolMeaning
xArgument
bBase
yLogarithm

log_b(x) = ln(x) / ln(b)

Divides the natural log of the number by the natural log of the base. Any logarithm works in both places, so log(x) / log(b) gives the same answer.

SymbolMeaning
xArgument
bBase
lnNatural logarithm

n = ln(target / start) / ln(2)

The base-2 logarithm of the growth ratio. It counts how many times the starting value must double to reach the target.

SymbolMeaning
SStarting value
TTarget value
nDoublings

How To Calculate A Logarithm

  1. 1

    Write the question as a power

    Log base b of x asks what power of b gives x. For log base 10 of 1000 the question is ten to what power equals one thousand, and the answer is 3.

  2. 2

    Check the argument is positive

    Only positive numbers have real logarithms. If the number is zero or negative, stop and look for an error upstream, because no power of a positive base produces such a value.

  3. 3

    Take the natural log of the number

    Use the ln key. For 1000 the natural log is 6.907755278982137. This is an intermediate value and is not the answer unless the base happens to be e.

  4. 4

    Take the natural log of the base

    For a base of 10 the natural log is 2.302585092994046. The base's logarithm is always positive when the base is greater than 1, which is the usual case.

  5. 5

    Divide and interpret

    6.907755278982137 divided by 2.302585092994046 is 3. That is the logarithm. Sanity-check it by raising the base to that power and confirming you get back the original number.

Examples

Example 1: The base-10 logarithm of 1000

Number
1000
Base
10
StepCalculationResult
Natural log of the numberln(1000)6.907755278982137
Natural log of the baseln(10)2.302585092994046
Divide6.907755278982137 / 2.3025850929940463

Result: Because 10 raised to the power 3 gives 1000, the base-10 logarithm of 1000 is 3 exactly.

Example 2: The base-2 logarithm of 1024

Number
1024
Base
2
StepCalculationResult
Natural log of the numberln(1024)6.931471805599453
Natural log of the baseln(2)0.6931471805599453
Divide6.931471805599453 / 0.693147180559945310

Result: The base-2 logarithm of 1024 is 10, which is why 1024 is the round number in computing rather than 1000.

Example 3: How many doublings to reach 1000 from 1

Number
1000
Base
2
StepCalculationResult
Natural log of the numberln(1000)6.907755278982137
Natural log of 2ln(2)0.6931471805599453
Doublings6.907755278982137 / 0.69314718055994539.965784284662087

Result: Reaching 1000 from 1 takes 9.965784284662087 doublings, so ten doublings overshoots to 1024.

Calculator

Logarithm in your base

3

Natural logarithm (base e)
6.9078
Common logarithm (base 10)
3
Check: base raised to the answer
1,000
Equivalent doublings (base 2)
9.9658

Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.

Prefer a full-width tool? Open the A Logarithm calculator page.

Common Mistakes

  • Trying to take the logarithm of zero or a negative number

    No power of a positive base produces zero or a negative value, so the logarithm is undefined over the real numbers. Encountering one almost always means an upstream sign error or a missing absolute value.

  • Using a base of 1

    One raised to any power is still 1, so the logarithm to base 1 cannot distinguish between any two arguments. Dividing by ln(1), which is zero, also produces an infinite result rather than an error message.

  • Confusing ln with log

    ln is the natural logarithm to base e, while log on most scientific calculators is the common logarithm to base 10. Using the wrong one changes the answer by a constant factor, so the result looks plausible but is wrong.

  • Assuming log(x) + log(y) equals log(x + y)

    The product rule turns a sum of logarithms into the logarithm of a product, not a sum. Writing log(x + y) is a different quantity and there is no simplification for it.

  • Forgetting that logarithms of values below 1 are negative

    The logarithm of 0.1 to base 10 is minus 1, and the logarithm of 0.5 is negative too. A negative logarithm is not an error; it simply means the argument is smaller than 1.

  • Rounding the intermediate logarithms

    Dividing one rounded logarithm by another compounds both errors. Keep full precision through the division and round only the final result, or the third decimal place can shift.

FAQ

What is a logarithm in plain terms?

A logarithm answers the question of what power a base must be raised to in order to produce a given number. The base-10 logarithm of 1000 is 3 because ten cubed is one thousand. It is the inverse operation of exponentiation.

How do I calculate a logarithm in an arbitrary base?

Use the change of base rule: divide the natural log of the number by the natural log of the base. For the base-10 logarithm of 1000, that is 6.907755278982137 divided by 2.302585092994046, which is 3.

What is the difference between ln and log?

ln is the natural logarithm to base e, where e is 2.718281828459045. log on most calculators is the common logarithm to base 10. Some programming languages use log for the natural logarithm, so check the convention before trusting a result.

Why are logarithms useful?

They turn multiplication into addition and bring exponents down to where ordinary algebra can solve for them. That is why they appear in compound interest, radioactive decay, decibels, pH and the Richter scale.

What is the logarithm of 1?

Zero, in every base. Any positive base raised to the power zero equals 1, so the logarithm of 1 is always 0. It is a useful sanity check on any logarithm calculation.

Can a logarithm be negative?

Yes. The logarithm of any number between 0 and 1 is negative, and the logarithm of a number smaller than the base is less than 1. A negative result means the argument is smaller than 1, not that anything went wrong.

References

  1. [1]Wikipedia, Logarithm — https://en.wikipedia.org/wiki/Logarithm
  2. [2]Khan Academy, Logarithms — https://www.khanacademy.org/math/algebra2/x2ec2f6f830c9fb89:logs
  3. [3]Math is Fun, Introduction to Logarithms — https://www.mathsisfun.com/algebra/logarithms.html
  4. [4]Brilliant, Change of base formula — https://brilliant.org/wiki/logarithms/