APSC248 – Engineering Analysis III
Lecture 10 Gradient Vectors
(1) Gradient Vector
Recall the chain rule for multivariable function 𝑤 = 𝑓(𝑥, 𝑦, 𝑧) , where 𝑥 = 𝑥(𝑡), 𝑦 =
𝑦(𝑡), 𝑧 = 𝑧(𝑡)
𝑑𝑤 𝑑𝑥 𝑑𝑦 𝑑𝑧
= 𝑓! + 𝑓" + 𝑓#
𝑑𝑡 𝑑𝑡 𝑑𝑡 𝑑𝑡
We can rewrite this with a new notation. Define a (position) vector 𝑟⃑(𝑡) = 𝑥(𝑡)𝚤̂ +
𝑦(𝑡)𝚥̂ + 𝑧(𝑡)𝑘3. Then its derivative (velocity vector) is
𝑑𝑟⃑(𝑡) 𝑑𝑥(𝑡) 𝑑𝑦(𝑡) 𝑑𝑧(𝑡)
= 𝚤̂ + 𝚥̂ + 𝑘3
𝑑𝑡 𝑑𝑡 𝑑𝑡 𝑑𝑡
Define another vector, ∇𝑤 or ∇𝑓, as
𝜕𝑓 𝜕𝑓 𝜕𝑓 𝜕𝑓 𝜕𝑓 𝜕𝑓
∇𝑓 = 𝚤̂ + 𝚥̂ + 𝑘3 = 〈 , , 〉
𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑥 𝜕𝑦 𝜕𝑧
$% $'⃑(&)
Then $&
= ∇𝑓 ⋅ $&
. This newly defined vector ∇𝑓 = 〈𝑓! , 𝑓" , 𝑓# 〉 is called “Gradient
vector” (or Gradient) of function 𝑓(𝑥, 𝑦, 𝑧) at some point (𝑥, 𝑦, 𝑧). Gradient refers to the
derivative of functions of multivariable.
Remarks:
• At each point (𝑥, 𝑦, 𝑧), ∇𝑓 gives a vector. For a certain region of points, ∇𝑓 gives a
so called “vector field”.
• ∇𝑓 is read as “grad 𝑓”, or “gradient of 𝑤”, or “del 𝑓”. ∇ by itself is read as “del”.
• The journey of calculus, 𝑑𝑓 → 𝜕𝑓 → ∇𝑓 .
+ + +
• ∇: vector differential operator: ∇= +! 𝚤̂ + +" 𝚥̂ + +# 𝑘3
@Dr. Yang Cao Page 1
APSC248 – Engineering Analysis III
• ∇ is a linear operator. Superposition rule is satisfied,
∇(𝑐, 𝑓 + 𝑐- 𝑔) = 𝑐, ∇𝑓 + 𝑐- ∇𝑔
• Recall that function 𝑓(𝑥, 𝑦) around (𝑥. , 𝑦. ) can be approximated with a plane, i.e.,
𝑓(𝑥, 𝑦) ≈ 𝑓(𝑥. , 𝑦. ) + 𝑓! (𝑥. , 𝑦. )(𝑥 − 𝑥. ) + 𝑓" (𝑥. , 𝑦. )(𝑦 − 𝑦. )
= 𝑓(𝑥. , 𝑦. ) + ∇𝑓(𝑥. , 𝑦. ) ⋅ 〈𝑥 − 𝑥. 𝑦 − 𝑦. 〉
From point (𝑥. , 𝑦. ) to nearby point (𝑥, 𝑦) = (𝑥. + Δ𝑥, 𝑦. + Δ𝑦), we have
Δ𝑓 = 𝑓(𝑥. + Δ𝑥, 𝑦. + Δ𝑦) − 𝑓(𝑥. , 𝑦. ) ≈ ∇𝑓(𝑥. , 𝑦. ) ⋅ 〈Δ𝑥 Δ𝑦〉
Example 1: 𝑤 = 𝑓 (𝑥, 𝑦, 𝑧) = 𝑥 ! + 𝑦 ! − 2𝑧 ! + 𝑧 ln 𝑥, find ∇𝑓 and ∇𝑓 at (1,1,1)
Solution:
𝜕𝑓 𝜕𝑓 𝜕𝑓
∇𝑓 = 𝚤̂ + 𝚥̂ + 𝑘3
𝜕𝑥 𝜕𝑦 𝜕𝑧
𝑧
= @2𝑥 + B 𝚤̂ + (2𝑦)𝚥̂ + (−4𝑧 + ln 𝑥)𝑘3
𝑥
∇𝑓|(,,,,,) = (2 + 1)𝚤̂ + (2)𝚥̂ + (−4 + 0)𝑘3 = 3𝚤̂ + 2𝚥̂ − 4𝑘3
@Dr. Yang Cao Page 2
APSC248 – Engineering Analysis III
Example 2: 𝑤 = 𝑓 (𝑥, 𝑦) = 𝑥 ! − 𝑦 ! , find ∇𝑓 and ∇𝑓 at (1, −1)
Solution:
∇𝑓 = (2𝑥)𝑖̂ + (−2𝑦)𝑗̂
∇𝑓|(,,0,) = 2𝚤̂ + 2𝚥̂
∇𝑓 = 2𝚤̂ + 2𝚥̂
@Dr. Yang Cao Page 3
APSC248 – Engineering Analysis III
In vector calculus, the gradient of a scalar field is a vector field that points in the direction
of the greatest rate of increase of the scalar field, and whose magnitude is that rate of increase.
In simple terms, the variation in space of any quantity can be represented (e.g. graphically) by a
slope.
Interpretations:
• For example, consider a room in which the temperature is given by a scalar field 𝑇, so at
each point (𝑥, 𝑦, 𝑧) the temperature is 𝑇(𝑥, 𝑦, 𝑧) (we will assume that the temperature
does not change in time). Then, at each point in the room, the gradient of 𝑇 at that point
will show the direction in which the temperature rises most quickly. The magnitude of
the gradient will determine how fast the temperature rises in that direction.
• Consider a surface whose height above sea level at a point (𝑥, 𝑦) is 𝐻(𝑥, 𝑦). The gradient
of 𝐻 at a point is a vector pointing in the direction of the steepest slope at that point. The
steepness of the slope at that point is given by the magnitude of the gradient vector |∇𝑓|
(we’ll learn this in directional derivative).
Summary:
The gradient is a fancy word for derivative, or the rate of change of a function. It’s a vector (a
direction to move) that
• points in the direction of greatest increase of a function
• is zero at a local maximum or local minimum (because there is no single direction of
increase)
We can use concept of directional derivative in Lecture 15 to explain why gradient vector gives
the direction of greatest increase.
@Dr. Yang Cao Page 4
APSC248 – Engineering Analysis III
Example 3: Watch out for which gradient you are looking for
Given a surface 𝑧 = 𝑓(𝑥, 𝑦) = 𝑥 - + 𝑦 - . We can also say that this surface is one of the level
surfaces of function 𝑤(𝑥, 𝑦, 𝑧) = 𝑧 − 𝑥 - − 𝑦 - when 𝑤 = 0.
• The Gradient vector of function 𝑓(𝑥, 𝑦) gives a planar vector field
∇𝑓 = 2𝑥𝚤̂ + 2𝑦𝚥̂
• The Gradient vector of function 𝑤(𝑥, 𝑦, 𝑧) gives a 3D vector field
∇𝑤 = −2𝑥𝚤̂ − 2𝑦𝚥̂ + 𝑘3
• Given a point 𝑃. (1,1) which is on level curve 𝑧 = 2. We have the gradient vector of
function 𝑓(𝑥, 𝑦) at this point is
∇𝑓|(,,,) = (2𝑥𝚤̂ + 2𝑦𝚥̂)|(,,,) = 2𝚤̂ + 2𝚥̂
This vector points to the direction of greatest increase for variable 𝑧 or function 𝑓(𝑥, 𝑦) at
location 𝑃. (1,1).
@Dr. Yang Cao Page 5
APSC248 – Engineering Analysis III
• Given a point 𝑃, (1,1,2) which is on the level surface 𝑤 = 0, or the surface 𝑧 = 𝑥 - + 𝑦 - .
We have the gradient vector of function 𝑤(𝑥, 𝑦, 𝑧) at this point is
∇𝑤|(,,,,-) = O−2𝑥𝚤̂ − 2𝑦𝚥̂ + 𝑘3 PQ(,,,,-) = −2𝚤̂ − 2𝚥̂ + 𝑘3 = 〈−2, −2,1〉
This vector points to the direction of greatest increase for variable 𝑤 or function
𝑤(𝑥, 𝑦, 𝑧) at location 𝑃, (1,1,2).
The graphs showing here were generated using Maple to illustrate the differences.
Question: What are the gradient vectors of ∇𝑓 and ∇𝑤 at points (0,0) and (0,0,0), respectively?
Can you interpret the meaning?
@Dr. Yang Cao Page 6
APSC248 – Engineering Analysis III
Theorem:
(a) Given a differentiable function 𝑧 = 𝑓(𝑥, 𝑦), then
∇𝑓 ⊥ level curves 𝑓(𝑥, 𝑦) = 𝐶
∇𝑓 ⊥ tangent lines of level curves 𝑓(𝑥, 𝑦) = 𝐶
(b) Given a differentiable function 𝑤 = 𝑓(𝑥, 𝑦, 𝑧), then
∇𝑓 ⊥ level surfacess 𝑓(𝑥, 𝑦, 𝑧) = 𝐶
∇𝑓 ⊥ tangent planes of level surfacess 𝑓(𝑥, 𝑦, 𝑧) = 𝐶
For example: Given 𝑧 = 𝑓(𝑥, 𝑦). Suppose its level curves or contour plot is shown
below. Then a gradient at any point (𝑥, 𝑦) gives a vector perpendicular to that level
curve.
∇𝑓
𝑦
Example 4: 𝑤 = 𝑓 (𝑥, 𝑦, 𝑧) = 𝑎" 𝑥 + 𝑎! 𝑦 + 𝑎# 𝑧, find ∇𝑤 and show that ∇𝑤 is
perpendicular to level surfaces.
∇𝑤 = 〈𝑎" , 𝑎! , 𝑎# 〉
The level surface is 𝑓 (𝑥, 𝑦, 𝑧 ) = 𝐶 or 𝑎" 𝑥 + 𝑎! 𝑦 + 𝑎# 𝑧 = 𝐶
This is a plane equation in 3D space and the normal vector to this plane is
〈𝑎, , 𝑎- , 𝑎1 〉
Hence the gradient vector ∇𝑤 is perpendicular to the level surface 𝑤 = 𝐶.
@Dr. Yang Cao Page 7
APSC248 – Engineering Analysis III
Example 5: 𝑤 = 𝑓 (𝑥, 𝑦) = 𝑥 ! + 𝑦 ! , find ∇𝑤 and show that ∇𝑤 is
perpendicular to level curves 𝑤 = 𝐶.
Solution:
∇𝑤 = 〈2𝑥 2𝑦〉
The level curves are given by 𝑤 = 𝐶 or
𝑥- + 𝑦- = 𝐶
which is a cluster of concentric circles. And the gradient vectors are in the direction from origin
to the tangent point, which are perpendicular to the tangent line or we can say they are
perpendicular to the level curve at point (𝑥, 𝑦).
𝑦 ∇𝑤
@Dr. Yang Cao Page 8
APSC248 – Engineering Analysis III
Example 6: 𝑧 = 𝑓 (𝑥, 𝑦) = 4 − (cos ! 𝑥 + cos ! 𝑦 )! , find ∇𝑓.
The gradient of the function 𝑓(𝑥, 𝑦) = 4 − (cos - 𝑥 + cos - 𝑦 )- depicted as a vector field on the
bottom plane. Its gradient
∇𝑓 = 𝑓! 𝚤̂ + 𝑓" 𝚥̂
= −2(cos - 𝑥 + cos - 𝑦)(2 cos 𝑥)(− sin 𝑥)𝚤̂ − 2(cos - 𝑥 + cos - 𝑦)(2 cos 𝑦)(− sin 𝑦)𝚥̂
= 2(cos - 𝑥 + cos - 𝑦) sin 2𝑥 𝚤̂ + 2(cos - 𝑥 + cos - 𝑦) sin 2𝑦 𝚥̂
Apparently, this function has a global minimum at (0,0). At point (0,0), the gradient is
∇𝑓|(.,.) = 0
@Dr. Yang Cao Page 9
APSC248 – Engineering Analysis III
Matlab Code:
x = -2:0.2:2; y = x;
[X,Y] = meshgrid(x,y);
f = 4 - (cos(X).^2+cos(Y).^2).^2
mesh(X,Y,f);
hold on
hidden off;
%contour(x,y, f, 'color','r'); hold on
%hidden off;
[Dx,Dy] = gradient(f);
quiver(x , y, Dx, Dy, 'linewidth', 1);
title('f(x,y) = 4 - (cos(x)^2+cos(y)^2)^2, gradient of f');
@Dr. Yang Cao Page 10
APSC248 – Engineering Analysis III
(2) Tangent Planes and Normal Lines for Level Surfaces
Given a function of three variables, 𝑤 = 𝑓(𝑥, 𝑦, 𝑧). If 𝑟⃑(𝑡) = 𝑥(𝑡)𝚤̂ + 𝑦(𝑡)𝚥̂ + 𝑧(𝑡)𝑘3 is a
smooth curve on the level surface 𝑓(𝑥, 𝑦, 𝑧) = 𝐶, then 𝑓O𝑥(𝑡), 𝑦(𝑡), 𝑧(𝑡)P = 𝐶. Differentiating
both sides with respect to 𝑡 and with chain rule, we have
𝑑 𝑑
𝑓O𝑥(𝑡), 𝑦(𝑡), 𝑧(𝑡)P = (𝐶)
𝑑𝑡 𝑑𝑡
𝑑𝑥 𝑑𝑦 𝑑𝑧
𝑓! + 𝑓" + 𝑓# =0
𝑑𝑡 𝑑𝑡 𝑑𝑡
𝑑𝑟⃑ 𝑑𝑟⃑
∇𝑓 ⋅ = 0 ⟹ ∇𝑓 ⊥ c = 𝑣⃑e
𝑑𝑡 𝑑𝑡
Comments:
• At every point along the curve, ∇𝑓 is perpendicular to the curve’s velocity vector. The
result also applies for any other curves on the surface.
• Now let’s focus on a point 𝑃. (𝑥. , 𝑦. , 𝑧. ) on the surface and curves passing through 𝑃. .
For all curves on the surface through 𝑃. , the velocity vectors at 𝑃. are orthogonal to ∇𝑓 at
𝑃. .
• Hence the curves’ tangent lines all lie in the plane through 𝑃. and normal to ∇𝑓. We call
this plane “the tangent plane of the surface at 𝑃. ”.
@Dr. Yang Cao Page 11
APSC248 – Engineering Analysis III
Definition: Tangent Plane
The tangent plane at the point 𝑃(𝑥. , 𝑦. , 𝑧. ) on the level surface 𝑓O𝑥(𝑡), 𝑦(𝑡), 𝑧(𝑡)P = 𝐶 is the
plane through 𝑃. normal to ∇𝑓|2! . The plane equation is
𝑓! (𝑃. )(𝑥 − 𝑥. ) + 𝑓" (𝑃. )(𝑦 − 𝑦. ) + 𝑓# (𝑃. )(𝑧 − 𝑧. ) = 0
Definition: Normal Line
The normal line of the surface at 𝑃(𝑥. , 𝑦. , 𝑧. ) is the line through 𝑃. parallel to vector ∇𝑓|2! . The
normal line equation is
𝑥 = 𝑥. + 𝑓! (𝑃. )𝑡
f𝑦 = 𝑦. + 𝑓" (𝑃. )𝑡
𝑧 = 𝑧. + 𝑓# (𝑃. )𝑡
Note, if ∇𝑓|2! = 0, then we are at local minimum or maximum. The tangent plane will be
parallel to 𝑥𝑦-plane. The equation for tangent plane is
𝑧 = 𝑧.
The equation for normal line is
𝑥 = 𝑥.
g𝑦 = 𝑦. , − ∞ < 𝑡 < ∞
𝑧=𝑡
@Dr. Yang Cao Page 12
APSC248 – Engineering Analysis III
Example 7: Find tangent plane to surface 𝑥 ! + 𝑦 ! − 𝑧 ! = 4 at (2,1,1)
Solution:
Here 𝑓(𝑥, 𝑦, 𝑧) = 𝑥 - + 𝑦 - − 𝑧 - . Then the gradient vector for this surface at (2,1,1) is
∇𝑓|(-,,,,) = 〈2𝑥, 2𝑦, −2𝑧〉|(-,,,,)
= 〈4, 2, −2〉
The tangent plant is then
4(𝑥 − 2) + 2(𝑦 − 1) + (−2)(𝑧 − 1) = 0
4𝑥 + 2𝑦 − 2𝑧 = 8
The normal line is
𝑥 = 2 + 4𝑡
k𝑦 = 1 + 2𝑡
𝑧 = 1 − 2𝑡
@Dr. Yang Cao Page 13
APSC248 – Engineering Analysis III
We can also use gradient of a function 𝑓(𝑥, 𝑦) to obtain the its linearization or approximation of
𝑓(𝑥, 𝑦) at point 𝑃. (𝑥. , 𝑦. ). Suppose that from a level surface 𝑓(𝑥, 𝑦, 𝑧) = 𝐶, we can explicitly
express 𝑧 as function 𝑓(𝑥, 𝑦). In another word, the level surface is rewritten as 𝑧 − 𝑓(𝑥, 𝑦) = 0.
Define 𝑤 = 𝑧 − 𝑓(𝑥, 𝑦). For this level surface, the gradient vector is
𝜕𝑤 𝜕𝑤 𝜕𝑤 𝜕𝑓 𝜕𝑓
∇𝑤 = 𝚤̂ + 𝚥̂ + 𝑘3 = − 𝚤̂ − 𝚥̂ + 𝑘3
𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑥 𝜕𝑦
At 𝑃. ,
𝜕𝑓 𝜕𝑓
∇𝑤|2! = − l 𝚤̂ − l 𝚥̂ + 𝑘3 = −𝑓! (𝑃. )𝚤̂ − 𝑓" (𝑃. )𝚥̂ + 𝑘3
𝜕𝑥 2! 𝜕𝑦 2
!
Then the tangent plane at 𝑃. is
−𝑓! (𝑃. )(𝑥 − 𝑥. ) − 𝑓" (𝑃. )(𝑦 − 𝑦. ) + (𝑧 − 𝑧. ) = 0
𝑧 = 𝑧. + 𝑓! (𝑃. )(𝑥 − 𝑥. ) + 𝑓" (𝑃. )(𝑦 − 𝑦. )
which is an approximation of the surface 𝑧 = 𝑓(𝑥, 𝑦) at 𝑃. . We can also say the above equation
is a linearization of the surface 𝑧 = 𝑓(𝑥, 𝑦) at 𝑃. . This is the same result as we derived in
Lecture 13.
Recall that in 2D space, the approximation of a curve 𝑦 = 𝑓(𝑥) at point 𝑃. (𝑥. , 𝑦. ) is
𝑓(𝑥) ≈ 𝑓(𝑥. ) + 𝑓 3 (𝑥. )(𝑥 − 𝑥. )
@Dr. Yang Cao Page 14
APSC248 – Engineering Analysis III
(3) Tangent Lines for Level Curves (Optional)
Given a differentiable function, 𝑧 = 𝑓(𝑥, 𝑦). The level curve are then 𝑓(𝑥, 𝑦) = 𝐶.
𝑦 ∇𝑤
𝑟⃑(𝑡)
If part of or whole of a level curve 𝑓(𝑥, 𝑦) = 𝐶 is represented using parametric function or
vector 𝑟⃑(𝑡) = 𝑥(𝑡)𝚤̂ + 𝑦(𝑡)𝚥̂, then 𝑓(𝑥(𝑡), 𝑦(𝑡)) = 𝐶. Using chain rule, we have
𝑑 𝑑
𝑓O𝑥(𝑡), 𝑦(𝑡)P = (𝐶)
𝑑𝑡 𝑑𝑡
𝑑𝑥 𝑑𝑦
𝑓! + 𝑓" =0
𝑑𝑡 𝑑𝑡
𝑑𝑥 𝑑𝑦
O𝑓! 𝚤̂ + 𝑓" 𝚥̂P ⋅ m 𝚤̂ + 𝚥̂n
𝑑𝑡 𝑑𝑡
𝑑𝑟⃑ 𝑑𝑟⃑
∇𝑓 ⋅ = 0 ⟹ ∇𝑓 ⊥ c = 𝑣⃑e
𝑑𝑡 𝑑𝑡
At every point (𝑥. , 𝑦. ) in the domain of the differentiable function 𝑓(𝑥, 𝑦), the gradient of
𝑓 is normal to the level curve through (𝑥. , 𝑦. ).
• Equation of tangent line to level curve at point 𝑃.
At the point 𝑃. (𝑥. , 𝑦. ) on the curve, the gradient vector is ∇𝑓 = 𝑓! (𝑥. , 𝑦. )𝚤̂ + 𝑓" (𝑥. , 𝑦. )𝚥̂.
∇𝑓 is perpendicular to the tangent line through 𝑃. (𝑥. , 𝑦. ).
@Dr. Yang Cao Page 15
APSC248 – Engineering Analysis III
o⃑ = 𝑃
If 𝑃(𝑥, 𝑦) is another point on the tangent line, then we can define 𝑇 ooooooo⃑
. 𝑃 = (𝑥 − 𝑥. )𝚤̂ +
(𝑦 − 𝑦. )𝚥̂, which is a vector parallel to the tangent line. Thus
o⃑ = 0
∇𝑓 ⋅ 𝑇
𝑓! (𝑥. , 𝑦. )(𝑥 − 𝑥. ) + 𝑓" (𝑥. , 𝑦. )(𝑦 − 𝑦. ) = 0
This is the equation of the tangent line.
$!
Example 8: Given a level curve %
+ 𝑦 ! = 2. Find the tangent line at point
(−2,1)
𝑥-
𝑓(𝑥, 𝑦) = + 𝑦-
4
𝑥
∇𝑓|(0-,,) = @ 𝚤̂ + 2𝑦𝚥̂Bp = −𝚤̂ + 2𝚥̂
2 (0-,,)
Thus the tangent line equation is
(−1)(𝑥 + 2) + 2(𝑦 − 1) = 0
𝑥 − 2𝑦 = −4
@Dr. Yang Cao Page 16