Gradient Calculator

Compute the gradient of a 2D or 3D scalar field at any point.
Choose a function type, enter coefficients and evaluation point, and get the partial derivatives.

Gradient

The gradient of a scalar field f is a vector pointing in the direction of the steepest increase. At any point, it tells you which direction to step to increase f most rapidly. The magnitude of the gradient equals the slope in that steepest direction.

For f(x,y), the gradient is the vector: del f = (df/dx, df/dy)

Each component is a partial derivative, meaning the rate of change along one axis with the other held fixed.

This calculator handles three function forms:

Separable sum: f(x,y) = ax^p + by^q. Partial derivatives are df/dx = pax^(p-1) and df/dy = qby^(q-1). These are independent of each other because x and y appear in separate terms.

Product: f(x,y) = ax^p * y^q. Now both variables mix: df/dx = pax^(p-1)y^q and df/dy = qax^py^(q-1). The y term survives in the x-derivative and vice versa.

3D separable: f(x,y,z) = ax^p + by^q + cz^r. The gradient becomes a 3D vector with a third component df/dz = rcz^(r-1).

Worked example: f(x,y) = 3x^2 + 2y^3 at (1, 2). df/dx = 6x = 6(1) = 6. df/dy = 6y^2 = 6(4) = 24. Gradient = (6, 24), magnitude = sqrt(36 + 576) = sqrt(612) = 24.74. From point (1,2), the function climbs fastest in the direction (6, 24), which is mostly along the y-axis.

The gradient is always perpendicular to the level curves of the function. Walk along a level curve and f does not change; that is what makes it a level curve, and it is why the directional-derivative chart below crosses zero exactly 90 degrees away from the peak.

About gradient descent. Machine learning follows the negative gradient because it is the steepest downhill direction at the point where you are standing. It is worth being precise about what that does and does not guarantee. For an infinitesimally small step, you always go down. For a real step of finite size the guarantee is gone: if the learning rate is too large you can step clean over the valley and land higher than you started, which is exactly what a diverging loss curve looks like. The gradient describes the slope under your feet, not the shape of the landscape ahead, and tuning the learning rate is the work of respecting that difference.

A note on the zero gradient. When every partial derivative is zero, the point is stationary, but the gradient cannot say whether it is a peak, a valley, or a saddle. That question needs second derivatives, specifically the Hessian matrix. A saddle point is flat in the gradient’s eyes and is the reason plain gradient descent can stall in high dimensions.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.