Free preview

106 lessons

Essential Calculus for ML

Free preview

Essential Calculus for ML · 106 lessons

Master the fundamentals

No surprise gaps

Actually remember it

Skip what you know

One subscription. All learning paths included.

Our content is best on a larger screen

The derivative at a point

The limit definition

Explanation

The instantaneous rate of change at aa is the value the average rates of change over [a,b][a, b] approach as bb moves towards aa. So far we have estimated that value from a shrinking interval. We can now define it exactly.

The interval from aa to bb is what is shrinking. Call this h=bah = b - a, which means b=a+hb = a + h. Sliding bb towards aa is then the same as letting hh shrink towards 00. The average rate of change over the interval [a,b]=[a,a+h][a, b] = [a, a+h] then becomes

f(b)f(a)ba=f(a+h)f(a)h,\dfrac{f(b) - f(a)}{b - a} = \dfrac{f(a+h) - f(a)}{h},

which is called the difference quotient. It is the secant slope for a step of size hh, written in terms of that step.

The instantaneous rate of change is the value this difference quotient approaches as h0h \to 0. That value, taken as a limit, is the derivative of ff at aa.

The derivative at a point

Definition

The derivative of ff at aa, written f(a)f'(a), is

f(a)=limh0f(a+h)f(a)h,f'(a) = \lim\limits_{h \to 0} \dfrac{f(a+h) - f(a)}{h},

provided the limit exists.

123−1−21234−1
a
a+h
The blue curve is the graph of f(x)=x2. The red tangent line touches it at the red point a; its slope is f(a). Drag the purple square a+h towards a to shrink h towards 0, and watch the green secant rotate onto the tangent.
Difference quotient for step h=1.00: f(a+h)f(a)h=3.00
Derivative f(a)=2.00 (the slope the quotient settles on as h0)

Example

For f(x)=x26xf(x) = x^2 - 6x, simplify the difference quotient at a=4a = 4 to a single expression in hh.

Solution

The difference quotient at a=4a = 4 is

f(4+h)f(4)h.\dfrac{f(4 + h) - f(4)}{h}.

We expand f(4+h)f(4 + h):

f(4+h)=(4+h)26(4+h)=16+8h+h2246h=8+2h+h2.\begin{align*} f(4 + h) &= (4 + h)^2 - 6(4 + h) \\ &= 16 + 8h + h^2 - 24 - 6h \\ &= -8 + 2h + h^2. \end{align*}

Since f(4)=1624=8f(4) = 16 - 24 = -8, the numerator is

f(4+h)f(4)=(8+2h+h2)(8)=2h+h2.\begin{align*} f(4 + h) - f(4) &= (-8 + 2h + h^2) - (-8) \\ &= 2h + h^2. \end{align*}

Every term in the numerator carries a factor of hh, so we cancel it against the hh in the denominator:

2h+h2h=2+h.\dfrac{2h + h^2}{h} = 2 + h.

The difference quotient for f(x)=x26xf(x) = x^2 - 6x at a=4a = 4 is 2+h2 + h.

Practice questions

4 questions

For f(x)=2x+1f(x) = 2x + 1, form and simplify the difference quotient at a=1a = 1, giving a single expression in hh.

Select the correct answer:

+ 3 more questions

Computing the derivative from the definition

Explanation

The derivative f(a)f'(a) is the limit of the difference quotient f(a+h)f(a)h\dfrac{f(a+h) - f(a)}{h} as h0h \to 0. Computing it means evaluating that limit.

We cannot evaluate the limit by setting h=0h = 0 in the difference quotient directly: that gives 00\dfrac{0}{0}, which has no value. Simplifying the difference quotient first clears this, leaving an expression where letting h0h \to 0 is an ordinary substitution.

Computing f(a)f'(a) from the definition

Procedure

For a polynomial ff:

  1. Form the difference quotient f(a+h)f(a)h\dfrac{f(a+h) - f(a)}{h}, expanding f(a+h)f(a+h).
  2. Simplify the numerator so that every remaining term carries a factor of hh.
  3. Cancel the common factor hh from numerator and denominator.
  4. Let h0h \to 0 in the simplified expression.

The result is a single number: the exact instantaneous rate of change of ff at aa, and the slope of the tangent line there.

Example

For f(x)=x2+3xf(x) = x^2 + 3x, compute f(2)f'(2) from the limit definition.

Solution

We are working at a=2a = 2, so the derivative is

f(2)=limh0f(2+h)f(2)h.f'(2) = \lim\limits_{h \to 0} \dfrac{f(2+h) - f(2)}{h}.

We form the difference quotient, expanding f(2+h)f(2+h). Replacing xx with 2+h2+h in f(x)=x2+3xf(x) = x^2 + 3x:

