Profit depends on price and advertising; a neural network's loss depends on millions of weights. To know how such a function changes, we need its rate of change in every input at once. The gradient collects these rates into a single vector: the central object of multivariable calculus and of optimization.
We will compute partial derivatives and finish with gradients of other functions.
Step 1: Partial derivatives
A partial derivative is an ordinary derivative in one variable, taken with the other variables held fixed. The gradient stacks them into a vector:
For f = x² + 3xy, treat y as a constant to get ∂f/∂x = 2x + 3y, and treat x as a constant to get ∂f/∂y = 3x. So ∇f = (2x + 3y, 3x), which is (8, 3) at the point (1, 2). The gradient is itself a function: it takes a different value at each point.
Step 2: Gradients of other functions
Every rule of single-variable calculus applies to each variable in turn, with the other variables treated as constants. A constant factor stays: ∂(x²y)/∂x = 2xy, since y just multiplies x². A term without x vanishes: ∂(x + y³)/∂x = 1. For f = 2x³ + xy², the power rule gives ∂f/∂x = 6x² + y², and in y, where 2x³ is constant and x multiplies y², ∂f/∂y = 2xy. At (1, 3): ∂f/∂x = 6 + 9 = 15 and ∂f/∂y = 6.