For a scalar function — a function that takes inputs and produces a single output — the gradient vector is the vector of partial derivatives:
The partial derivative measures how fast changes when we increase slightly while keeping the other inputs fixed. The gradient packages all of these directions of change into a single vector.
Two facts about the gradient are important:
The gradient points in the direction of steepest ascent. If we’re standing at some point on a hilly landscape — where the height is given by — and we want to know which direction up the hill is steepest, the gradient points there. The magnitude of the gradient tells us how steep.
The negative of the gradient points in the direction of steepest descent. If we want to go downhill as fast as possible, we move in the direction . This is the fact that makes Gradient descent work.
A worked example
Take
Partial derivative with respect to : the first term differentiates to , the second term differentiates to , the third term differentiates to (treating as a constant). So
Partial derivative with respect to : the first two terms have no , so they differentiate to 0; the third differentiates to .
The gradient is
At any specific point , plug in the coordinates to get a specific vector that points uphill from there. Negate it to point downhill.
Why this matters for machine learning
In Supervised learning, we have a Loss function that depends on the model’s parameter vector . The job of training is to find that minimizes . The negative gradient points in the direction of steepest decrease of , so taking a step in that direction reduces the loss. Iterating this is Gradient descent.
For a function with one input, the gradient reduces to the ordinary derivative. For a function with many inputs — like a neural-network loss with millions of weight parameters — the gradient is a million-dimensional vector, and computing it efficiently is the job of the backpropagation algorithm.
In vector calculus
Three geometric facts get used constantly in Vector Calculus and Complex Analysis.
Perpendicular to level surfaces. At every point, is perpendicular to the level surface passing through that point. Proof: parameterize any curve on the level surface, so is constant. Differentiating, . Since is tangent to the surface and the equation holds for any such curve, is perpendicular to every tangent direction — i.e., perpendicular to the surface.
This is what makes the gradient the normal vector to a level surface, used everywhere from defining surface normals in flux integrals to identifying the steepest-ascent direction (steepest ascent must be perpendicular to “no change,” which is the level surface).
Directional derivative formula. The rate of change of in any unit direction is , maximized when aligns with . This confirms “steepest ascent direction” and “magnitude = how steep” — and is the calculus tool used in Gradient descent and in walking along level surfaces.
Conservative field structure. Vector fields of the form are called conservative fields (or gradient fields). These are the special fields whose line integrals depend only on endpoints — see Fundamental theorem of line integrals.
Gradient in curvilinear coordinates
The coordinate expression depends on whether you’re working in Cartesian, cylindrical, or spherical coordinates. In each, the position-dependent unit vectors pick up scale factors:
Cartesian :
Cylindrical :
Spherical :
The , , factors are the scale-factor reciprocals, coming from the curvilinear differential length element (, , ). Same story as for Divergence and Curl in curvilinear coordinates — the scale factors propagate through every differential operator.