When One Quantity Depends On Two Things At Once
Every function of real interest may not always depend on only one variable, say — a single $x$ deciding a single $y$. There can be many quantities in practice that will be dependent on more than one quantities at a time.
For example,
- A room’s comfort depends on temperature and humidity.
- A patient’s response to a drug depends on dose and body weight.
- Distance covered depends on speed and time travelled.
- A loan’s EMI depends on the principal and the interest rate.
- The area of a rectangle depends on its length and its breadth.
- A crop’s yield depends on rainfall and the amount of fertilizer used.
- The cost of a flight ticket depends on the season and how early it is booked.
- A company’s profit depends on the price set and the quantity sold.
- The pressure of a gas depends on its volume and its temperature.
- A student’s exam score depends on hours studied and hours slept.
In each case, the output cannot be pinned down by knowing only one of the two inputs — both are needed together before the quantity is determined.
Mathematical Description Of A Two-Variable Function
When an output depends on two inputs together, it is written as
$$z = f(x,y)$$
where $x$ and $y$ are the two independent variables and $z$ is the dependent variable — the quantity of interest.
Unlike a single-variable function, where the output is found from a single number on a line, a two-variable function’s output is found from a pair of numbers, $(x,y)$, together.
Example 1: $f(x,y) = x^2 + y^2$
$\quad f(3,4) = 3^2 + 4^2 = 9 + 16 = 25$
Example 2: $f(x,y) = xy + 2x – y$
$ \quad f(2,5) = (2)(5) + 2(2) – 5 = 10 + 4 – 5 = 9$
Just as a single-variable function can be pictured as a curve, a two-variable function can be pictured as a surface — every pair $(x,y)$ on a flat plane is lifted up or down to a height $z = f(x,y)$.
Partial Derivatives: Why “Partial”
For a single-variable function, asking “how does the output change” had only one possible meaning — $x$ was the only input that could move.
For a two-variable function, the same question might be ambiguous: both $x$ and $y$ could move, together or separately, and the output could change differently depending on which one moves and by how much.
A partial derivative answers this question: how does $z$ change if only $x$ moves, while $y$ is held completely fixed — or, separately, how does $z$ change if only $y$ moves, while $x$ is held completely fixed. Each of these is only a part of the full answer to “how does $z$ respond to change” — hence the name partial.
The partial derivative of $f$ with respect to $x$, holding $y$ fixed, is written
$$\frac{\partial f}{\partial x}$$
and the partial derivative of $f$ with respect to $y$, holding $x$ fixed, is written
$$\frac{\partial f}{\partial y}$$
Each is computed exactly like an ordinary derivative, treating the other variable as if it were simply a constant.
Example: $f(x,y) = x^2y + 3y^2$
$\qquad \frac{\partial f}{\partial x} = 2xy,$
$\qquad \frac{\partial f}{\partial y} = x^2 + 6y$
In the first case, $y$ was treated as a constant while differentiating with respect to $x$; in the second, $x$ was treated as a constant while differentiating with respect to $y$.
Example: $f(x,y) = e^{x} \sin y$
$ \qquad \frac{\partial f}{\partial x} = e^{x}\sin y,$
$\qquad \frac{\partial f}{\partial y} = e^{x}\cos y$
Neither partial derivative alone tells the complete story of how $f$ changes when both $x$ and $y$ move together — each only tells the part of the story attributable to one variable moving on its own, with the other one paused.
Second-Order Partial Derivatives
Just as a single-variable function can be differentiated a second time to get $f”(x)$, a two-variable function’s partial derivatives can themselves be differentiated again.
But since there were already two first partial derivatives, $\dfrac{\partial f}{\partial x}$ and $\dfrac{\partial f}{\partial y}$, there are now four possible second-order partials — each first partial can be differentiated with respect to $x$ again, or with respect to $y$ instead.
Differentiating $\dfrac{\partial f}{\partial x}$ further, with respect to $x$ again, gives the pure second partial
$$\frac{\partial^2 f}{\partial x^2} = \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}\right)$$
Differentiating $\dfrac{\partial f}{\partial y}$ further, with respect to $y$ again, gives the other pure second partial
$$\frac{\partial^2 f}{\partial y^2} = \frac{\partial}{\partial y}\left(\frac{\partial f}{\partial y}\right)$$
The remaining two are mixed — differentiating with respect to one variable, then the other:
$$\frac{\partial^2 f}{\partial y \partial x} = \frac{\partial}{\partial y}\left(\frac{\partial f}{\partial x}\right)$$
$$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}\right)$$
Example: $f(x,y) = x^3y^2 + 4xy$
First partials:
$$\qquad \frac{\partial f}{\partial x} = 3x^2y^2 + 4y,$$
$$ \qquad \frac{\partial f}{\partial y} = 2x^3y + 4x$$
Pure second partials:
$$\frac{\partial^2 f}{\partial x^2} = \frac{\partial}{\partial x}\left(3x^2y^2+4y\right) = 6xy^2$$
$$\frac{\partial^2 f}{\partial y^2} = \frac{\partial}{\partial y}\left(2x^3y+4x\right) = 2x^3$$
Mixed second partials:
$$\frac{\partial^2 f}{\partial y \partial x} = \frac{\partial}{\partial y}\left(3x^2y^2+4y\right) = 6x^2y + 4$$
$$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial}{\partial x}\left(2x^3y+4x\right) = 6x^2y + 4$$
Both mixed partials came out to exactly the same expression, $6x^2y+4$, regardless of the order in which $x$ and $y$ were differentiated.
Remark — the order of mixed differentiation usually does not matter
This is not a coincidence specific to this one example. For the great majority of functions encountered in practice, the two mixed partials agree:
$$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial^2 f}{\partial y \partial x}$$
This means that, in practice, only three distinct second-order partials need to be computed for a two-variable function, not four — the order of mixed differentiation can usually be chosen for convenience rather than treated as fixed.
Example: $f(x,y) = e^{xy}$
First partials:
$$\frac{\partial f}{\partial x} = ye^{xy},$$
$$ \frac{\partial f}{\partial y} = xe^{xy}$$
Mixed second partials:
$$\frac{\partial^2 f}{\partial y \partial x} = \frac{\partial}{\partial y}\left(ye^{xy}\right) = e^{xy} + y\cdot xe^{xy} = e^{xy}(1+xy)$$
$$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial}{\partial x}\left(xe^{xy}\right) = e^{xy} + x\cdot ye^{xy} = e^{xy}(1+xy)$$
Once again, both mixed partials agree, $e^{xy}(1+xy)$, confirming the order of differentiation did not matter here either.