Lesson 8 of 18
Directional Derivative
The Directional Derivative
The directional derivative measures the rate of change of in a specific direction :
Where is a unit vector ().
This is the dot product of the gradient with the direction vector.
Expanding the Formula
Why Unit Vectors?
Using a unit vector normalizes the measurement. If we doubled the direction vector, we'd get twice the rate — but we want a pure measure of slope in that direction, independent of how long the direction vector is.
Special Cases
- : directional derivative
- : directional derivative
- : maximum directional derivative
- : minimum (most negative) directional derivative
Example
For at , direction :
Your Task
Implement double directional_deriv(double (*f)(double, double), double x, double y, double ux, double uy, double h) that computes the directional derivative using central differences and the dot product formula.
Note: assume is already a unit vector.
TCC compiler loading...
Loading...
Click "Run" to execute your code.