This set practises two lessons: the gradient and directional derivatives and Lagrange multipliers. It follows MIT's Problem Set 5, in our own words.
MIT's set has two parts. Part B holds MIT's three longer problems (19 points), for which OpenCourseWare has no solutions. All three are written out below, with hints and solutions of our own. Part A is a list of short exercises, most of them from MIT's own Supplementary Notes, which also hold their solutions. Those are not rewritten here: the last section of this page lists them and links to MIT's exercises and solutions.
MIT's sheet numbers the lectures by its Fall 2007 calendar, which counts the day of the first exam. Its "Lecture 13" (gradient, directional derivative, tangent plane) is Lecture 12 on this site and in MIT's lecture summaries, and its "Lecture 14" (Lagrange multipliers) is Lecture 13 here. Problems 1 and 2 belong to the gradient lesson and Problem 3 to the lesson on Lagrange multipliers.
How to answer#
Work each problem on paper first. Then type your result in the answer box and press Check. A number box wants a decimal number, not a fraction or a square root, and its question says how exact your value must be: keep all the digits your calculator shows while you work. Unless a box asks for more digits, give 3 significant figures in the box; an answer with only 2 significant figures may or may not be accepted. Angles are asked in degrees. A formula box takes plain typing, for example 2/(1 - lam), and accepts every correct way of writing the answer. Type lam for the multiplier . The points, and their split over the parts of a problem, are MIT's. If you are stuck, open the hints one at a time. Each part ends with its full solution. Try before you open it: an answer given after its solution was opened earns no points. Parts that ask you to explain something have a box for only a piece of them: compare the rest of your work with the solution and mark it yourself. Your score is kept in this browser only.
Two parts need a tool that calculates: part (d) of Problem 1 and part (b) of Problem 3. MIT used an applet of its own and MATLAB. Any tool will do here: a spreadsheet, a graphing calculator, a few lines of Python, or an online solver for polynomials.
Problem 1#
The largest and smallest directional derivative
The function of this problem is the one MIT also used in Problem 3 of its Problem Set 3 (Problem 3 of our Problem Set 3):
In words
f(x, y) equals x cubed minus x y squared minus 4 x squared plus 3 x plus x squared y
The point is . A direction in the plane is given by a unit vector , and the directional derivative of at in that direction is written , as in the lesson.
(a)2 points
Find the largest and the smallest value that the directional derivative of at takes as runs through all directions. Give both as decimals, to four decimal places.
Hint
The lesson writes the directional derivative as a dot product of two vectors, and then with the angle between them. Only one of the two vectors changes when turns.
Hint
Find the two partial derivatives of and put in , . The largest value is the length of the gradient.
Solution
The idea. The directional derivative is the component of the gradient along :
In words
( d f over d s ) sub u hat equals del f times u hat equals the absolute value of del f cos theta
where is the angle between and . The cosine runs from to , so the values run from to .
The partial derivatives
In words
f sub x equals 3 x squared minus y squared minus 8 x plus 3 plus 2 x y, f sub y equals minus 2 x y plus x squared
The gradient at P
At , : and .
In words
del f equals the average of minus one quarter, minus three quarters, the absolute value of del f equals the square root of 1 over 16 plus 9 over 16, end of root, equals the square root of 10 over 4 equals 0.7906
Largest and smallest
The largest value of the directional derivative is and the smallest is .
Check the result
Try two simple directions. Along the directional derivative is , and along it is . Both lie between and , and is close to the largest value, which fits: the gradient points mostly along .
(b)1 point
Say in which direction the largest value occurs, and in which direction the smallest.
Give each direction as a unit vector. For the boxes, write , as MIT does in part (d): is the angle from the positive -axis to , counterclockwise. Give in degrees between 0 and 360, to one decimal place. (In this part and the next, is this angle of , not the angle between and the gradient.)
Hint
For which angle between and is the cosine equal to ? And to ?
Hint
Both components of the gradient are negative. In which quarter of the plane does it point? A calculator's inverse tangent only returns angles between and .
Solution
The idea. By the lesson, the directional derivative is largest when points along the gradient and smallest when it points the opposite way.
The two unit vectors
Divide the gradient by its length :
In words
largest: u hat equals del f over the absolute value of del f equals the quantity the average of minus 1, minus 3, all over the square root of 10, smallest: u hat equals minus del f over the absolute value of del f equals the average of 1, 3 over the square root of 10
In decimals, the second one is .
The angles
The direction of the smallest value, , points into the first quarter of the plane, with , so , which rounds to . The direction of the largest value points the opposite way, into the third quarter: , which rounds to .
Check the result
and , the components of to three decimal places. And the dot product of with is , the largest value of part (a).
(c)1 point
Find the direction or directions in which the directional derivative of at is zero. Give them as unit vectors, and for the boxes as angles in degrees, to one decimal place.
Hint
A dot product is zero when the two vectors are perpendicular.
Hint
In the plane, is perpendicular to . How many unit vectors are perpendicular to a given vector?
Solution
The idea. exactly when is perpendicular to the gradient. In the plane there are two such unit vectors, opposite to each other.
The two unit vectors
The gradient points along (or against it). The vector is perpendicular to it, since :
In words
u hat equals plus or minus the average of 3, minus 1 over the square root of 10
The angles
These directions are a quarter turn away from the ones of part (b): for , and for . Rounded: and .
Check the result
. By the lesson these are the two directions along the level curve of through : moving along a level curve does not change .
(d)4 points
Now find the same answers by experiment. MIT's students used an applet on the course's own website (the "directional derivatives" view of the applets at math.mit.edu/18.02/applets). It shows the contour plot of with the level curve through a movable point in blue, the gradient there in purple and a direction in yellow that can be turned, and it prints the value of the directional derivative. The students clicked as close to as they could. MIT accepts a point such as , as long as the point used is written down.
If you can run that applet, use it as MIT describes. Our version of the experiment, for any tool that calculates, is this. Take the point and the small step , and for a direction angle compute
In words
Q( theta ) equals the quantity f of the quantity x nought plus h cos theta, y nought plus h sine theta, minus f( x nought, y nought ), all over h
This is the change of over a short walk of length in the direction , divided by the length of the walk: an estimate of the directional derivative at . (The name and the choice of are ours.) Let run from 0° to 360°, first in large steps and then in steps of 1° near the interesting places. Find the largest and smallest values and the angles at which they occur, and the angles at which the value passes through zero.
Then state, for the directions of parts (b) and (c), how the direction lies with respect to the level curve through the point and to the gradient vector there.
Hint
In a spreadsheet: one column with in degrees, one with in radians, one with . First compute once.
Hint
The point has moved a little, so the numbers will differ a little from parts (a) to (c). To see whether your experiment is right, compute the gradient at with the formulas of part (a).
Solution
The idea. The experiment measures the directional derivative without any formula for it. It must agree with , with the gradient taken at the point actually used.
The experiment
. Some values of with :
| 0° | 69° | 90° | 159° | 160° | 180° | 249° | 250° | 270° | 339° | 340° | |
|---|---|---|---|---|---|---|---|---|---|---|---|
The largest value is about , near . The smallest is about , near to . The value passes through zero between 159° and 160°, and again between 339° and 340°.
Compare with the gradient
With the partial derivatives of part (a), at :
In words
del f equals the average of minus 0.2896, minus 0.7701, the absolute value of del f equals 0.8228
The gradient points at the angle . So the exact answers at this point are: largest value at , smallest value at , and zero at and . The experiment agrees to within about in the values. That small difference is the price of a step that is small but not zero.
The geometry
For part (b): the directional derivative is largest when lies along the gradient vector, and smallest when it points exactly the opposite way. In both cases is at right angles to the level curve through the point.
For part (c): the directional derivative is zero when is tangent to the level curve, in either of its two directions. Then is at right angles to the gradient.
On MIT's applet this reads: largest when the yellow arrow lies on the purple one, zero when the yellow arrow lies along the blue curve.
Check the result
The angles of the experiment fit together as they should: from to to to is a quarter turn each time. Compared with the point of parts (a) to (c), every angle is about 2° smaller ( against ) and the largest value is a little larger ( against ): moving the point by in each coordinate changes the gradient noticeably. That is why MIT asks you to record the point you used.
Problem 2#
Downhill to a level surface, by linear approximation
This problem is about the function of three variables
In words
g(x, y, z) equals x squared plus y z
and the point . (The name is ours.)
(a)2 points
Find the direction from in which decreases fastest. Give it as a unit vector.
Hint
The lesson says in which direction a function increases fastest. Where is the directional derivative most negative?
Hint
The gradient of has three components, , and . Take care with and : the derivative of with respect to is .
Solution
The idea. The directional derivative is most negative when points opposite to the gradient.
The gradient
In words
del g equals the average of g sub x, g sub y, g sub z equals the average of 2 x, z, y, del g(2, minus 1, 1) equals the average of 4, 1, minus 1
Its length is .
The direction
In words
u hat equals minus del g over the absolute value of del g equals the quantity the average of minus 4, minus 1, 1, all over the square root of 18
Check the result
The directional derivative in this direction is : minus the length of the gradient, the most negative value possible. The vector would come from the gradient , with and exchanged.
(b)3 points
At the value of is not 2. Follow the straight line from in the direction of part (a), and use the linear approximation to estimate where on it . That point is an estimate of the point closest to on the surface .
Do this without a calculator, and write the coordinates as fractions. Then use a calculator to find at your point: it should come out reasonably close to 2. For the boxes, turn your fractions into decimals, to four decimal places.
Hint
What is at ? By how much must it change?
Hint
Along the line, after a distance , the linear approximation says that has changed by about the directional derivative times .
Hint
The displacement is the distance times the unit vector of part (a). The two square roots multiply to a whole number.
Solution
The idea. Near the function is close to its linear approximation, whose level surfaces are planes perpendicular to . The nearest point of such a plane is reached by going straight along the gradient, here against it, because must go down.
How far g must change
. To reach the change must be .
The distance along the line
A point of the line at distance from is . By part (a) the directional derivative along the line is , so the linear approximation gives
In words
capital delta g is approximately ( d g over d s ) sub u hat s equals minus the square root of 18 s equals minus 1 which gives s equals 1 over the square root of 18
The point
The displacement is :
In words
(x, y, z) is approximately the quantity 2 minus 4 over 18, minus 1 minus 1 over 18, 1 plus 1 over 18, equals the quantity 16 over 9, minus 19 over 18, 19 over 18
In decimals: .
The value of g there
In words
g equals ( 16 over 9 ) squared minus ( 19 over 18 ) squared equals 1024 over 324 minus 361 over 324 equals 663 over 324 equals 2.0463
Reasonably close to 2, as MIT promises.
Check the result
The error can be found exactly. Write the points of the line as . Then . The linear approximation keeps , which is 2 at . The term it drops is , exactly the amount by which misses 2.
Problem 3#
The closest point, exactly, with a Lagrange multiplier
Problem 2(b) estimated the point of the surface that is closest to . Now find that point without the linear approximation.
(a)2 points
Use the method of Lagrange multipliers to write down the system of equations that the closest point satisfies. (MIT's hint: it is easier to minimise the square of the distance.)
Write the multiplier on the side of the constraint, , as the lesson does.
Hint
What is the square of the distance from to ? That is the function to minimise. The constraint is with the of Problem 2.
Hint
The gradient of is in Problem 2(a). Three components give three equations, and the constraint is the fourth.
Solution
The idea. The point that makes the distance smallest also makes its square smallest, and the square has no root in it. Minimise it among the points with .
The function and the constraint
In words
minimise f(x, y, z) equals the quantity x minus 2, all squared plus the quantity y plus 1, all squared plus the quantity z minus 1, all squared subject to g(x, y, z) equals x squared plus y z equals 2
The Lagrange equations
The lesson's condition is
In words
del f equals lambda del g
Here and . Component by component, and with the constraint:
In words
2 the quantity x minus 2, equals 2 lambda x, 2 the quantity y plus 1, equals lambda z, 2 the quantity z minus 1, equals lambda y, x squared plus y z equals 2
Check the result
There are four equations for the four unknowns , , and . If were zero, the first three equations would give , the point itself. But there, so the fourth equation fails: the multiplier is not zero, and the closest point is not .
(b)4 points
Solve the equations, and give the closest point to four decimal places. Then compare with Problem 2(b): was each coordinate of the estimate within of the exact one?
MIT suggests this route. Add the second and third equations, and show that either or . In the case , use the first three equations to write , and in terms of , and put those into the constraint. After the denominators are cleared, an equation of degree 4 for is left. Solve it with a calculator or a computer. (MIT names MATLAB's command roots; any solver for polynomials does the same.) It should have two real roots. Last, look at the case . MIT's sheet says that it gives points further away from : see what you find.
The boxes follow this route. Write the equation of degree 4 with the coefficient in front of .
Hint
Add the left sides and the right sides of the second and third equations. Both sides contain .
Hint
With the second equation holds only and . The first holds only and .
Hint
After substituting, multiply the constraint by both squared denominators. The right side becomes the square of a product of two brackets: multiply the two brackets first, then square.
Hint
Each real root gives one point. Compare their distances to .
Solution
The idea. The second and third equations are alike with and exchanged. Adding them splits the problem into two cases, and in the main case everything can be written with alone.
Two cases
Adding and gives :
In words
the quantity 2 minus lambda, the quantity y plus z, equals 0 which gives z equals minus y or lambda equals 2
The case : everything in terms of
The first equation is , so . With the second equation is , so . (Neither bracket can be zero: would turn the first equation into , and would turn the second into .)
In words
x equals 2 over the quantity 1 minus lambda, y equals minus 2 over the quantity 2 plus lambda, z equals 2 over the quantity 2 plus lambda
The third equation, , becomes with : the second equation again, so it adds nothing.
The equation for λ
Put these into the constraint , where :
In words
4 over the quantity 1 minus lambda, all squared minus 4 over the quantity 2 plus lambda, all squared equals 2
Multiply by and divide by 2. On the left, . On the right, , and its square is . Bringing everything to one side:
In words
lambda to the power 4 plus 2 lambda cubed minus 3 lambda squared minus 16 lambda minus 2 equals 0
Its real roots and their points
A polynomial solver gives two real roots, and , and two that are not real. With the formulas for , and :
| distance to | ||||
|---|---|---|---|---|
The case
With the first equation is , so . The second is , so (the third says the same). The constraint becomes :
In words
y squared plus y plus 2 equals 0, discriminant 1 minus 8 equals minus 7
The discriminant is negative, so no real satisfies it. This case gives no point at all. (MIT's sheet asks to check that this case yields solutions further away. There are none to compare: with multiplying , the convention that makes the two cases come out as or , the case is empty.)
The closest point
The Lagrange equations have exactly two real solutions, the two rows of the table. The first is the nearer one by far:
In words
(x, y, z) equals the quantity 1.7725, minus 1.0686, 1.0686, lambda equals minus 0.1283, distance 0.2473
(Our remark, as the lesson warns that the method does not say which solution is a minimum: a closest point does exist, because points of the surface far from the origin are also far from , and it must satisfy the Lagrange equations, because is zero only at the origin, which is not on the surface. So the closest point is one of the two solutions, and comparing distances picks the first.)
Compare with Problem 2(b)
The estimate was . The differences from the exact point are in and in and in . So was within , and and were not, though they missed by only a little more. The estimate went straight along the gradient at , but the surface is curved, and the line from to the true closest point is perpendicular to the surface at that point, not at .
Check the result
The point is on the surface: , which is 2 up to the rounding of the coordinates. The two gradients are parallel there: and , and the ratios and are both , the multiplier. The distance is a little more than the of the linear estimate. That fits: along the line of Problem 2(b) the estimated point, with , had not yet reached the surface.
More practice: MIT's own solved exercises#
Part A of MIT's Problem Set 5 (8 points at MIT, not scored here) is a list of short exercises from the problems section of MIT's "18.02 Supplementary Notes and Problems", which is on MIT OpenCourseWare under the same licence as the rest of the course, with solutions to the exercises that are not marked with a star. They are not rewritten here: open the exercises (section 2, Partial differentiation), try them, then compare with MIT's solutions.
An exercise number such as 2D-3 means section 2, group D, exercise 3; the letters after it are its parts. MIT assigned these, lecture by lecture (with this site's lecture numbers):
| For | Exercises in section 2 of the Notes |
|---|---|
| Lecture 12: the gradient, directional derivatives and tangent planes | 2D-1a, b, e, 2D-2b, 2D-3a, c, 2D-8, 2D-9; 2E-7 |
| Lecture 13: Lagrange multipliers | 2I-1, 2I-3 |
MIT's list also names sections of the course textbook to read (Edwards and Penney, Multivariable Calculus, 6th edition). The textbook is not openly licensed and is not used on this site, so they are not part of this page.