Article
Logarithm: Formula, Change of Base and Examples
A logarithm answers the question: to what power must the base be raised to get a given number? This article explains the definition, the change of base formula, the rules of logarithms and four worked examples. You can test your own numbers in the logarithm calculator.
Last updated:
Special cases are the common logarithm and the natural logarithm. The inverse operation is exponentiation.
The definition of a logarithm
The logarithm with base b of a number x, written log_b(x), is the exponent y for which b^y = x. The number x must be positive, and the base b must be positive and not equal to 1. A logarithm is therefore the inverse of exponentiation.
log_b(x) = y when b^y = x
conditions: x > 0, b > 0, b ≠ 1
example: log₂(8) = 3, because 2³ = 8
| Logarithm | Result | Check |
|---|---|---|
| log_2(8) | 3 | 2^3 = 8 |
| log_10(1000) | 3 | 10^3 = 1000 |
| log_2(0.25) | −2 | 2^−2 = 0.25 |
| log_2(1) | 0 | 2^0 = 1 |
| log_2(16) | 4 | 2^4 = 16 |
| log_5(25) | 2 | 5^2 = 25 |
| log_3(27) | 3 | 3^3 = 27 |
| log_10(100) | 2 | 10^2 = 100 |
For x ≤ 0 and for base 1 a real logarithm does not exist.
Try it with an example
Example: the base-2 logarithm of 1000, that is, the power to which 2 must be raised to get 1000. The numbers are already stored in the link to the calculator.
- Number x
- 1000
- Base b
- 2
- Result
- log₂(1000) ≈ 9.9658
Open the calculator with these numbers
The calculator reads the values from the page address and shows the result right away. You can change them freely.
How the calculator works
The calculator computes log_b(x) = ln x ÷ ln b for x > 0 and a base b > 0 with b ≠ 1. Next to the result it shows ln x, ln b, the common logarithm of x and a check that b raised to the result gives x. For x ≤ 0 or b = 1 it reports an error, because the logarithm is not defined among real numbers in those cases. You always enter the base yourself, so the ambiguity of the notation “log” does not arise.
The change of base formula
Most calculators know only the common and the natural logarithm, but every logarithm can be written with them. The change of base formula says log_b(x) = ln(x) ÷ ln(b), or equally log(x) ÷ log(b).
log_b(x) = ln(x) ÷ ln(b)
example: log₂(8) = ln 8 ÷ ln 2 = 2.0794 ÷ 0.6931 = 3
In the logarithm calculator you simply enter the number and then the base. For other variants use the logarithm of any base calculator.
How to calculate a logarithm step by step
Write the question as b^y = x. For log₂(16) you ask: to what power must 2 be raised to get 16? The answer is 4, because 2⁴ = 16.
When the result is not obvious, use the change of base formula. In the calculator you enter the number x and the base b, and the result comes with the check b^y = x. For numbers below 1 the result is negative: log₂(0.25) = −2, because 2^(−2) = 0.25.
Rules of logarithms
log_b(x · y) = log_b(x) + log_b(y)
log_b(x ÷ y) = log_b(x) − log_b(y)
log_b(x^k) = k · log_b(x)
log_b(b) = 1, log_b(1) = 0
The first rule gives, for example, log₂(8 · 4) = log₂(8) + log₂(4) = 3 + 2 = 5, which matches 2⁵ = 32. You can compute powers in the power calculator and the inverse of the natural logarithm in the exponential function calculator.
Common logarithm, natural logarithm and log 100
The common logarithm has base 10, so log(100) = 2 and log(1000) = 3. You can compute it in the common logarithm calculator. The natural logarithm has base e ≈ 2.71828 and is available in the natural logarithm calculator.
| Notation | Base | Example |
|---|---|---|
| log(x) | 10 | log(100) = 2 |
| ln(x) | e ≈ 2.71828 | ln(e) = 1 |
| log₂(x) | 2 | log₂(8) = 3 |
What are log 10, ln and log2?
| Notation | Base | Examples |
|---|---|---|
| log x (or lg x) | 10 (common logarithm) | log 10 = 1, log 100 = 2, log 1000 = 3 |
| ln x | e ≈ 2.71828 (natural logarithm) | ln e = 1, ln 1 = 0, ln 10 ≈ 2.3026 |
| log₂ x (log2 in code) | 2 | log₂ 8 = 3, log₂ 1024 = 10, log₂ 1000 ≈ 9.9658 |
The notation “log” without a base usually means the common logarithm, but in programming and in some textbooks it means the natural logarithm. Always check which base a given source uses.
The base-2 logarithm answers the question of how many times you must double 1 to reach a given number. For 1000 the result is 9.9658, so after 10 doublings you pass 1000 (2¹⁰ = 1024). You can also compute the common and natural logarithms in separate calculators: common logarithm and natural logarithm ln.
Where logarithms are useful
Compound interest. The doubling time of capital at 5% annual interest is log₁.₀₅(2) ≈ 14.21 years. You can check this by entering the number 2 and the base 1.05. Savings growth is available in the compound interest calculator.
Computing. The number of bits needed to store n different values is the base-2 logarithm of n, rounded up. For 8 values that is 3 bits.
Science. Logarithmic scales describe pH, sound intensity and earthquake magnitude, among others, because they cover very large ranges of values.
Exponential equations. Solving 2^x = 20 requires a logarithm: x = log₂(20) ≈ 4.32. Percentage changes are covered in the article Percentage Change: Formula, Examples and Calculator.
Four worked examples
You can check each example in the logarithm calculator.
1. log₂(8)
A base-2 logarithm.
- Enter the number 8 and the base 2.
- Ask: to what power must 2 be raised to get 8?
- Because 2³ = 8, the result is a whole number.
- The result is 3.
2. log₁₀(1000)
The common logarithm.
- Enter the number 1000 and the base 10.
- The number 1000 is 10³.
- The exponent is the result of the logarithm.
- The result is 3.
3. log₂(0.25)
A number below 1 gives a negative result.
- Enter the number 0.25 and the base 2.
- Write 0.25 as 1/4, that is, 2^(−2).
- The exponent is −2.
- The result is −2; check: 2^(−2) = 0.25.
4. Doubling capital at 5% a year
A logarithm whose base is not a whole number.
- Enter the number 2 and the base 1.05.
- The change of base formula gives ln 2 ÷ ln 1.05.
- You compute 0.6931 ÷ 0.0488.
- The result is about 14.21 years.
Common mistakes with logarithms
- Taking the logarithm of a non-positive number — for x ≤ 0 a real logarithm does not exist.
- Using base 1 — one raised to any power gives 1, so a logarithm with base 1 is undefined.
- Swapping the number and the base — log₂(8) = 3, but log₈(2) ≈ 0.333.
- Splitting the logarithm of a sum — log(x + y) is not equal to log(x) + log(y). Only a product can be split.
- Confusing log and ln — log usually means base 10 and ln means base e.
- Skipping the check — the result y should satisfy b^y = x.
- Rounding too early — round only the final result, especially in a quotient of natural logarithms.
Frequently asked questions
How do you calculate a logarithm?
Find the exponent y for which b^y = x. For log₂(8) the result is 3, because 2³ = 8. When the result is not obvious, use ln(x) ÷ ln(b).
What is log 100?
The common logarithm of 100 is 2, because 10² = 100.
What are log 10 and log₂ 1024?
log 10 = 1 because 10¹ = 10, and log₂ 1024 = 10 because 2¹⁰ = 1024. For comparison, log 1000 = 3 because 10³ = 1000.
Does the logarithm of a negative number exist?
Not among real numbers. The argument of a logarithm must be positive, and the calculator shows an error for x ≤ 0.
Why can the base not be 1?
Because every power of 1 equals 1, so no other number can be obtained.
How do you change the base of a logarithm?
Use log_b(x) = ln(x) ÷ ln(b). For log₂(8) you get ln 8 ÷ ln 2 = 3.
What is the difference between log and ln?
Log usually means the common logarithm, with base 10, and ln means the natural logarithm, with base e ≈ 2.71828.
Can a logarithm be negative?
Yes, when the number is below 1 and the base is greater than 1. For example, log₂(0.25) = −2.
Calculate the logarithm of your own number
Enter the number and then the base in the logarithm calculator. The result includes the check b^y = x, so you can see at once whether it is correct.
For related calculations use the common logarithm, the natural logarithm or the square root calculator.