A logarithm is an exponent
Two to what power gives 8? The answer is 3, because . That answer has a name: the logarithm of 8 to base 2, written .
Rule: Definition of a logarithm
A logarithm answers one question: "what exponent?" Every log statement is an exponent statement written the other way round.
A log counts factors. because 8 is three factors of 2: three doublings, starting from 1. counts factors of 10, so . A number between 1000 and 10,000 has a log between 3 and 4: .
A log is a count, so it has no units.
| Exponential form | Log form | In words |
|---|---|---|
| 2 to the power 3 is 8 | ||
| 10 to the power 3 is 1000 | ||
| any base to the power 0 is 1 | ||
| a negative log means a number below 1 |
Try it
Python has math.log2 and math.log10 for the two common bases.
For any other base, give it as a second input: math.log(y, b). Check each row of the table.
Logs of numbers below 1
A log can be negative; its input cannot. Divide by 10 and the base-10 log drops by 1:
| 1000 | 100 | 10 | 1 | 0.1 | 0.01 | 0.001 | |
|---|---|---|---|---|---|---|---|
| 3 | 2 | 1 | 0 |
The algebra agrees: (lesson 1.4.1), so . So with a base above 1, a number above 1 has a positive log and 1 has log 0. A number between 0 and 1 has a negative log.
Keep dividing and the log keeps falling, without end. But no power of 10 is ever 0 or negative, because is always positive (lesson 1.4.2). So exists only for .
Try it
The cell rebuilds the table, then asks for the logs of 0 and .
Python refuses both with a ValueError, which the cell catches and prints.
The natural logarithm
The logarithm with base has its own name and symbol: the natural log, . It asks " to what power gives ?"
Rule: Logs and exponentials undo each other
Apply one and then the other and you are back where you started. The same holds for any base: and .
always rises, so no two inputs share an output: it passes the horizontal line test of lesson 1.1.3. So it has an inverse function, and that inverse is . Its graph is the graph of mirrored in the line .
and are mirror images in : each point on one has the partner on the other. The pair and shows a number below 1 with a negative log.
Mirroring swaps the domain and the range. takes any input and gives a positive output, so takes a positive input and gives any output. It also rises slowly: .
Try it
In Python, math.log(y) with one input is , and NumPy's version is np.log. On many calculators the log button is base 10 and ln is base .
The second line prints 4.999999999999999: a rounding error in the last digit, not a failure of the rule.
The three log rules
Logs turn multiplication into addition. Here are the first powers of 2 with their logs:
| 1 | 2 | 4 | 8 | 16 | 32 | |
|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 |
Multiplying in the top row is adding in the bottom row: , and . The product rule of exponents (lesson 1.4.1) is the reason:
Each exponent rule from lesson 1.4.1 gives one log rule in the same way.
Rule: Product rule
The log of a product is the sum of the logs.
Rule: Quotient rule
The log of a quotient is the difference of the logs.
Rule: Power rule
An exponent inside a log comes down in front as a multiplier. This is the rule you will use most: it brings an unknown exponent down where you can solve for it (lesson 1.4.4).
Two consequences are worth naming. The quotient rule with gives . And the product rule works for many factors at once, turning a product into a sum (lesson 0.2.2):
Case study 1.4.7 uses this to add up returns over time. All the rules need and . If you want to see why they must hold in general, Proof Gym stage PG2 proves them.
Try it
Each line prints both sides of one rule, using natural logs. The last line is the product rule with three factors.
The pairs agree, apart from rounding in the last digits.
Two worked examples
To expand , split it with the quotient rule. Then write (lesson 1.4.1) so the power rule can bring both exponents down:
To combine into one log, run the rules the other way. The power rule turns into , then the quotient rule joins the two logs:
Try it
The cell checks the first example at , , and the second directly.
Each line prints two values that agree to about 15 digits.
Change of base
Python and calculators give directly. For any other base, divide two natural logs.
Rule: Change of base
So , which means .
It works for a base below 1 too: , because . A base of 1 is impossible: , and the formula would divide by zero.
Any power as a power of
Since , the power-of-a-power rule gives a second form of change of base.
Rule: Powers through e
Every exponential is with stretched by the factor . For example , since . Lesson 2.3.4 uses this to differentiate .
Try it
The first two lines compute two ways. The third checks it by raising 2 to that power; it prints 9.99999934 because 3.321928 is rounded.
The last two lines check and .
Mistakes to avoid
Try it
- There is no rule for the log of a sum. , but .
- A ratio of logs is not the log of a ratio. is change of base, not .
- The power must be inside the log. is not , and , not .
- No logs of zero or negative numbers. A log itself can be negative, though: .
- The rules need positive inputs. exists, but does not.
- In Python,
math.logis . Usemath.log10for base 10.
Logarithms
0 of 11 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- means . A log is an exponent: it counts factors of .
- Logs exist only for . With , the log is positive above 1, zero at 1 and negative between 0 and 1.
- is the inverse of , and their graphs mirror in . In Python,
math.log(y); for base ,math.log(y, b). - , , , for positive and . A product of many factors becomes a sum of logs.
- Change of base: , and .
- No rule exists for .