Quiz 2

Directional Derivatives & The Gradient

1388 words
7 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Directional Derivatives & The Gradient ## 🎯 Learning Objectives After this topic you will be able to: - Compute the gradient vector $\nabla f$ of a multivariable function - Find the directional derivative in any direction - Determine the direction of steepest ascent/descent - Use the gradient to find tangent plan...

Directional Derivatives & The Gradient

🎯 Learning Objectives

After this topic you will be able to:
  • Compute the gradient vector f\nabla f of a multivariable function
  • Find the directional derivative in any direction
  • Determine the direction of steepest ascent/descent
  • Use the gradient to find tangent planes
  • Understand the relationship f\nabla f points in the direction of greatest increase

📋 Prerequisites

  • Partial Derivatives (this week) — components of the gradient
  • Dot Product (Week 1) — directional derivative = fu\nabla f \cdot \mathbf{u}
  • The gradient is the vector calculus generalisation of the derivative

1. Intuition: Which Way is Up?

Imagine you're on a hillside. The gradient tells you:
  • Which direction is steepest uphill (the gradient direction)
  • How steep it is (the gradient magnitude) A directional derivative answers: if I walk in a specific direction, how fast does the elevation change? (Diagram)

2. The Gradient Vector

Definition (Gradient). For f:RnRf: \mathbb{R}^n \to \mathbb{R}, the gradient is the vector of all first partial derivatives:
>f=(fx1,fx2,,fxn)>> \nabla f = \left(\frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial x_2}, \dots, \frac{\partial f}{\partial x_n}\right) >
Example 1: Gradient of f(x,y,z)=x2y+ezf(x,y,z) = x^2y + e^z
>f=(2xy,x2,ez)>> \nabla f = (2xy, x^2, e^z) >

2.1 Properties of the Gradient

PropertyStatement
Directional derivativeDuf=fuD_{\mathbf{u}} f = \nabla f \cdot \mathbf{u} (for unit u\mathbf{u} )
Steepest ascentDirection of f\nabla f
Steepest descentDirection of f-\nabla f
Rate of steepest ascent$\
Level setsf\nabla f is perpendicular to level curves/surfaces

3. Directional Derivatives

3.1 Definition

Definition (Directional Derivative). The directional derivative of ff at x\mathbf{x} in the direction of unit vector u\mathbf{u} is:
>Duf(x)=limh0f(x+hu)f(x)h=f(x)u>> D_{\mathbf{u}} f(\mathbf{x}) = \lim_{h \to 0} \frac{f(\mathbf{x} + h\mathbf{u}) - f(\mathbf{x})}{h} = \nabla f(\mathbf{x}) \cdot \mathbf{u} >
Important: u\mathbf{u} must be a unit vector. If given a non-unit direction v\mathbf{v}, use u=vv\mathbf{u} = \frac{\mathbf{v}}{\|\mathbf{v}\|}.
Example 2: Directional derivative
f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (1,2)(1,2) in direction (3,4)(3,4).
f=(2x,2y)\nabla f = (2x, 2y), so f(1,2)=(2,4)\nabla f(1,2) = (2,4).
Direction v=(3,4)\mathbf{v} = (3,4), unit vector u=(3,4)5=(35,45)\mathbf{u} = \frac{(3,4)}{5} = \left(\frac{3}{5}, \frac{4}{5}\right).
Duf=(2,4)(35,45)=65+165=225=4.4D_{\mathbf{u}} f = (2,4) \cdot \left(\frac{3}{5}, \frac{4}{5}\right) = \frac{6}{5} + \frac{16}{5} = \frac{22}{5} = 4.4.

3.2 Steepest Ascent and Descent

The maximum value of DufD_{\mathbf{u}} f is f\|\nabla f\|, achieved when u\mathbf{u} points in the direction of f\nabla f.
Example 3: Steepest ascent
f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (1,2)(1,2): f(1,2)=(2,4)\nabla f(1,2) = (2,4). Direction of steepest ascent: (2,4)20=(15,25)\frac{(2,4)}{\sqrt{20}} = \left(\frac{1}{\sqrt{5}}, \frac{2}{\sqrt{5}}\right). Rate of steepest ascent: f=4+16=204.47\|\nabla f\| = \sqrt{4+16} = \sqrt{20} \approx 4.47. Direction of steepest descent: (15,25)-\left(\frac{1}{\sqrt{5}}, \frac{2}{\sqrt{5}}\right).

4. Gradient and Level Sets

