Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

 Open In Colab

Gradient Approximation in Higher Dimensions

Finite difference generalizes readily to multiple dimensions by computing the directional partial derivatives individually:

∂f∂xi≈f(x+hei)−f(x−hei)2h\frac{\partial f}{\partial x_i} \approx \frac{f(\mathbf{x} + h \mathbf{e}_i) - f(\mathbf{x} - h \mathbf{e}_i)}{2h}

where ei\mathbf{e}_i is the unit basis vector along coordinate dimension ii.

The full gradient vector combines these directional components:

∇f(x)=[∂f∂x∂f∂y]\nabla f(\mathbf{x}) = \begin{bmatrix} \frac{\partial f}{\partial x} \\ \frac{\partial f}{\partial y} \end{bmatrix}

pointing in the direction of steepest ascent with magnitude equal to the maximum directional rate of change.

Boundary cases are handled similarly, but with the bounded coordinate evaluated using forward or backward differences.