In single-variable calculus, we map a number to a number (). In Vector Calculus, we map a position to a vector (). This represents physical phenomena like wind speed at every point in a city, or the force of gravity at every point in the solar system.
The Gradient: The Direction of Maximum Ascent
Given a scalar field (like the altitude of a mountain), the Gradient is a vector field that points in the direction of the steepest uphill slope.
The magnitude of the gradient tells you how steep the slope is.
Divergence: Sources and Sinks
The Divergence () of a vector field measures how much the “fluid” is expanding or compressing at a point.
Positive Divergence: The point is a Source (fluid is created/flowing out).
Negative Divergence: The point is a Sink (fluid is destroyed/flowing in).
Curl: The Rotation of the Field
The Curl () measures the tendency of the field to rotate around a point. If you placed a tiny paddlewheel in the field, the curl tells you how fast and in what direction it would spin.
Interactive Lab
import numpy as np
import matplotlib.pyplot as plt
# Define a grid of points
x, y = np.meshgrid(np.linspace(-2, 2, 10), np.linspace(-2, 2, 10))
# Example Vector Field: Rotational field (V = [-y, x])
u = -y
v = x
print("Visualizing a rotational field (Curl > 0):")
# In a real environment, we'd use plt.quiver(x, y, u, v)
# For now, let's look at the vectors at a few points
for i in [0, 5, 9]:
for j in [0, 5, 9]:
print(f"Point ({x[i,j]:.1f}, {y[i,j]:.1f}) -> Vector ({u[i,j]:.1f}, {v[i,j]:.1f})")
python
1import numpy as np
2import matplotlib.pyplot as plt
3
4# Define a grid of points
5x, y = np.meshgrid(np.linspace(-2, 2, 10), np.linspace(-2, 2, 10))
6
7# Example Vector Field: Rotational field (V = [-y, x])
8u =-y
9v = x
10
11print("Visualizing a rotational field (Curl > 0):")
12# In a real environment, we'd use plt.quiver(x, y, u, v)
13# For now, let's look at the vectors at a few points
A vector field is Conservative if it is the gradient of some scalar function (). In physics, this means the work done moving between two points is independent of the path taken. Gravity and electric fields are conservative; friction is not.
Exercises
Knowledge Check
If the Divergence of a wind field at a certain point is zero, what does it mean?
Answer: The air is incompressible; as much air enters the point as leaves it.
Zero divergence means the flow is 'solenoidal'—there are no net sources or sinks of fluid at that point.
If the Divergence of a wind field at a certain point is zero, what does it mean?
Knowledge Check
What does the Curl of a field represent?
Answer: The local rotation of the field.
Curl measures the 'vorticity' or spinning motion of the field at a specific point.
What does the Curl of a field represent?
Knowledge Check
Why is the Gradient important in Machine Learning?
Answer: It is used in Graduate Descent to find the minimum of an error function.
In Gradient Descent, we calculate the gradient of the 'Loss' function and move in the *opposite* direction to find the lowest error possible.
Why is the Gradient important in Machine Learning?