SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 2.2.1 Rate of change and the slope of a tangentConcept · 25 min
      2. 2.2.2 The derivative as a limit, and finite differencesConcept · 35 min
      3. 2.2.3 Practice set: the derivativePractice set · 20 min
      4. 2.2.4 Case study: bond price sensitivity and durationCase study · 30 min

Level 2, Single-variable calculus 2.2 The derivative Lesson 1 of 4

ConceptLesson 2.2.1 in Level 2, Single-variable calculus. About 25 minutes.

Rate of change and the slope of a tangent

What a rate of change measures

A rate of change says how fast one quantity changes as another one changes. It is the change in the output divided by the change in the input. Its units are output units per input unit.

A car that covers 150 km in 2 hours has an average speed of 150÷2=75150 \div 2 = 75 km per hour. A tank that loses 40 litres in 8 minutes drains at 40÷8=540 \div 8 = 5 litres per minute.

The Greek letter Δ\Delta (delta) is short for "change in". If the input moves from aa to bb, then Δx=b−a\Delta x = b - a is the change in input and Δy=f(b)−f(a)\Delta y = f(b) - f(a) is the change in output.

Average rate of change

Between two inputs aa and bb, the average rate of change of ff is the change in output per unit of input. On the graph it is the slope of the straight line joining the two points. That line is called a chord.

Rule: Average rate of change

ΔyΔx=f(b)−f(a)b−a\frac{\Delta y}{\Delta x} = \frac{f(b) - f(a)}{b - a}

The rise over the run between two points of the graph, exactly as for a line in lesson 1.2.1. It describes the whole interval, not any single point in it.

The chord of y=x2y = x^2 from x=1x = 1 to x=3x = 3. The run is 2, the rise is 8, so the average rate of change is 4.

For f(x)=x2f(x) = x^2 from 1 to 3, the output goes from 1 to 9. The rise is 8 over a run of 2, so the average rate is 4. On average, the output grows by 4 for each step of 1 in the input.

Rising, falling and flat

The sign of the average rate tells you the direction of the change over the interval.

  • Positive: the output ends higher. For x2x^2 from 1 to 3 the rate is 4.
  • Negative: the output ends lower. For g(x)=12xg(x) = \frac{12}{x} from 1 to 4, the output falls from 12 to 3, so the rate is 3−124−1=−3\frac{3 - 12}{4 - 1} = -3.
  • Zero: the output ends where it started. For x2x^2 from −2-2 to 2 the rate is 4−42−(−2)=0\frac{4 - 4}{2 - (-2)} = 0.

A zero average does not mean nothing happened. Between −2-2 and 2, the curve x2x^2 falls to 0 and climbs back to 4.

The order of the two points does not matter, as long as top and bottom use the same order. From 3 back to 1, x2x^2 gives 1−91−3=4\frac{1 - 9}{1 - 3} = 4 again.

The interval matters

On a curve, the average rate changes with the interval. For x2x^2 it is 3 from 1 to 2, and 5 from 2 to 3. A straight line is the exception: its average rate equals its slope on every interval.

Try it

average_rate is the formula above. The cell checks each example on this page.

Every result is a decimal (4.0, not 4) because / in Python always gives a decimal.

⌘/Ctrl + Enter runs the cell

From a chord to a tangent

A curve is steeper in some places than others, so it has no single slope. To get the slope at one point aa, take the chord from aa to a nearby point a+ha + h. Then let the gap hh shrink.

The gap hh can be negative. Then the second point sits to the left of aa, and the chord comes in from that side.

For f(x)=x2f(x) = x^2 at a=3a = 3, here are the chord slopes from both sides.

gap hh10.10.010.001
chord slope76.16.016.001
gap hh−1-1−0.1-0.1−0.01-0.01−0.001-0.001
chord slope55.95.995.999

From the right the slopes fall towards 6. From the left they rise towards 6. Both one-sided limits (lesson 2.1.2) agree, so the slope at 3 is 6.

Explore

Move the gap h towards 0 from either side and watch the chord of y = x² turn into the tangent at 3.

123450102030
Second point
(4, 16)
Chord slope
(16 − 9) ÷ 1 = 7
Tangent slope at 3
6, so the chord is off by 1

Algebra gives the same answer without a table. Expand the top, then cancel hh, which is allowed because h≠0h \neq 0:

(3+h)2−9h=6h+h2h=6+h\frac{(3 + h)^2 - 9}{h} = \frac{6h + h^2}{h} = 6 + h

As h→0h \to 0, 6+h→66 + h \to 6. You cannot put h=0h = 0 straight into the chord slope: it would read 00\frac{0}{0}. The limit is how you get past that, as in lesson 2.1.1.

Rule: Slope at a point

lim⁡h→0f(a+h)−f(a)h\lim_{h \to 0} \frac{f(a + h) - f(a)}{h}

