Welcome to our next lesson. In our previous session, we established how to compute partial derivatives, which measure a function's rate of change along the primary axes. We saw that for any multivariable function, like a dose distribution , we can find its rate of change in the x, y, and z directions individually.
Today, we'll learn how to combine these individual rates of change into a single, powerful tool: the gradient vector. This lesson will define the gradient and, most importantly, explore how to interpret its two key properties: its direction and its magnitude. Understanding the gradient is not just a mathematical exercise; it is the absolute foundation of how neural networks learn. The optimization algorithms that adjust a network's parameters to make better predictions are all guided by the gradient.
From Slopes to a Compass: The Idea of the Gradient
In the last lesson, we found the slopes of a surface in the x and y directions. But what if we want to know the slope in an arbitrary direction, or more importantly, which direction is the absolute steepest? The gradient provides the answer. It acts like a compass that, at any point on a function's surface, points in the direction of the steepest uphill climb.
The following video provides an excellent high-level introduction. It visualizes a temperature map as a "hill" and explains how partial derivatives are slopes in specific directions, which are then combined to form the gradient vector that points in the direction of the fastest temperature increase.
Best Explanation of Partial Derivatives and Gradients
This video from Brain Station Advanced offers a clear, intuitive starting point for understanding what a gradient represents.
Please watch from the beginning to the end. Pay close attention to how it builds from a scalar field (the temperature map) to partial derivatives (slopes along axes) and finally to the gradient (the arrow pointing uphill).
Defining the Gradient Vector
As the video summarized, the gradient is a vector whose components are the partial derivatives of the function. For a function that depends on variables , its gradient is denoted by (pronounced "nabla f" or "del f").
For a function of two variables, , the gradient is a two-dimensional vector:
For a function of three variables, , which is common in medical imaging, the gradient is a three-dimensional vector:
The following reading provides a formal definition and shows how this vector naturally arises when we generalize the concept of a derivative.
Calculus III - Directional Derivatives
This article from Paul's Online Math Notes formally introduces the gradient vector. We will use other parts of this article shortly.
In the article, find the part that begins with the line "There is another form of the formula...". Read the section that defines the gradient vector. Note the \nabla notation and how the definition extends to functions of any number of variables.
The Meaning of the Gradient: Direction and Magnitude
Now for the central question: what does this vector actually tell us? The gradient's power lies in the interpretation of its direction and magnitude.
To understand this, we first need to introduce the directional derivative, denoted . This value represents the rate of change (the slope) of the function at a given point in the direction of an arbitrary unit vector . While partial derivatives restrict us to the directions of the coordinate axes, the directional derivative lets us measure the slope in any direction we choose.
It turns out there is a beautiful and simple formula connecting the directional derivative to the gradient:
This states that the rate of change in any direction is simply the dot product of the gradient and that direction vector. This single equation allows us to interpret the gradient's properties. Recall from vector calculus that the dot product can also be written as . Since is a unit vector, , so we have:
Here, is the angle between the gradient vector and the direction vector .
-
Direction of the Gradient: The value of (the slope) is maximized when is maximized, which happens when , or . This means the direction vector points in the exact same direction as the gradient vector . Therefore, the direction of the gradient vector is the direction of the steepest ascent of the function at that point.
-
Magnitude of the Gradient: When , the maximum value of the directional derivative is . Therefore, the magnitude of the gradient vector is the rate of change in the direction of steepest ascent. It tells you how steep that steepest slope is.
The following text formalizes this result in a theorem.
Calculus III - Directional Derivatives
This section of the same article proves the interpretation we just discussed.
Please read the section titled Theorem, including its short proof. This formally establishes the link between the gradient's direction/magnitude and the concept of maximum rate of change.
The video below provides a fantastic geometric intuition for this relationship, explaining it in the context of level curves (or contour lines).
Geometric Meaning of the Gradient Vector
This video by Dr. Trefor Bazett, "Geometric Meaning of the Gradient Vector," beautifully illustrates these properties.
Watch the segment from this timestamp. Notice two key relationships he establishes: The directional derivative is zero (the slope is flat) when you move along a level curve (tangent to it). The directional derivative is maximized when you move perpendicular to a level curve, which is exactly the direction the gradient vector points.
From Mathematical Surfaces to Dose Distributions
Let's visualize this with a simple mathematical function, , which forms a paraboloid shape.

Now, let's connect this directly to your work. A radiation dose distribution is a scalar field, just like the temperature map or the paraboloid.
- At any point , the gradient vector points in the direction in which the dose is increasing most rapidly.
- The magnitude, , tells you the rate of that increase (e.g., in Gy/mm).
This is precisely the mathematical description of the "dose gradient" or "dose fall-off" that is critical in treatment planning. To spare an organ at risk (OAR) adjacent to a planning target volume (PTV), a steep dose fall-off is required. This corresponds to a large value for the magnitude of the dose gradient.

If you are at a point just outside the PTV, the direction of steepest dose decrease is what you are interested in for sparing tissue. This direction is simply the opposite of the gradient vector, . Optimization algorithms in treatment planning are designed to shape the dose distribution such that is large at the PTV-OAR interface. In our future work with PINNs, we will leverage this same principle to train a neural network.
Conclusion
In this lesson, we have defined the gradient vector and, more importantly, unpacked its physical and geometric meaning. It's a concept that beautifully unifies the partial derivatives of a function into a single, interpretable object.
Key Takeaways:
- The gradient, , is a vector containing all the first-order partial derivatives of a multivariable function .
- The direction of the gradient vector at a point indicates the direction of the greatest rate of increase of the function (the "steepest uphill" path).
- Geometrically, the gradient vector is always perpendicular (normal) to the level curve or level surface at that point.
- The magnitude of the gradient, , gives the value of this maximum rate of change. A larger magnitude means a steeper slope.
In our next lesson, we will transition from theory to practice by implementing the numerical computation of derivatives and gradients in Python. This will equip us with the tools to see these concepts in action and prepare us for the core algorithms of deep learning.