# Derivatives and Partial Derivatives

A critical feature of any function is how the output changes with the changes to its inputs.

## Derivatives

For a function of one variable $f(x)$, the derivative at some value $x$ may be written as $df/dx$: \({df \over dx} = \lim_{\Delta x \rightarrow 0} {f(x + \Delta x) - f(x) \over \Delta x}\) The reason we use this notation is that the $df$ refers to the vertical distance measured in the numerator, and $dx$ represents the horizontal distance in the denominator.

Visually, this means a line connecting $(x, f(x))$ and $(x + \Delta x, f(x + \Delta x))$ converges to a line tangent to the function at $(x, f(x))$ as $\Delta x \rightarrow 0$. The following diagram illustrates this for a few functions. Use the slider to bring $\Delta x$ to zero; you can also change the value of $x$ to see how the derivative changes (or doesn’t) as $x$ changes.

## Partial derivatives

A *partial derivative* of a multivariable function is defined in much the same way. For a function of two variables (say, $x$ and $y$) we can proceed in the same way as above, comparing the value of the function at $f(x,y)$ as we change the values of $x$ and $y$ by small amounts. The building blocks of our analysis are the *partial derivatives* of the function, which measure how the output of the function changes when one variable is increased while the other(s) are held constant.

In the case of a function of two variables, $x$ and $y$, we can define the partial derivative “with respect to $x$” as $\partial f/\partial x$, where
\({\partial f \over \partial x} = \lim_{\Delta x \rightarrow 0} {f(x + \Delta x, y) - f(x, y) \over \Delta x}\)
Visually, this has the same interpretation as above, except now the two points are points along the surface plot of the function $f(x,y)$, as as $\Delta x \rightarrow 0$ the line is tangent to the *surface*, not just a curve:

The partial derivative with respect to $y$ is defined similarly: holding $x$ constant, it measures the rate at which $f(x,y)$ changes when $y$ increases by a $\Delta y$. In the limit as $\Delta y \rightarrow 0$, it may be represented as a line tangent to the surface plot of the function, pointing in the $y$ direction.

You may have noticed that the graphs of the various $f(x)$ functions in the first example were related to the later multivariable examples. That’s because they were: in fact, the three functions shown were the same as the three functions illustrating $f(x,y)$ with $y$ fixed at 3. Indeed, one helpful way of thinking about partial derivatives is as the derivative of the function implied by holding the other variables of a multivariable function constant. (In economics, this often means imposing a “ceteris paribus” assumption that all other variables are held constant.)

To see what this means visually in this case, we can plot the (two-dimensional) function $f(x | y = \overline y)$. For illustrative purposes, we can see side-by-side what this looks like in three dimensions and two dimensions:

Indeed, if you look carefully, you can see that the two-dimensional graph is *exactly the same* as the graph of the intersection of the surface with the plane at $y = \overline y$.

## Calculating derivatives and partial derivatives

You should review the various rules for calculating derivatives (a nice summary is here). For taking the partial derivative, the key thing to remember is that when you take the derivative with respect to a single variable, you’re holding all other variables constant; so all variables except the variable of interest are treated as constants for the purposes of differentiation.

For example, with the univariate function $f(x) = 12x^{1 \over 2}$, by the exponent rule we have \({df \over dx} = \tfrac{1}{2}\times 12x^{ {1 \over 2} - 1} = 6x^{-{1 \over 2} }\) For the multivariable function $f(x,y) = 4x^{1 \over 2}y$, the $y$ is treated as a constant when taking the partial derivative: \({\partial f \over \partial x} = \tfrac{1}{2}\times 4x^{ {1 \over 2} - 1}y = 2x^{-{1 \over 2} }y\) It’s easy to see that when $y = 3$, these two expressions are identical.