Directional Derivatives serve to help us understand how a function changes in a particular direction. The gradient is a vector that points in the direction of the steepest increase of a function. The gradient is a generalization of the derivative to functions of multiple variables.


Abstract

example graph

import micropip
await micropip.install("matplotlib")
await micropip.install("numpy")
 
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
 
# Create figure and 3D axis
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
 
# Define the grid for the plane
x = np.linspace(-5, 5, 30)
y = np.linspace(-5, 5, 30)
x, y = np.meshgrid(x, y)
z = 0.5 * x + 0.2 * y  # Equation of a plane: z = 0.5x + 0.2y
 
# Plot the plane
ax.plot_surface(x, y, z, cmap=cm.viridis, alpha=0.6)
 
# Define a point on the plane
point = np.array([2, 1, 0.5 * 2 + 0.2 * 1])  # (x, y, z) = (2, 1, 1.2)
 
# Plot the point
ax.scatter(point[0], point[1], point[2], color='r', s=100)
 
# Define a direction vector
direction = np.array([1, 1, 0.5 * 1 + 0.2 * 1])  # Vector with slope matching the plane
 
# Normalize the direction for plotting an arrow
direction_normalized = direction / np.linalg.norm(direction)
 
# Plot the direction as an arrow from the point
ax.quiver(point[0], point[1], point[2], direction_normalized[0], direction_normalized[1], direction_normalized[2], color='b', length=2, arrow_length_ratio=0.2)
 
# add a projection at the bottom of the graph of where the direction vector is pointing
ax.plot([point[0], point[0] + direction_normalized[0]], [point[1], point[1] + direction_normalized[1]], [0, 0], color='b', linestyle='--')
 
# Set labels
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.set_title('3D Plane with Point and Direction')
 
# Show plot
plt.show()
 

Given and the point we seek the slope of the tangent line at in the direction of the unit vector

We are seeking to find the secant line that passes through the point and

For this purpose, we will use the abstract equation:

Where:

  • vertical change is the change in z coordinates
  • horizontal change is the change in x and y coordinates

Plugging in the imaginary values:

Where:

  • is the x coordinate of the point on the secant line
  • is the y coordinate of the point on the secant line
  • is the z coordinate of the point on the secant line
  • is the direction vector

Putting this all together, we get a graph that looks something like this:

In Layman’s Terms

Essentially, the directional derivative is a measure of how a function changes in a specific direction. The gradient is a vector that points in the direction of the steepest increase of a function. The gradient is a generalization of the derivative to functions of multiple variables.

Proofs

Definition

Directional Derivative of f at in the direction of , where is unit vector

Key Formula

Formula

This enables us to calculate the directional derivative in an arbitrary direc- tion, by taking the dot product of ∇f with a unit vector, u, in the desired direction.


Example

Example

Find the directional derivative of: at the point in the direction of

Lets start by finding the gradient of :

Tip

Always normalize the direction vector into a unit vector

After finding the gradient, we can plug in the values:

Conclusively, the directional derivative of at the point in the direction of is

Conclusion:

The directional derivative of at the point in the direction of is


Example 2