Free preview
189 lessons
Essential Calculus for ML
Free preview
Essential Calculus for ML · 189 lessons
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 rate as
At a point , in which direction does rise fastest?
Every unit direction has its own rate , and only the direction varies from one rate to the next. There are infinitely many directions, so we cannot compare the rates by evaluating one direction at a time. We need a formula for the rate in which the direction appears only through one angle.
Every one of those rates is a dot product, and the dot product also has a geometric form: the two lengths multiplied by the cosine of the angle between the vectors. Writing for the angle between and ,
A direction is a unit vector, so and the second length drops out:
At a fixed point is a fixed number, so turning the direction changes only , which takes every value from to .
Move the slider to turn the unit direction
Here
At a point where , find the rate of change of at in a unit direction at to , and in a unit direction at to it.
Solution
Both directions are unit vectors, so each rate is the length of the gradient multiplied by the cosine of the angle:
The length is the same for both directions, because the point is fixed. Only changes.
At we have , so
and rises at per unit of distance in that direction.
At we have , so
and neither rises nor falls in that direction.
Practice questions
4 questions
At a point where , two unit directions make angles and with . How do the rates of change of at in these two directions compare?
Select the correct answer:
+ 3 more questions
Steepest ascent is along the gradient
We can now find the rate of change of in any unit direction, and we can compute at any point. Together they answer the question of which direction makes rise fastest, and the answer is the gradient itself.
At each point where , the direction of is the direction of steepest ascent, and its length is the rate of steepest ascent. This holds at one point at a time: changes from point to point, and the direction of steepest ascent changes with it.
The reason is the formula . At a fixed point only changes, so the largest and smallest rates come from the largest and smallest values of :
| Rate | Direction of | ||
|---|---|---|---|
| , the largest | along | ||
| , the smallest | along |
At a point where , both directions and their rates come from the gradient alone:
Procedure
The board below draws the gradient at a point and then the two unit directions it gives.
The gradient at
A unit direction
For , find the unit directions of steepest ascent and steepest descent at , and the rate of change of in each.
Solution
First we compute the gradient at the point. The power rule gives the first partials, and substituting and turns them into numbers:
Next we compute the length of the gradient:
This length is the largest rate of change at , so in the direction of steepest ascent rises at per unit of distance. Dividing the gradient by its length gives that direction as a unit vector:
Steepest descent is the opposite unit direction, so we negate both components:
In this direction the rate of change is , so falls at per unit of distance.
Practice questions
4 questions
At a function has . In which unit direction does rise fastest at that point, and how fast does it rise there?
Select the correct answer:
+ 3 more questions
The gradient on a contour plot
A contour plot usually comes with no formula for , but it still shows which way points at any point.
At a point on a contour, has the same value all along that contour, so the rate of change along it is zero. In a unit direction at angle to the gradient the rate is , which, when the gradient is not zero, is zero only at . So the gradient crosses the contour at a right angle. Of the two directions at a right angle, it is the one pointing towards the higher levels, because the gradient is the direction of steepest ascent.
Theorem
At a point where the gradient is not zero, crosses the contour through at a right angle and points towards the higher levels.
The contour plot shows one surface at the levels
ML Context
Gradient descent steps along , so on a contour plot of the loss each step leaves the contour it starts on at a right angle.
Practice questions
5 questions
The contour plot of a function is shown below, with the point marked on one of its contours and four arrows drawn from . Which arrow points along ?
Select the correct answer:
+ 4 more questions