Introduction to partial differentiation
Before reading this guide, it is recommended that you read Guide: Introduction to differentiation and the derivative, Guide: The chain rule, Guide: The product rule, and Guide: The quotient rule.
Narration of study guide: |
What is partial differentiation?
As explained in Guide: Introduction to differentiation and the derivative, a derivative measures how a function changes as its input changes. For example, if you have a function \(f(x)\), the derivative \(f'(x)\) describes the rate at which \(f\) changes with respect to \(x\). \[f'(x)=\lim_{h \to 0} \left( \dfrac{f(x+h)-f(x)}{h} \right)\]
However, in many real-world examples, functions depend on more than one variable. For example, weather prediction involves functions that depend on pressure, humidity and time. In economics, profit might depend on both price and production level. The process of partial differentiation is essential if you want to understand the influence of each variable separately.
For a function \(f(x,y)\) that depends on two variables \(x\) and \(y\), partial differentiation allows you to study the change in \(f\) by considering the change in one variable at a time. If you choose to study the change in \(f\) by considering the change in \(x\), you need to hold \(y\) fixed. In this case, \(y\) is treated as a constant as it doesn’t change during this process.
This guide explains the idea of partial differentiation and how it is different from standard single-variable differentiation. It will explain how to find partial derivatives, the concept of second-order partial derivatives, and how to partially differentiate a function with any finite number of variables.
Definition of the partial derivative
Consider a surface (some bumpy terrain) shown in the 3D graph below. A surface \(z=f(x,y)\) can be defined as a function of \(x\) and \(y\). This means that for any values of \(x\) and \(y\), the function returns a value \(z\) representing the height of the surface at the point \((x,y)\).
A partial derivative measures how the surface changes in a single direction while keeping the other variable constant. To understand how the surface changes with respect to \(x\), fix a value of \(y\), say \(y=1\). The surface \(z=f(x,y)\) is a function of \(x\) and \(y\), but when \(y=1\) the surface reduces to a curve \(z=f(x,1)=f(x)\) in the \(xz\)-plane. This shows how the height \(z\) depends on \(x\) alone when \(y\) is fixed at \(1\).
The 3D graph illustrates the surface with a vertical plane sliding through it at a chosen value of \(y=a\). The points where the plane intersects the surface form a curve (shown in yellow). You can use the slider to change the value of \(a\) which will change the position of the vertical plane and the shape of the curve. The 2D graph displays this curve separately.
Imagine you are following a path across a bumpy terrain where you don’t change direction. As you go up and down the hills and valleys, you will trace out a curve that shows how the height changes along that path. The slope of this curve at any point tells you how steeply the surface is rising or falling in that direction. This is what the partial derivative measures.
As seen in Guide: Introduction to differentiation and the derivative, you can approximate the gradient of this function at a point by looking at how much the function’s value changes over a small step. By fixing \(y\) and observing how the function changes with respect to \(x\), you’re treating the surface as a single-variable function. The slope of the curve at a point gives the partial derivative with respect to \(x\), evaluated at that value of \(y\).
For a function \(f(x,y)\), the partial derivative with respect to \(x\) is written as \[\dfrac{\partial f}{\partial x}\]
It is defined by the limit \[\dfrac{\partial f}{\partial x} = \lim_{h \to 0} \left( \dfrac{f(x+h,y)-f(x,y)}{h} \right)\]
This definition is similar to that of single-variable differentiation, with the key difference that \(y\) is treated as a constant during the process.
Similarly, the partial derivative with respect to \(y\) is defined by the limit \[\dfrac{\partial f}{\partial y} = \lim_{h \to 0} \left( \dfrac{f(x,y+h)-f(x,y)}{h} \right)\]
When differentiating with respect to some variable, all other variables are held fixed (they do not change) and they should be treated as you would normally treat constants.
You may sometimes see the notation \(f_{x}\) to mean the partial derivative of \(f\) with respect to \(x\).
Partial derivatives are always written using a curly \(\partial\) as opposed to a straight \(\mathrm{d}\) as in single-variable differentiation.
An important distinction is that if a function depends only on \(x\), then \(\dfrac{\partial f}{\partial x} = \dfrac{\mathrm{d}f}{\mathrm{d}x}\) as there is no other variable to hold fixed.
Finding partial derivatives
To finding a partial derivative, start by identifying the variable you want to differentiate with respect to. For example, if you want to find the partial derivative of \(f\) with respect to \(x\), treat \(x\) as the variable to differentiate with respect to.
The golden rule of partial differentiation is as follows:
When differentiating with respect to some variable, treat all other variables as constants.
If required, apply any rules of differentiation such as the sum/difference rule chain rule, product rule or quotient rule. These rules from single-variable differentiation still apply to partial differentiation, but they must be applied with respect to the chosen variable only and (again) you must treat all other variables as constants. This can involve a lot of lengthy working, so take your time, especially when combining multiple rules.
For a reminder on how to apply these techniques, please see Guide: Introduction to differentiation and the derivative, Guide: The chain rule, Guide: The product rule, and Guide: The quotient rule.
Consider the function \(f(x,y) = x^2 + y^2\).
To find the partial derivative with respect to \(x\), first differentiate \(x^2\) with respect to \(x\) using the power rule to get \(2x\). Importantly, the term \(y^2\) is a constant with respect to \(x\) so its partial derivative with respect to \(x\) is \(0\). So: \[ \begin{aligned} \dfrac{\partial f}{\partial x} &= \dfrac{\partial}{\partial x}(x^2+y^2) \\[0.5em] &= \dfrac{\partial}{\partial x}(x^2) + \dfrac{\partial}{\partial x}(y^2) \\[0.5em] &= 2x + 0 = 2x \end{aligned} \]
To find the partial derivative with respect to \(y\), first differentiate \(y^2\) with respect to \(y\) using the power rule to get \(2y\). Importantly, the term \(x^2\) is a constant with respect to \(y\) so its partial derivative with respect to \(y\) is \(0\). \[ \begin{aligned} \dfrac{\partial f}{\partial y} &= \dfrac{\partial}{\partial y}(x^2+y^2) \\[0.5em] &= \dfrac{\partial}{\partial y}(x^2) + \dfrac{\partial}{\partial y}(y^2) \\[0.5em] &= 0 + 2y = 2y \end{aligned} \]
Consider the function \(f(x,y) = 3x^{2}y + 4xy^{3}\).
To find the partial derivative with respect to \(x\), first differentiate \(3x^2y\) with respect to \(x\) to get \(6xy\). Now differentiate \(4xy^3\) with respect to \(x\) to get \(4y^3\). Once again, \(y\) is treated as a constant. \[ \begin{aligned} \dfrac{\partial f}{\partial x} &= \dfrac{\partial}{\partial x}(3x^{2}y + 4xy^{3}) \\[0.5em] &= \dfrac{\partial}{\partial x}(3x^2y) + \dfrac{\partial}{\partial x}(4xy^3) \\[0.5em] &= 3y\dfrac{\partial}{\partial x}(x^2) + 4y^3\dfrac{\partial}{\partial x}(x) \\[0.5em] &= 3y \cdot 2x + 4y^3 \cdot1 = 6xy + 4y^3 \end{aligned} \]
To find the partial derivative with respect to \(y\), first differentiate \(3x^2y\) with respect to \(y\) to get \(3x^2\). Now differentiate \(4xy^3\) with respect to \(y\) to get \(12xy^2\). Notice that in this case, \(x\) is treated as a constant. \[ \begin{aligned} \dfrac{\partial f}{\partial y} &= \dfrac{\partial}{\partial y}(3x^{2}y + 4xy^{3}) \\[0.5em] &= \dfrac{\partial}{\partial y}(3x^2y) + \dfrac{\partial}{\partial y}(4xy^3) \\[0.5em] &= 3x^2\dfrac{\partial}{\partial y}(y) + 4x\dfrac{\partial}{\partial y}(y^3) \\[0.5em] &= 3x^2 \cdot 1 + 4x \cdot 3y^2 = 3x^2 + 12xy^2 \end{aligned} \]
Consider the function \(f(x,y) = x^2 (3x+y^2)^3\).
Start by finding the partial derivative with respect to \(x\). Notice that \(f(x,y)\) is a product of the two functions \(x^2\) and \((3x+y^2)^3\). You need to use the product rule to differentiate the product \(x^2 (3x+y^2)^3\) with respect to \(x\). Then, you need to differentiate \((3x+y^2)^3\) with respect to \(x\) using the chain rule. Remember to treat \(y^2\) as a constant. \[ \begin{aligned} \dfrac{\partial f}{\partial x} &= \dfrac{\partial}{\partial x} [ x^2 (3x+y^2)^3 ] \\[0.5em] &= x^2 \dfrac{\partial}{\partial x} [ (3x+y^2)^3 ] + (3x+y^2)^3 \dfrac{\partial}{\partial x} [ x^2 ] \\[0.5em] &= x^2 \cdot 9(3x+y^2)^2 + (3x+y^2)^3 \cdot 2x\\[0.5em] &= 9x^2 (3x+y^2)^2 + 2x (3x+y^2)^3 \end{aligned} \]
Now find the partial derivative with respect to \(y\). Notice that \(f(x,y)\) is a product of the two functions \(x^2\) and \((3x+y^2)^3\) however only the second function is a function of \(y\). Therefore, this doesn’t require the product rule to differentiate as \(x^2\) is treated as a constant. The second function still requires you to use the chain rule. \[ \begin{aligned} \dfrac{\partial f}{\partial y} &= \dfrac{\partial}{\partial y} [ x^2 (3x+y^2)^3 ] = x^2 \dfrac{\partial}{\partial y} [ (3x+y^2)^3 ] \\[0.5em] &= x^2 \cdot 6y(3x+y^2)^2 = 6x^2y(3x+y^2)^2 \end{aligned} \]
Higher-order partial derivatives
As with single-variable functions, you can take partial derivatives of partial derivatives to get second-order partial derivatives. For a function of two variables \(f(x,y)\), there are four second-order partial derivatives, one for each combination of variables.
Much like in differentiation in a single variable, second-order partial derivatives are the partial derivatives of first-order partial derivatives.
For a function \(f\) of two variables \(x\) and \(y\), the pure second-order partial derivatives are defined as: \[ \begin{aligned} f_{xx} &= \dfrac{\partial^2 f}{\partial x^2} = \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial x} \right) \\[0.5em] f_{yy} &= \dfrac{\partial^2 f}{\partial y^2} = \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial y} \right) \end{aligned} \]
To compute a pure second-order partial derivative, you need to differentiate a first-order partial derivative with respect to the same variable again.
For a function \(f\) of two variables \(x\) and \(y\), the mixed second-order partial derivatives are defined as: \[ \begin{aligned} f_{xy} &= \dfrac{\partial^2 f}{\partial y \partial x} = \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial x} \right) \\[0.5em] f_{yx} &= \dfrac{\partial^2 f}{\partial x \partial y} = \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial y} \right) \end{aligned} \]
To compute a mixed second-order partial derivative, you need to differentiate a first-order partial derivative with respect to a different variable.
The order in which the subscript variables are written above is not a typo! For the two notation systems, there are different conventions for denoting the order in which differentiation occurs.
Under certain conditions, the mixed second-order partial derivatives are equal. This is called Schwarz’s Theorem.
If \(\dfrac{\partial f}{\partial x}\) and \(\dfrac{\partial f}{\partial y}\) are continuous and differentiable, then \[\dfrac{\partial^2 f}{\partial x \partial y} = \dfrac{\partial^2 f}{\partial y \partial x}\]
Please see [Guide: Introduction to continuity] and [Guide: Introduction to differentiability] for more detailed analyses of what makes functions continuous and differentiable.
Consider the function \(f(x,y) = \sin(xy) + x^4y^2 + x^3y^3 + 3x\).
The first-order partial derivatives are given by \[ \begin{aligned} \dfrac{\partial f}{\partial x} &= y \cos(xy) + 4x^3 y^2 + 3x^2 y^3 + 3 \\[0.5em] \dfrac{\partial f}{\partial y} &= x \cos(xy) + 2x^4 y + 3x^3 y^2 \end{aligned} \]
The second-order partial derivatives can be calculated from the first-order partial derivatives. \[ \begin{aligned} \dfrac{\partial^2 f}{\partial x^2} &= \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial x} \right) = -y^2 \sin(xy) + 12x^2 y^2 + 6xy^3 \\[0.5em] \dfrac{\partial^2 f}{\partial y^2} &= \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial y} \right) = -x^2 \sin(xy) + 2x^4 + 6x^3 y \\[0.5em] \dfrac{\partial^2 f}{\partial x \partial y} &= \dfrac{\partial}{\partial x} \left( \dfrac{\partial f}{\partial y} \right) = \cos(xy) - xy \sin(xy) + 8x^3 y + 9x^2 y^2 \\[0.5em] \dfrac{\partial^2 f}{\partial y \partial x} &= \dfrac{\partial}{\partial y} \left( \dfrac{\partial f}{\partial x} \right) = \cos(xy) - xy \sin(xy) + 8x^3 y + 9x^2 y^2 \end{aligned} \]
Notice that Schwarz’s Theorem holds as the first-order partial derivatives are continuous and differentiable and \[\dfrac{\partial^2 f}{\partial x \partial y} = \dfrac{\partial^2 f}{\partial y \partial x}.\]
Functions of more than two variables
Partial differentiation is not limited to functions of two variables. Many real-world problems involve functions of many more variables. For example, the temperature in a room might depend on position \((x,y,z)\) and time \(t\).
In general, if \(f=f(x_1, x_2, \ldots, x_n)\), you can compute the partial derivative of \(f\) with respect to any one variable by treating all other variables as constants.
For a function \(f(x_1, x_2, \ldots, x_n)\) of \(n\) variables, the partial derivative with respect to \(x_i\) is denoted by \[ \dfrac{\partial f}{\partial x_i} \quad \textsf{or} \quad f_{x_i} \]
It is defined by the limit \[ \dfrac{\partial f}{\partial x_i} = \lim_{h \to 0} \left( \dfrac{f(x_1, \ldots, x_i + h, \ldots, x_n) - f(x_1, \ldots, x_i, \ldots, x_n)}{h} \right) \]
This is a natural extension of the two-variable case from before. When differentiating with respect to \(x_i\), all other variables are held fixed.
Consider the function \(f(x,y,z,t) = \ln(x^2+y^2+1) + e^{xzt} + y\sin(z+t)\).
As an example, to find the first-order partial derivative with respect to \(x\), you need to differentiate \(f\) with respect to \(x\) while holding \(y\), \(z\) and \(t\) constant.
The first-order partial derivatives are given by \[ \begin{aligned} \dfrac{\partial f}{\partial x} &= \dfrac{2x}{x^2+y^2+1} + zte^{xzt} \\[0.5em] \dfrac{\partial f}{\partial y} &= \dfrac{2y}{x^2+y^2+1} + \sin(z+t) \\[0.5em] \dfrac{\partial f}{\partial z} &= xte^{xzt} + y\cos(z+t) \\[0.5em] \dfrac{\partial f}{\partial t} &= xze^{xzt} + y\cos(z+t) \end{aligned} \]
You can also calculate various higher order partial derivatives for each variable by taking partial derivatives of these first-order partial derivatives.
Quick check problems
- Consider the function \(f(x,y) = x^3y^2 + y^2 + x\). Determine whether the following statements are true or false.
The partial derivative with respect to \(x\) is given by \(\dfrac{\partial f}{\partial x} = 3x^2y^2 + y^2 + 1\).
The partial derivative with respect to \(y\) is given by \(\dfrac{\partial f}{\partial y} = 2x^3y^2 + 2y\).
- Let \(f(x, y) = x^4y^2 + 3\ln(x)\). Which of the following best describes \(\dfrac{\partial f}{\partial y}\)?
- Suppose \(f(x,y) = 5x^2y + 7y\). The mixed partial derivative \(\dfrac{\partial^2 f}{\partial y \partial x}\) is given by .
- Consider the function \(f(x,y) = (x+y^3)^4\sin(x)\). Which rule(s) do you need to compute \(\dfrac{\partial f}{\partial x}\)?
- If \(f(x, y, z, t) = y\sin(z + t) + e^{2x}\), then \(\dfrac{\partial f}{\partial t} =\) .
Further reading
For more questions on the subject, please go to Questions: Introduction to partial differentiation.
For a way to differentiate functions of more than one variable, please see Guide: Multivariate chain rule.
Version history
v1.0: initial version created 05/25 by Donald Campbell as part of a University of St Andrews VIP project.