Skip to content
Glacius
CalculusConcept reference

Partial derivatives

A partial derivative measures a scalar function’s rate in one independent coordinate while all other coordinates are held constant.

On this page 10 sections
  1. Overview
  2. Change one input at a time
  3. Read the partial derivative
  4. Take a different slice through the same point
  5. Differentiate through an inner expression
  6. Evaluate and interpret the result
  7. Key takeaway
  8. Further questions
  9. Sources & further reading
  10. Concept connections

01Change one input at a time#

A function can depend on several inputs even when its output is a single number. A partial derivative asks what happens locally when one input changes and the others stay fixed. This is how we isolate the effect of one model parameter on a loss.

We will use f(x,y)=x2y+3yf(x,y)=x^2y+3y. At (x,y)=(2,4)(x,y)=(2,4), its value is 16+12=2816+12=28. That value tells us where the output is; a derivative tells us how it changes.

To study the effect of xx at this point, hold yy at 44. The two-input function becomes the one-input slice

f(x,4)=4x2+12.f(x,4)=4x^2+12.

Differentiate this ordinary function of xx: the slope is 8x8x. At x=2x=2, the slope is 1616. Increasing xx a little, while keeping y=4y=4, increases the output by about sixteen times that change.

02Read the partial derivative#

We write the rate with respect to xx as ∂f/∂x\partial f/\partial x, or fxf_x. The symbol ∂\partial is read as “partial.” In this lesson, fxf_x means differentiation, not an extra input to ff.

Keeping yy symbolic but constant gives the same result:

∂f∂x=2xyfx(2,4)=16.\begin{gathered}\frac{\partial f}{\partial x}=2xy\\f_x(2,4)=16.\end{gathered}

Holding yy constant does not mean setting it to zero. In x2yx^2y, it acts as a fixed coefficient, so differentiating with respect to xx leaves 2xy2xy. The separate term 3y3y has no changing xx, so its derivative is zero.

Choose the variable first. Then identify which factors are coefficients and which expressions actually change.

Check your reasoning

f(x,y)=4xy+y2f(x,y)=4xy+y^2. Find fxf_x.

  1. A4x+2y4x+2y
  2. B4y4y
  3. C4y+2y4y+2y
Show answer and explanation
4y4y

Hold yy fixed: fx=4yf_x=4y.

03Take a different slice through the same point#

Now change yy while holding x=2x=2. The slice becomes f(2,y)=4y+3y=7yf(2,y)=4y+3y=7y, whose slope is 77.

In symbolic form,

∂f∂y=x2+3fy(2,4)=7.\begin{gathered}\frac{\partial f}{\partial y}=x^2+3\\f_y(2,4)=7.\end{gathered}

The same point therefore has an xx-rate of 1616 and a yy-rate of 77. There is no contradiction: they describe different changes in the input.

The diagram uses a separate example, f(x,y)=x2+3yf(x,y)=x^2+3y, to show a slice in the input plane. Along its highlighted horizontal path, y=2y=2 stays fixed and xx varies. The resulting one-variable function is f(x,2)=x2+6f(x,2)=x^2+6.

The vertical axis shows the input yy, not the function's output. The line marks which inputs we visit.

Input plane for f(x,y)=x squared+3y. The horizontal highlighted path keeps y=2 while x varies from -2 to 2. At fixed y=2 the scalar function becomes x squared+6. The axes use equal 26 pixels per data unit; the path is in input space, not a graph of output values.Input plane for f(x,y)=x squared+3y. The horizontal highlighted path keeps y=2 while x varies from -2 to 2. At fixed y=2 the scalar function becomes x squared+6. The axes use equal 26 pixels per data unit; the path is in input space, not a graph of output values.
Figure 1Input plane for f(x,y)=x squared+3y. The horizontal highlighted path keeps y=2 while x varies from -2 to 2. At fixed y=2 the scalar function becomes x squared+6. The axes use equal 26 pixels per data unit; the path is in input space, not a graph of output values.
Link to this figure ↗Download SVGDownload PNG

Return to f(x,y)=x2y+3yf(x,y)=x^2y+3y at (2,4)(2,4). With a small change Δx=0.01\Delta x=0.01 and no change in yy, the derivative predicts

Δf≈fx(2,4)Δx=16(0.01)=0.16.\begin{gathered}\Delta f\approx f_x(2,4)\Delta x\\=16(0.01)=0.16.\end{gathered}

The actual new value is f(2.01,4)=28.1604f(2.01,4)=28.1604. The prediction 28.1628.16 is close, but the derivative is a local linear approximation, not an exact finite-change rule.

04Differentiate through an inner expression#

Partial derivatives still use the ordinary rules of differentiation. For g(x,y)=(x+3y)2g(x,y)=(x+3y)^2, first recognize the outer square and the inner expression u=x+3yu=x+3y.

For the yy-partial, the outer rate is 2u2u and the inner rate is 33. Multiply them:

gy=6(x+3y).g_y=6(x+3y).

For the xx-partial of the same function, the inner rate is 11, because 3y3y stays fixed. This gives gx=2(x+3y)g_x=2(x+3y).

The outer operation did not change; the coordinate we allowed to vary did. Omitting that inner rate is why two apparently similar partial derivatives can be confused.

Check your reasoning

f(x,y)=(2x+y)2f(x,y)=(2x+y)^2. A learner writes fx=2(2x+y)f_x=2(2x+y). Repair it.

  1. A2(2x+y)2(2x+y)
  2. B2(2x+y)(2+1)2(2x+y)(2+1)
  3. C4(2x+y)4(2x+y)
Show answer and explanation
4(2x+y)4(2x+y)

The inner derivative in xx is 2.

05Evaluate and interpret the result#

Try a new context: a scalar cost C(a,b)=a2b+2bC(a,b)=a^2b+2b. Its partial derivatives are Ca=2abC_a=2ab and Cb=a2+2C_b=a^2+2.

At (a,b)=(3,2)(a,b)=(3,2), these are 1212 and 1111. A small increase in aa alone has a different effect from the same-sized increase in bb alone. Both rates were evaluated at the same starting state.

Differentiate before substituting all the coordinates. If you replace aa and bb by numbers at the beginning, C(3,2)=22C(3,2)=22 is just a number; it no longer records how the cost depends on either input.

You may substitute the coordinates being held fixed to make a slice, as we did earlier. Keep the coordinate you are differentiating with respect to variable until you have taken its derivative.

Check your reasoning

Cost C(a,b)=a2+abC(a,b)=a^2+ab. At (a,b)=(2,3)(a,b)=(2,3), find CaC_a with bb fixed.

Show answer and explanation
7

Ca=2a+b=7C_a=2a+b=7.

A partial derivative is one piece of local information. It does not by itself describe a change in which several coordinates move together. The gradient collects all these coordinate rates, and the multivariable chain rule combines them when inputs depend on other changing quantities.

Key takeaway

Differentiate one coordinate; keep the others fixed.

  • Compute a partial derivative with other coordinates held fixed.

Further questions

Does a fixed coordinate disappear from the answer?
Not necessarily. In xy, the x partial is y because y stays as the constant coefficient. A term containing only fixed coordinates does have derivative zero.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Partial derivatives.” Math behind ML. /learn/c-partial