The limit of chord slopes as the second point slides into the first, from either side. It is the slope of the tangent line: the line that touches the curve at aa and points the same way. Lesson 2.2.2 turns this into a function, the derivative.

Try it

The cell computes chord slopes for x2x^2 at 3 from the right (3+h3 + h) and from the left (3−h3 - h).

round(…, 6) hides tiny rounding errors in the last digits. Without it you would see 6.100000000000012.

⌘/Ctrl + Enter runs the cell

A second example: x3x^3 at 2

Take f(x)=x3f(x) = x^3 at a=2a = 2, where f(2)=8f(2) = 8. With h=1h = 1 the chord slope is 27−81=19\frac{27 - 8}{1} = 19. With h=0.1h = 0.1 it is 9.261−80.1=12.61\frac{9.261 - 8}{0.1} = 12.61, and with h=0.01h = 0.01 it is 12.0601.

From the left, h=−0.1h = -0.1 gives 11.41 and h=−0.01h = -0.01 gives 11.9401. Both sides settle on 12.

The algebra agrees. Expanding gives (2+h)3=8+12h+6h2+h3(2 + h)^3 = 8 + 12h + 6h^2 + h^3, so the chord slope is 12+6h+h212 + 6h + h^2. As h→0h \to 0 it tends to 12.

Try it

The same loop for x3x^3 at 2, with gaps on both sides of 0.

Compare each line with 12+6h+h212 + 6h + h^2. For h=0.1h = 0.1 that is 12+0.6+0.01=12.6112 + 0.6 + 0.01 = 12.61.

⌘/Ctrl + Enter runs the cell

The tangent line

Once you know the slope mm at aa, the tangent is the line through the point (a,f(a))(a, f(a)) with that slope.

Rule: Tangent line at a

y=f(a)+m(x−a)y = f(a) + m(x - a)

At x=ax = a this gives f(a)f(a), so the line passes through the point. Each step of 1 to the right adds mm, so its slope is mm. It is the same line as y=mx+cy = mx + c from lesson 1.2.1, with c=f(a)−mac = f(a) - ma.

For x2x^2 at 3 the tangent is y=9+6(x−3)y = 9 + 6(x - 3). Multiplying out gives y=6x−9y = 6x - 9.

The tangent to y=x2y = x^2 at (3,9)(3, 9), far away and close up. Far from 3 it drifts below the curve: at x=5x = 5 the gap is 4. Inside the dashed box around (3,9)(3, 9), enlarged, the two are hard to tell apart.

How closely the tangent copies the curve

Near aa the tangent is an excellent stand-in for the curve. Further away it drifts off. Here is x2x^2 against its tangent at 3.

xx3.13.545
curve x2x^29.6112.251625
tangent 6x−96x - 99.6121521
gap0.010.2514

The gap is the square of the distance from 3. Algebra shows why: x2−(6x−9)=(x−3)2x^2 - (6x - 9) = (x - 3)^2. Move 10 times closer to 3 and the gap shrinks 100 times.

That is why the tangent is called the best straight-line copy of a curve near a point. It lets you estimate values quickly: 3.123.1^2 is close to 6×3.1−9=9.66 \times 3.1 - 9 = 9.6. The same idea gives Newton's method (lessons 1.3.3 and 2.4.3).

A tangent does not have to stay on one side of the curve. For x3x^3 at 0, the chord slope is h3h=h2\frac{h^3}{h} = h^2, which tends to 0. So the tangent is the line y=0y = 0, and the curve crosses it at 0.

Try it

The cell compares x2x^2 with its tangent at 3, at the four inputs of the table.

The last column is the gap. Each value is (x−3)2(x - 3)^2.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. An average rate needs an interval; the slope at a point is a limit. "The rate of x2x^2 at 3" means the slope there, 6, not an average.
  2. Divide by the change in input, b−ab - a, not by bb.
  3. Keep the same order on top and bottom. f(b)−f(a)a−b\frac{f(b) - f(a)}{a - b} has the wrong sign.
  4. Do not put h=0h = 0 straight in. It gives 00\frac{0}{0}. Simplify first, then let hh shrink.
  5. Check both sides. The slope at a point exists only when both one-sided limits agree. Lesson 2.2.2 shows a corner where they do not.
  6. The tangent is only a good copy near the point. Far away it can miss badly, and it may cross the curve.

Rates of change and tangents

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

  • A rate of change is change in output per unit of input, in output units per input unit.
  • Average rate of change: f(b)−f(a)b−a\frac{f(b) - f(a)}{b - a}, the slope of the chord between two points.
  • The slope at a point is the limit of chord slopes, from both sides: lim⁡h→0f(a+h)−f(a)h\lim_{h \to 0}\frac{f(a + h) - f(a)}{h}.
  • The tangent at aa is y=f(a)+m(x−a)y = f(a) + m(x - a), with mm the slope at aa. Near aa it copies the curve closely.

Free further reading

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