f(2+h)=(2+h)2+3(2+h)=4+4h+h2+6+3h=h2+7h+10.\begin{align*} f(2+h) &= (2+h)^2 + 3(2+h) \\ &= 4 + 4h + h^2 + 6 + 3h \\ &= h^2 + 7h + 10. \end{align*}

The fixed value is f(2)=22+3(2)=10f(2) = 2^2 + 3(2) = 10. Substituting both into the difference quotient gives

f(2+h)f(2)h=(h2+7h+10)10h=h2+7hh.\begin{align*} \dfrac{f(2+h) - f(2)}{h} &= \dfrac{(h^2 + 7h + 10) - 10}{h} \\ &= \dfrac{h^2 + 7h}{h}. \end{align*}

Now we simplify the numerator so that every remaining term carries a factor of hh. The constants have already cancelled, and h2+7h=h(h+7)h^2 + 7h = h(h + 7):

h2+7hh=h(h+7)h.\dfrac{h^2 + 7h}{h} = \dfrac{h(h + 7)}{h}.

Substituting h=0h = 0 at this stage would give 00\dfrac{0}{0}, so we cancel the common factor hh first, which is valid because h0h \neq 0 as it approaches 00:

h(h+7)h=h+7.\dfrac{h(h + 7)}{h} = h + 7.

Finally we let h0h \to 0 in the simplified expression:

f(2)=limh0(h+7)=7.f'(2) = \lim\limits_{h \to 0} (h + 7) = 7.

So f(2)=7f'(2) = 7: the instantaneous rate of change of ff at x=2x = 2 is 77.

Practice questions

4 questions

For f(x)=x2f(x) = x^2, compute f(3)f'(3) from the limit definition.

Select the correct answer:

+ 3 more questions

Equation of the tangent line

Explanation

The tangent line to the graph of ff at (a,f(a))(a, f(a)) has slope f(a)f'(a), the derivative at aa. Knowing the slope and a point on the line, we can write down its equation.

Slope and gradient

Tip

The slope of the tangent at a point is also called the gradient of the curve there. The two terms are interchangeable, and much of the literature uses "gradient".

On that line, the slope between the point of tangency (a,f(a))(a, f(a)) and any other point (x,y)(x, y) must equal f(a)f'(a). This can be written as:

yf(a)xa=f(a),\dfrac{y - f(a)}{x - a} = f'(a),

and multiplying through by xax - a gives its equation.

Equation of the tangent line at (a,f(a))(a, f(a))

Definition

The tangent line to the graph of ff at (a,f(a))(a, f(a)) has equation

yf(a)=f(a)(xa).y - f(a) = f'(a)(x - a).

The two ingredients are the slope f(a)f'(a) and the point (a,f(a))(a, f(a)). Both come from the function and the value aa.

Writing the equation of the tangent line

Procedure

For a function ff at x=ax = a:

  1. Compute the slope f(a)f'(a) from the limit definition.
  2. Compute the yy-coordinate f(a)f(a) of the point of tangency.
  3. Substitute f(a)f'(a) and f(a)f(a) into yf(a)=f(a)(xa)y - f(a) = f'(a)(x - a).

The tangent line equation can be left in this form, or rearranged into y=mx+cy = mx + c.

123−1−21234−1
(a,f(a))
The blue curve is the graph of f. The red tangent line touches it at the point (a,f(a)), and its slope is f(a).

Example

For f(x)=x24xf(x) = x^2 - 4x, find the equation of the tangent line at x=1x = 1.

Solution

The tangent line needs two ingredients: its slope f(1)f'(1) and the point of tangency (1,f(1))(1, f(1)).

The point of tangency is (1,3)(1, -3), since f(1)=14=3f(1) = 1 - 4 = -3. The slope is the derivative f(1)=2f'(1) = -2.

Computing the slope f(1)f'(1) from the definition

Details

Now we substitute the slope f(1)=2f'(1) = -2 and the point (1,3)(1, -3) into the tangent line equation:

yf(a)=f(a)(xa)y - f(a) = f'(a)(x - a)

which gives:

y(3)=2(x1).y - (-3) = -2(x - 1).

We rearrange into slope-intercept form:

y+3=2x+2y=2x1.\begin{align*} y + 3 &= -2x + 2 \\ y &= -2x - 1. \end{align*}

The tangent line to ff at x=1x = 1 is y=2x1y = -2x - 1.

Practice questions

4 questions

For f(x)=x2+2xf(x) = x^2 + 2x, the derivative at x=1x = 1 is f(1)=4f'(1) = 4. What is the equation of the tangent line to ff at x=1x = 1?

Select the correct answer:

+ 3 more questions