Theorem. The gradient f\nabla f at a point is perpendicular to the level set (contour) passing through that point. This is why f\nabla f gives the normal vector to the tangent plane of f(x,y,z)=cf(x,y,z) = c. Example 4: Gradient perpendicular to level curve
f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (1,1)(1,1). Level curve through (1,1)(1,1): x2+y2=2x^2 + y^2 = 2 (a circle). f(1,1)=(2,2)\nabla f(1,1) = (2,2), which points outward from the circle, perpendicular to it ✓.

5. Tangent Planes via Gradient

For a surface defined implicitly by F(x,y,z)=0F(x,y,z) = 0, the tangent plane at x0\mathbf{x}_0 is:
F(x0)(xx0)=0\nabla F(\mathbf{x}_0) \cdot (\mathbf{x} - \mathbf{x}_0) = 0
For z=f(x,y)z = f(x,y), define F(x,y,z)=zf(x,y)=0F(x,y,z) = z - f(x,y) = 0, then:
F=(fx,fy,1)\nabla F = (-f_x, -f_y, 1)
Tangent plane: zz0=fx(x0,y0)(xx0)+fy(x0,y0)(yy0)z - z_0 = f_x(x_0,y_0)(x-x_0) + f_y(x_0,y_0)(y-y_0).

6. Edge Cases & Gotchas

SituationWhat Happens
** f=0\nabla f = \mathbf{0} **Critical point — no direction of increase
Direction not unit lengthMust normalise first
Function not differentiableDirectional derivative may not exist in all directions

7. Common Pitfalls

❌ Pitfall 1: Forgetting to normalise the direction vector

Duf=fuD_{\mathbf{u}} f = \nabla f \cdot \mathbf{u} only works when u=1\|\mathbf{u}\| = 1. If given (3,4)(3,4), normalise to (3/5,4/5)(3/5, 4/5).

❌ Pitfall 2: Thinking f\nabla f points uphill at the same rate everywhere

The gradient changes from point to point. f(1,2)\nabla f(1,2) and f(3,4)\nabla f(3,4) are different.

❌ Pitfall 3: Confusing gradient with directional derivative

The gradient is a vector of partial derivatives; the directional derivative is a scalar (rate of change in a specific direction).

8. Formula Summary Table

