SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons

Level 1, Precalculus 1.4 Exponents and logarithms Lesson 3 of 7

ConceptLesson 1.4.3 in Level 1, Precalculus. About 25 minutes.

Logarithms and their rules

A logarithm is an exponent

Two to what power gives 8? The answer is 3, because 23=82^3 = 8. That answer has a name: the logarithm of 8 to base 2, written log⁡28=3\log_2 8 = 3.

Rule: Definition of a logarithm

log⁡by=xmeansbx=y(b>0, b≠1, y>0)\begin{gathered} \log_b y = x \quad \text{means} \quad b^x = y \\ (b > 0,\ b \neq 1,\ y > 0) \end{gathered}

A logarithm answers one question: "what exponent?" Every log statement is an exponent statement written the other way round.

A log counts factors. log⁡28=3\log_2 8 = 3 because 8 is three factors of 2: three doublings, starting from 1. log⁡10\log_{10} counts factors of 10, so log⁡101000=3\log_{10} 1000 = 3. A number between 1000 and 10,000 has a log between 3 and 4: log⁡105000≈3.699\log_{10} 5000 \approx 3.699.

A log is a count, so it has no units.

Exponential formLog formIn words
23=82^3 = 8log⁡28=3\log_2 8 = 32 to the power 3 is 8
103=100010^3 = 1000log⁡101000=3\log_{10} 1000 = 310 to the power 3 is 1000
50=15^0 = 1log⁡51=0\log_5 1 = 0any base to the power 0 is 1
2−2=142^{-2} = \tfrac{1}{4}log⁡214=−2\log_2 \tfrac{1}{4} = -2a 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.

⌘/Ctrl + Enter runs the cell

Logs of numbers below 1

A log can be negative; its input cannot. Divide by 10 and the base-10 log drops by 1:

yy10001001010.10.010.001
log⁡10y\log_{10} y3210−1-1−2-2−3-3

The algebra agrees: 0.01=10−20.01 = 10^{-2} (lesson 1.4.1), so log⁡100.01=−2\log_{10} 0.01 = -2. 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 10x10^x is always positive (lesson 1.4.2). So log⁡by\log_b y exists only for y>0y > 0.

Try it

The cell rebuilds the table, then asks for the logs of 0 and −5-5.

Python refuses both with a ValueError, which the cell catches and prints.

⌘/Ctrl + Enter runs the cell

The natural logarithm

The logarithm with base ee has its own name and symbol: the natural log, ln⁡y=log⁡ey\ln y = \log_e y. It asks "ee to what power gives yy?"

Rule: Logs and exponentials undo each other

ln⁡(ex)=xeln⁡y=yln⁡e=1ln⁡1=0\begin{gathered} \ln\left(e^{x}\right) = x \qquad e^{\ln y} = y \\ \ln e = 1 \qquad \ln 1 = 0 \end{gathered}

Apply one and then the other and you are back where you started. The same holds for any base: log⁡b(bx)=x\log_b(b^x) = x and blog⁡by=yb^{\log_b y} = y.

exe^x 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 ln⁡\ln. Its graph is the graph of exe^x mirrored in the line y=xy = x.

exe^x and ln⁡x\ln x are mirror images in y=xy = x: each point (a,b)(a, b) on one has the partner (b,a)(b, a) on the other. The pair (−1,1e)(-1, \frac{1}{e}) and (1e,−1)(\frac{1}{e}, -1) shows a number below 1 with a negative log.

Mirroring swaps the domain and the range. exe^x takes any input and gives a positive output, so ln⁡x\ln x takes a positive input and gives any output. It also rises slowly: ln⁡1000≈6.9078\ln 1000 \approx 6.9078.

Try it

In Python, math.log(y) with one input is ln⁡y\ln y, and NumPy's version is np.log. On many calculators the log button is base 10 and ln is base ee.

The second line prints 4.999999999999999: a rounding error in the last digit, not a failure of the rule.

⌘/Ctrl + Enter runs the cell

The three log rules

Logs turn multiplication into addition. Here are the first powers of 2 with their logs:

yy12481632
log⁡2y\log_2 y012345

Multiplying in the top row is adding in the bottom row: 4×8=324 \times 8 = 32, and 2+3=52 + 3 = 5. The product rule of exponents (lesson 1.4.1) is the reason:

8×4=23×22=23+2=32solog⁡2(8×4)=3+2=log⁡28+log⁡24\begin{aligned} 8 \times 4 &= 2^3 \times 2^2 = 2^{3+2} = 32 \\ \text{so}\quad \log_2 (8 \times 4) &= 3 + 2 \\ &= \log_2 8 + \log_2 4 \end{aligned}

Each exponent rule from lesson 1.4.1 gives one log rule in the same way.

Rule: Product rule

log⁡b(xy)=log⁡bx+log⁡by\log_b(xy) = \log_b x + \log_b y

The log of a product is the sum of the logs.

Rule: Quotient rule

log⁡b(xy)=log⁡bx−log⁡by\log_b\left(\frac{x}{y}\right) = \log_b x - \log_b y

The log of a quotient is the difference of the logs.

Rule: Power rule

log⁡b(xk)=klog⁡bx\log_b\left(x^k\right) = k \log_b x

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 log⁡b1=0\log_b 1 = 0 gives log⁡b1x=−log⁡bx\log_b \frac{1}{x} = -\log_b x. And the product rule works for many factors at once, turning a product Π\Pi into a sum Σ\Sigma (lesson 0.2.2):

