Home / Calculus

Partial Derivatives and the Gradient

With two inputs there is no single slope — it depends which way you walk. Freeze one variable at a time to get the partials, then combine them into the gradient: the arrow pointing straight uphill.

Controls

x2.0
y1.5

learning rate0.15

Brighter = higher. The green arrow is the gradient (uphill); descent steps the opposite way.

Contour Map of f(x, y)

click anywhere to move the point

Live Calculation

f(x, y)
0
∂f/∂x
0
∂f/∂y
0
|∇f|
0

Overview

Change one input at a time

For a function of several variables, a partial derivative varies one input while holding the others fixed. For f(x,y) = x² + 3y², ∂f/∂x = 2x and ∂f/∂y = 6y. At (1, 2), the gradient is (2, 12): the local rate of increase is much larger along y than x.

∇f = (∂f/∂x₁, …, ∂f/∂xₙ)

The gradient points in the direction of steepest local increase under the usual Euclidean geometry. Its negative points toward steepest local decrease. Gradient descent uses that direction, scaled by a learning rate; a large step can overshoot, and a small step can be slow. See convexity and optimisation.

Partial Derivatives and the Gradient

Partial derivatives measure one coordinate’s effect; together, they form the gradient direction of steepest increase.

Limits of the picture

A gradient is local information, not a guarantee that one step reaches a minimum. At a stationary point it is zero, but the point may be a saddle or maximum. If features use different scales, the steepest direction also depends on that coordinate geometry. The Jacobian and Hessian extend the derivative picture to vector outputs and curvature.

Use a directional derivative to predict a change

At a point x, the gradient ∇f collects the partial derivatives. For a small displacement h, f(x+h) is approximately f(x)+∇f(x)·h. If h is a unit direction, the directional derivative is ∇f·h; its maximum is ‖∇f‖ in the gradient direction. For f(x,y)=x²+3y² at (1,2), the gradient is (2,12), so the steepest local increase points mostly in the y direction. The steepest decrease points in the negative-gradient direction.

This statement assumes the ordinary Euclidean notion of distance. If coordinates use different units or a different geometry, “steepest” depends on how step length is measured; feature scaling can therefore change gradient descent behaviour. Partial derivatives hold the other inputs fixed, which may not match a real process where inputs move together. A zero gradient at a differentiable point indicates no first-order change in any direction, but it can be a minimum, maximum, or saddle. Use the Hessian to examine curvature, and remember that finite steps can overshoot the local approximation.

Try this above

Move in x and y independently and watch their partial derivatives. Then compare a step along the negative gradient with a step that is too large.

For f(x,y)=x²+3y² at (1,2), a small step h=(0.01,0) predicts a change of about (2,12)·(0.01,0)=0.02. A step of the same Euclidean length in the y direction predicts about 0.12. The approximation works for sufficiently small steps; for larger steps, curvature adds error. This dot-product interpretation explains why the gradient is useful for local optimisation and why the learning rate must be controlled. It also gives a numerical check by comparing predicted and observed changes for a small displacement.

A partial derivative is not the same as the rate along every path through a point. For f(x,y)=xy at (1,1), each partial derivative is 1, but moving along the path y=x changes f=x² at rate 2 with respect to x. The gradient combines partials so a chosen direction's rate is their dot product with that direction. Specify the path or direction when interpreting change in a multivariable system.

Sources and next steps

Predict, then reveal

About to run: set x to its minimum (-4). Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Check yourself

0 of 2

Answer without scrolling back up.

  1. When computing a partial derivative with respect to x, what happens to other inputs?

  2. Under Euclidean geometry, which direction is steepest local increase?

Cheat sheet

Partial Derivatives and the Gradient

Take one derivative per variable, bundle them into the gradient vector, and see why it points straight uphill on any loss surface.

MATHS · vizlearn.in/maths/partial_derivatives_and_gradient.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.