Directional Derivatives & The Gradient
1388 words
7 min read
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 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 points in the direction of greatest increase
📋 Prerequisites
- Partial Derivatives (this week) — components of the gradient
- Dot Product (Week 1) — directional derivative = ∇f⋅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
>∇f=(∂x1∂f,∂x2∂f,…,∂xn∂f)>Definition (Gradient). For f:Rn→R, the gradient is the vector of all first partial derivatives:
>∇f=(2xy,x2,ez)>Example 1: Gradient of f(x,y,z)=x2y+ez
2.1 Properties of the Gradient
| Property | Statement |
|---|---|
| Directional derivative | Duf=∇f⋅u (for unit u ) |
| Steepest ascent | Direction of ∇f |
| Steepest descent | Direction of −∇f |
| Rate of steepest ascent | $\ |
| Level sets | ∇f is perpendicular to level curves/surfaces |
3. Directional Derivatives
3.1 Definition
>Duf(x)=h→0limhf(x+hu)−f(x)=∇f(x)⋅u>Definition (Directional Derivative). The directional derivative of f at x in the direction of unit vector u is:
Important: u must be a unit vector. If given a non-unit direction v, use u=∥v∥v.
Example 2: Directional derivativef(x,y)=x2+y2 at (1,2) in direction (3,4).∇f=(2x,2y), so ∇f(1,2)=(2,4).Direction v=(3,4), unit vector u=5(3,4)=(53,54).Duf=(2,4)⋅(53,54)=56+516=522=4.4.
3.2 Steepest Ascent and Descent
The maximum value of Duf is ∥∇f∥, achieved when u points in the direction of ∇f.
Example 3: Steepest ascentf(x,y)=x2+y2 at (1,2): ∇f(1,2)=(2,4). Direction of steepest ascent: 20(2,4)=(51,52). Rate of steepest ascent: ∥∇f∥=4+16=20≈4.47. Direction of steepest descent: −(51,52).
4. Gradient and Level Sets
Theorem. The gradient ∇f at a point is perpendicular to the level set (contour) passing through that point. This is why ∇f gives the normal vector to the tangent plane of f(x,y,z)=c. Example 4: Gradient perpendicular to level curvef(x,y)=x2+y2 at (1,1). Level curve through (1,1): x2+y2=2 (a circle). ∇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)=0, the tangent plane at x0 is:
For z=f(x,y), define F(x,y,z)=z−f(x,y)=0, then:
Tangent plane: z−z0=fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0).
6. Edge Cases & Gotchas
| Situation | What Happens |
|---|---|
| ** ∇f=0 ** | Critical point — no direction of increase |
| Direction not unit length | Must normalise first |
| Function not differentiable | Directional derivative may not exist in all directions |
7. Common Pitfalls
❌ Pitfall 1: Forgetting to normalise the direction vector
Duf=∇f⋅u only works when ∥u∥=1. If given (3,4), normalise to (3/5,4/5).
❌ Pitfall 2: Thinking ∇f points uphill at the same rate everywhere
The gradient changes from point to point. ∇f(1,2) and ∇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
| Concept | Formula |
|---|---|
| Gradient | ∇f=(fx1,fx2,…,fxn) |
| Directional derivative | Duf=∇f⋅u ( $\ |
| Max directional derivative | $\ |
| Min directional derivative | $-\ |
| Tangent plane | ∇F(x0)⋅(x−x0)=0 |
9. 📝 Practice Questions
Q1: Gradient computationf(x,y)=3x2y−y3. Find ∇f.Solution: ∇f=(6xy,3x2−3y2). Q2: Directional derivativef(x,y)=xey at (2,0) in direction toward (5,4).Solution: ∇f=(ey,xey), ∇f(2,0)=(1,2). Direction v=(5−2,4−0)=(3,4), ∥v∥=5, u=(3/5,4/5). Duf=(1,2)⋅(3/5,4/5)=3/5+8/5=11/5=2.2. Q3: Steepest ascentf(x,y)=sin(xy) at (π/2,1). Find direction of steepest ascent.Solution: ∇f=(ycos(xy),xcos(xy)). At (π/2,1): ∇f=(1⋅cos(π/2),(π/2)cos(π/2))=(1⋅0,(π/2)⋅0)=(0,0). ∇f=0! This is a critical point. There's no direction of increase. Q4: Rate of changeIn what direction does f(x,y)=x2−y2 increase most rapidly at (1,2)? What's the rate?Solution: ∇f=(2x,−2y), ∇f(1,2)=(2,−4). Direction: 20(2,−4)=(51,−52). Rate: ∥∇f∥=20=25. Q5: Gradient perpendicular to level setFor f(x,y)=x2+y2, show ∇f is perpendicular to the level curve at (1,1).Solution: ∇f(1,1)=(2,2). Level curve: x2+y2=2. Tangent vector to level curve: differentiate implicitly: 2x+2yy′=0⇒y′=−x/y=−1 at (1,1). Tangent direction: (1,−1). Dot product: (2,2)⋅(1,−1)=2−2=0 ✓. Q6: Tangent planeFind the tangent plane to z=x2+3xy+y2 at (1,1,5).Solution: fx=2x+3y, fx(1,1)=5. fy=3x+2y, fy(1,1)=5. z−5=5(x−1)+5(y−1) ⇒ z=5x+5y−5. Q7: Direction of no changeFor f(x,y)=x2+y2 at (1,2), find a direction where the directional derivative is 0.Solution: We need ∇f⋅u=0. ∇f(1,2)=(2,4). A perpendicular vector: u=20(−4,2)=(−52,51). Check: (2,4)⋅(−2/5,1/5)=(−4+4)/5=0 ✓. Q8: Gradient in 3Df(x,y,z)=xyz. Find ∇f(1,2,3) and the directional derivative toward (2,1,0).Solution: ∇f=(yz,xz,xy), ∇f(1,2,3)=(6,3,2). Direction: v=(2−1,1−2,0−3)=(1,−1,−3), ∥v∥=11. u=(1/11,−1/11,−3/11). Duf=(6,3,2)⋅(1/11,−1/11,−3/11)=(6−3−6)/11=−3/11. Q9: Maximum rate of changeFind the maximum rate of change of f(x,y,z)=xln(yz) at (1,1,1).Solution: ∇f=(ln(yz),x/z,x/y). At (1,1,1): ∇f=(0,1,1). Maximum rate = ∥∇f∥=0+1+1=2. Q10: Gradient descent directionIf you're at (2,1) on f(x,y)=x2+2y2, which direction should you move to descend most steeply?Solution: ∇f=(2x,4y), ∇f(2,1)=(4,4). Direction of steepest descent = −∇f=(−4,−4), or unit vector (−21,−21).
🔗 Cross-References
- Next topic: Limits & Continuity
- Week 10 (Tangent Planes): Direct application of gradient
- Week 11 (Hessian): Gradient's derivative is the Hessian
- BSCS3004 (Deep Learning): Gradient descent is the core optimisation algorithm Join Discord Previous9.1 Multivariable FunctionsNext9.3 Limits & Continuity