ConceptFormula
Gradientf=(fx1,fx2,,fxn)\nabla f = (f_{x_1}, f_{x_2}, \dots, f_{x_n})
Directional derivativeDuf=fuD_{\mathbf{u}} f = \nabla f \cdot \mathbf{u} ( $\
Max directional derivative$\
Min directional derivative$-\
Tangent planeF(x0)(xx0)=0\nabla F(\mathbf{x}_0) \cdot (\mathbf{x} - \mathbf{x}_0) = 0

9. 📝 Practice Questions

Q1: Gradient computation
f(x,y)=3x2yy3f(x,y) = 3x^2y - y^3. Find f\nabla f.
Solution: f=(6xy,3x23y2)\nabla f = (6xy, 3x^2 - 3y^2). Q2: Directional derivative
f(x,y)=xeyf(x,y) = xe^y at (2,0)(2,0) in direction toward (5,4)(5,4).
Solution: f=(ey,xey)\nabla f = (e^y, xe^y), f(2,0)=(1,2)\nabla f(2,0) = (1, 2). Direction v=(52,40)=(3,4)\mathbf{v} = (5-2, 4-0) = (3,4), v=5\|\mathbf{v}\| = 5, u=(3/5,4/5)\mathbf{u} = (3/5, 4/5). Duf=(1,2)(3/5,4/5)=3/5+8/5=11/5=2.2D_{\mathbf{u}} f = (1,2) \cdot (3/5, 4/5) = 3/5 + 8/5 = 11/5 = 2.2. Q3: Steepest ascent
f(x,y)=sin(xy)f(x,y) = \sin(xy) at (π/2,1)(\pi/2, 1). Find direction of steepest ascent.
Solution: f=(ycos(xy),xcos(xy))\nabla f = (y\cos(xy), x\cos(xy)). At (π/2,1)(\pi/2, 1): f=(1cos(π/2),(π/2)cos(π/2))=(10,(π/2)0)=(0,0)\nabla f = (1\cdot\cos(\pi/2), (\pi/2)\cos(\pi/2)) = (1\cdot 0, (\pi/2)\cdot 0) = (0,0). f=0\nabla f = \mathbf{0}! This is a critical point. There's no direction of increase. Q4: Rate of change
In what direction does f(x,y)=x2y2f(x,y) = x^2 - y^2 increase most rapidly at (1,2)(1,2)? What's the rate?
Solution: f=(2x,2y)\nabla f = (2x, -2y), f(1,2)=(2,4)\nabla f(1,2) = (2, -4). Direction: (2,4)20=(15,25)\frac{(2,-4)}{\sqrt{20}} = \left(\frac{1}{\sqrt{5}}, -\frac{2}{\sqrt{5}}\right). Rate: f=20=25\|\nabla f\| = \sqrt{20} = 2\sqrt{5}. Q5: Gradient perpendicular to level set
For f(x,y)=x2+y2f(x,y) = x^2 + y^2, show f\nabla f is perpendicular to the level curve at (1,1)(1,1).
Solution: f(1,1)=(2,2)\nabla f(1,1) = (2,2). Level curve: x2+y2=2x^2 + y^2 = 2. Tangent vector to level curve: differentiate implicitly: 2x+2yy=0y=x/y=12x + 2y y' = 0 \Rightarrow y' = -x/y = -1 at (1,1)(1,1). Tangent direction: (1,1)(1,-1). Dot product: (2,2)(1,1)=22=0(2,2)\cdot(1,-1) = 2-2 = 0 ✓. Q6: Tangent plane
Find the tangent plane to z=x2+3xy+y2z = x^2 + 3xy + y^2 at (1,1,5)(1,1,5).
Solution: fx=2x+3yf_x = 2x + 3y, fx(1,1)=5f_x(1,1) = 5. fy=3x+2yf_y = 3x + 2y, fy(1,1)=5f_y(1,1) = 5. z5=5(x1)+5(y1)z - 5 = 5(x-1) + 5(y-1)z=5x+5y5z = 5x + 5y - 5. Q7: Direction of no change
For f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (1,2)(1,2), find a direction where the directional derivative is 0.
Solution: We need fu=0\nabla f \cdot \mathbf{u} = 0. f(1,2)=(2,4)\nabla f(1,2) = (2,4). A perpendicular vector: u=(4,2)20=(25,15)\mathbf{u} = \frac{(-4,2)}{\sqrt{20}} = \left(-\frac{2}{\sqrt{5}}, \frac{1}{\sqrt{5}}\right). Check: (2,4)(2/5,1/5)=(4+4)/5=0(2,4)\cdot(-2/\sqrt{5}, 1/\sqrt{5}) = (-4+4)/\sqrt{5} = 0 ✓. Q8: Gradient in 3D
f(x,y,z)=xyzf(x,y,z) = xyz. Find f(1,2,3)\nabla f(1,2,3) and the directional derivative toward (2,1,0)(2,1,0).
Solution: f=(yz,xz,xy)\nabla f = (yz, xz, xy), f(1,2,3)=(6,3,2)\nabla f(1,2,3) = (6, 3, 2). Direction: v=(21,12,03)=(1,1,3)\mathbf{v} = (2-1, 1-2, 0-3) = (1,-1,-3), v=11\|\mathbf{v}\| = \sqrt{11}. u=(1/11,1/11,3/11)\mathbf{u} = (1/\sqrt{11}, -1/\sqrt{11}, -3/\sqrt{11}). Duf=(6,3,2)(1/11,1/11,3/11)=(636)/11=3/11D_{\mathbf{u}} f = (6,3,2)\cdot(1/\sqrt{11}, -1/\sqrt{11}, -3/\sqrt{11}) = (6 - 3 - 6)/\sqrt{11} = -3/\sqrt{11}. Q9: Maximum rate of change
Find the maximum rate of change of f(x,y,z)=xln(yz)f(x,y,z) = x\ln(yz) at (1,1,1)(1,1,1).
Solution: f=(ln(yz),x/z,x/y)\nabla f = (\ln(yz), x/z, x/y). At (1,1,1)(1,1,1): f=(0,1,1)\nabla f = (0, 1, 1). Maximum rate = f=0+1+1=2\|\nabla f\| = \sqrt{0+1+1} = \sqrt{2}. Q10: Gradient descent direction
If you're at (2,1)(2,1) on f(x,y)=x2+2y2f(x,y) = x^2 + 2y^2, which direction should you move to descend most steeply?
Solution: f=(2x,4y)\nabla f = (2x, 4y), f(2,1)=(4,4)\nabla f(2,1) = (4,4). Direction of steepest descent = f=(4,4)-\nabla f = (-4,-4), or unit vector (12,12)\left(-\frac{1}{\sqrt{2}}, -\frac{1}{\sqrt{2}}\right).

🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.