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 | Duโf=โ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
>Duโf(x)=hโ0limโhf(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โ).Duโf=(2,4)โ (53โ,54โ)=56โ+516โ=522โ=4.4.
3.2 Steepest Ascent and Descent
The maximum value of Duโf 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)โ=(5โ1โ,5โ2โ). Rate of steepest ascent: โฅโfโฅ=4+16โ=20โโ4.47. Direction of steepest descent: โ(5โ1โ,5โ2โ).
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
Duโf=โ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 | Duโf=โ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). Duโf=(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)โ=(5โ1โ,โ5โ2โ). 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)โ=(โ5โ2โ,5โ1โ). 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โ). Duโf=(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 (โ2โ1โ,โ2โ1โ).
๐ 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