ln⁡(x1x2⋯xn)=ln⁡x1+ln⁡x2+⋯+ln⁡xn\begin{gathered} \ln(x_1 x_2 \cdots x_n) \\ = \ln x_1 + \ln x_2 + \cdots + \ln x_n \end{gathered}

Case study 1.4.7 uses this to add up returns over time. All the rules need x>0x > 0 and y>0y > 0. 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.

⌘/Ctrl + Enter runs the cell

Two worked examples

To expand ln⁡x3y\ln\dfrac{x^3}{\sqrt{y}}, split it with the quotient rule. Then write y=y1/2\sqrt{y} = y^{1/2} (lesson 1.4.1) so the power rule can bring both exponents down:

ln⁡x3y=ln⁡x3−ln⁡y1/2=3ln⁡x−12ln⁡y\begin{aligned} \ln\frac{x^3}{\sqrt{y}} &= \ln x^3 - \ln y^{1/2} \\[4pt] &= 3\ln x - \tfrac{1}{2}\ln y \end{aligned}

To combine 2ln⁡6−ln⁡92\ln 6 - \ln 9 into one log, run the rules the other way. The power rule turns 2ln⁡62\ln 6 into ln⁡36\ln 36, then the quotient rule joins the two logs:

2ln⁡6−ln⁡9=ln⁡36−ln⁡9=ln⁡369=ln⁡4\begin{aligned} 2\ln 6 - \ln 9 &= \ln 36 - \ln 9 \\[4pt] &= \ln\frac{36}{9} = \ln 4 \end{aligned}

Try it

The cell checks the first example at x=2x = 2, y=5y = 5, and the second directly.

Each line prints two values that agree to about 15 digits.

⌘/Ctrl + Enter runs the cell

Change of base

Python and calculators give ln⁡\ln directly. For any other base, divide two natural logs.

Rule: Change of base

log⁡by=ln⁡yln⁡b\log_b y = \frac{\ln y}{\ln b}

So log⁡210=ln⁡10ln⁡2≈3.3219\log_2 10 = \dfrac{\ln 10}{\ln 2} \approx 3.3219, which means 23.3219≈102^{3.3219} \approx 10.

It works for a base below 1 too: log⁡0.58=ln⁡8ln⁡0.5=−3\log_{0.5} 8 = \frac{\ln 8}{\ln 0.5} = -3, because 0.5−3=80.5^{-3} = 8. A base of 1 is impossible: ln⁡1=0\ln 1 = 0, and the formula would divide by zero.

Any power as a power of ee

Since b=eln⁡bb = e^{\ln b}, the power-of-a-power rule gives a second form of change of base.

Rule: Powers through e

bx=exln⁡bb^x = e^{x \ln b}

Every exponential is exe^x with xx stretched by the factor ln⁡b\ln b. For example 2x=e0.693147x2^x = e^{0.693147x}, since ln⁡2≈0.693147\ln 2 \approx 0.693147. Lesson 2.3.4 uses this to differentiate bxb^x.

Try it

The first two lines compute log⁡210\log_2 10 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 log⁡0.58\log_{0.5} 8 and 23.5=e3.5ln⁡22^{3.5} = e^{3.5 \ln 2}.

⌘/Ctrl + Enter runs the cell

Mistakes to avoid

Try it

  1. There is no rule for the log of a sum. ln⁡(2+3)=ln⁡5≈1.609\ln(2 + 3) = \ln 5 \approx 1.609, but ln⁡2+ln⁡3≈1.792\ln 2 + \ln 3 \approx 1.792.
  2. A ratio of logs is not the log of a ratio. ln⁡xln⁡y\dfrac{\ln x}{\ln y} is change of base, not ln⁡xy\ln\dfrac{x}{y}.
  3. The power must be inside the log. (ln⁡x)2(\ln x)^2 is not 2ln⁡x2 \ln x, and ln⁡(2x)=ln⁡2+ln⁡x\ln(2x) = \ln 2 + \ln x, not 2ln⁡x2 \ln x.
  4. No logs of zero or negative numbers. A log itself can be negative, though: ln⁡0.5≈−0.6931\ln 0.5 \approx -0.6931.
  5. The rules need positive inputs. ln⁡((−3)2)=ln⁡9\ln\left((-3)^2\right) = \ln 9 exists, but 2ln⁡(−3)2 \ln(-3) does not.
  6. In Python, math.log is ln⁡\ln. Use math.log10 for base 10.
⌘/Ctrl + Enter runs the cell

Logarithms

0 of 11 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 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, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for 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

  • log⁡by=x\log_b y = x means bx=yb^x = y. A log is an exponent: it counts factors of bb.
  • Logs exist only for y>0y > 0. With b>1b > 1, the log is positive above 1, zero at 1 and negative between 0 and 1.
  • ln⁡y=log⁡ey\ln y = \log_e y is the inverse of exe^x, and their graphs mirror in y=xy = x. In Python, math.log(y); for base bb, math.log(y, b).
  • ln⁡(xy)=ln⁡x+ln⁡y\ln(xy) = \ln x + \ln y, ln⁡(x/y)=ln⁡x−ln⁡y\ln(x/y) = \ln x - \ln y, ln⁡(xk)=kln⁡x\ln(x^k) = k\ln x, for positive xx and yy. A product of many factors becomes a sum of logs.
  • Change of base: log⁡by=ln⁡y/ln⁡b\log_b y = \ln y / \ln b, and bx=exln⁡bb^x = e^{x \ln b}.
  • No rule exists for ln⁡(x+y)\ln(x + y).

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.