Gradient and Multidimensional Optimization
Definition of Gradient
For a differentiable function with two variables, using Euclidean coordinates, the gradient, denoted as , is defined as the vector of its partial derivatives. Formally,
For , the gradient is . This vector points in the direction of greatest local increase, and its magnitude gives that maximum directional rate of change. At a regular point, the gradient is perpendicular—not tangent—to the level curve through that point.
Open full-size imageStart with the arrows in the lower plane: the gradient lives in the input coordinates (x, y). Orange points toward steepest local increase, blue toward decrease, and green is tangent to a level curve. The surface above shows the corresponding changes in height; the gradient itself is not a three-dimensional arrow on that surface.
Gradient at a Specific Point
To find the gradient of at a particular point, say , we substitute and into the gradient formula:
This result signifies the gradient of at the point and represents the vector pointing in the direction of greatest increase of from that point.
Why the negative gradient gives local descent
Assume is differentiable at an interior point . For a unit vector in the Euclidean norm, the directional derivative is
Cauchy–Schwarz gives . If the gradient is nonzero, the lower bound is attained at . This is steepest descent among Euclidean unit directions, not a promise about a long step or differently scaled coordinates. In particular,
so sufficiently small positive steps decrease . For the gradient above, the steepest unit direction is and its rate is . A tangent vector to a regular level curve satisfies by differentiating the constant value along that curve.
Hessian and directional curvature
For a twice continuously differentiable function, the Hessian collects second partial derivatives, . Equality of mixed partials makes it symmetric. The second-order expansion is
The quadratic form describes curvature along a displacement. A real symmetric matrix is positive definite if this is positive for every nonzero , and positive semidefinite if it is nonnegative. These correspond to all eigenvalues being positive or nonnegative, respectively. An indefinite matrix has directions with both signs. See Boyd and Vandenberghe, Appendix A and §3.1.4 for the matrix definitions and second-order convexity criterion.
For , : curvature is positive along the x-axis and negative along the y-axis. For a symmetric matrix, positive definiteness is equivalent to and , the test used in the regression example below. A zero Hessian is inconclusive: , , and all have one at the origin but give a minimum, maximum, and saddle. Positive semidefiniteness throughout an open convex domain, rather than at one point, underlies the global guarantee in convex optimization.
A stationary point has zero gradient; a local minimum is best among nearby feasible points; a global minimum is best over the entire feasible set. These differ: has a stationary saddle at the origin, while minimizing on gives the boundary solution with derivative . At a stationary point of a twice continuously differentiable function, a positive-definite Hessian ensures a strict local minimum; an indefinite Hessian gives a saddle, and a singular positive-semidefinite Hessian needs further analysis.
Application in Optimization
At an interior local extremum of a differentiable function, the derivative must vanish. The converse is not guaranteed. For , solving gives the candidate ; the separate inequality proves it is the global minimum. Boundary points and points where a derivative does not exist require separate consideration.
For functions of two or more variables, such as , the optimization process seeks points where the gradient is zero, i.e., . This condition implies that both partial derivatives, and , are zero. Solving the system of equations
yields the point as the location of the minimum. This search generalizes to functions of any number of variables, but a zero gradient identifies only a stationary candidate. The point may be a minimum, maximum, or saddle, so a second-order test or another argument is still needed.
Optimization in a Two-Dimensional Sauna
Considering a sauna as a two-dimensional space allows for movement in any direction within a 5x5 room, aiming to find the coldest point based on the temperature distribution.
-
Temperature Function: For a given position , the temperature is a function represented by the height in a three-dimensional plot. Hot areas are indicated by red (higher values) and cold areas by blue (lower values).
-
Objective: Minimize over the closed square . A global minimizer need not be an interior point or have strictly higher values at every other point.
-
Mathematical Approach: The process involves calculating the partial derivatives and , setting them to zero, and solving for and to find potential minimum points.
-
Example Function: .
-
Partial Derivatives:
-
Finding the Minimum: Solving and gives interior candidates only. Check the four edges and corners as well; the complete argument below includes the boundary.
For the sauna, declare the domain . Put , so . On , and : it increases to and then decreases. Thus the unique global coldest point is with . Edges with or have temperature ; edges at have minimum . This checks the boundary, not just stationary points.
Linear Regression Optimization
Linear regression, a fundamental machine learning model, is optimized through a similar multidimensional calculus approach but involves finding the best fit line to a set of data points.
- Problem Statement: With given coordinates of power lines, the task is to minimize the total cost of connecting these to a main fiber line. In this illustrative model, cost is proportional to squared vertical residuals, not shortest distances to the line.
- Mathematical Formulation: The line equation represents the fiber line, with and being the slope and y-intercept, respectively. The optimization goal is to minimize the total cost function , which depends on and .
- Cost Function: Use the illustrative data . Expanding the vertical residual sum gives .
- Partial Derivatives and Optimization:
- Solution: Setting and and solving for and yields the optimal line parameters minimizing the cost.
- Result: The optimal values and are found, with a minimum cost of 4.167.
For the regression quadratic, the Hessian is , with positive leading minor and determinant . It is positive definite, so is the unique global minimizer and . Here squared distance means a vertical residual ; perpendicular distance would also divide its square by and give a different optimization problem. For the statistical model, see Linear Regression.
Gradient Descent: An Efficient Optimization Method
When solving stationary equations directly is impractical, gradient descent offers an iterative alternative. It is not always faster than a direct solver, and descent alone does not establish convergence or global optimality. The local descent property follows from differentiability as shown above; the one-variable guide supplies a domain-safe implementation.