Derivatives of Functions of Several Variables

Directional derivatives

The derivative of a function of one variable will give us the rate of change of that function: it will tell us how many times faster is the output of the function changing compared to the input.

When attempting to extend this to functions of several variables, we face the following problem: the way the output changes will depend not only on the magnitude of the input change, but also on its direction.

If we want to find the rate of change of a function of several variables, we need to specify the direction, which can be done by specifying a unit vector.

Definition

Given a function \(f\) of \(n\) variables (\(f:\mathbb{R}^n \to \mathbb{R}\)), a point \(A(a_1, a_2, \dots, a_n)\), and a unit vector \(\mathbf{u}\), we define the directional derivative of \(f\) at \(A\) in the direction \(\mathbf{u}\) the following way:

\[f_{\mathbf{u}}(a_1, a_2, \dots, a_n) = \lim_{h \to 0} \frac{f(x_1 + hu_1, x_2 + hu_2, \dots, x_n+hu_n) - f(x_1, x_2, \dots, x_n)}{h}\]

Another way to think about it

Suppose we have a line passing through the point \(A\) with the velocity vector \(\mathbf{u}\) (since this is a unit vector, the speed of the motion is 1). The equation of the line will be

\[\left\{\begin{aligned} x_1(t) &= a_1 + u_1 t\\ x_2(t) &= a_2 + u_2 t\\ &\vdots\\ x_n(t) &= a_n + u_n t \end{aligned} \right.\]

If we substitute the \(x_i\)s into the function \(f\), we will get a real function of single variable \(t\):

\[\begin{aligned} g(t) &= f\left(x_1(t), x_2(t), x_3(t), \dots, x_n(t)\right)\\ &= f\left(a_1 + u_1 t, a_2 + u_2 t, a_3 + u_3 t, \dots, a_n + u_n t\right) \end{aligned}\]

The derivative of \(g\) at \(0\) is then the directional derivative of \(f\) at \(A\) in the direction \(\mathbf{u}\).

An example

Given the function

\[f(x,y) = x^2 + 2y^3 - xy\]

find the directional derivative in the direction of the unit vector \(\left\langle \frac{\sqrt{3}}{2},\frac{1}{2}\right\rangle\) at the point \((1,1)\).

Solution:

The equation of the line passing through the point \((1,1)\) in the direction \(\left\langle \frac{\sqrt{3}}{2},\frac{1}{2}\right\rangle\) is

\[\left\{ \begin{aligned} x &= 1 + \frac{\sqrt{3}}{2}t\\ y &= 1 + \frac{1}{2}t \end{aligned} \right.\]

Plug in \(x = 1 + \frac{\sqrt{3}}{2}t\) and \(y = 1 + \frac{1}{2}t\) into \(f(x,y)\) to get a function of \(t\): \[\begin{aligned} f(t) &= f\left(1 + \frac{\sqrt{3}}{2}t, 1 + \frac{1}{2}t\right)\\ &= \left(1 + \frac{\sqrt{3}}{2}t\right)^2 + 2\left(1 + \frac{1}{2}t\right)^3 - \left(1 + \frac{\sqrt{3}}{2}t\right)\left(1 + \frac{1}{2}t\right) \end{aligned}\]

Then the required directional derivative is the derivative of this function at \(t=0\). \[\begin{aligned}f'(t) &= 2\left(1 + \frac{\sqrt{3}}{2}t\right)\frac{\sqrt{3}}{2}\\ &\phantom{= {}} + 6\left(1 + \frac{1}{2}t\right)^2\frac{1}{2}\\ &\phantom{= {}} - \frac{\sqrt{3}}{2}\left(1 + \frac{1}{2}t\right) - \left(1 + \frac{\sqrt{3}}{2}t\right)\frac{1}{2} \end{aligned}\]

\[\begin{aligned}f'(0) &= 2\frac{\sqrt{3}}{2} + 6\frac{1}{2} - \frac{\sqrt{3}}{2} - \frac{1}{2}\\ &= \frac{\sqrt{3} + 5}{2} \end{aligned}\]

The directional derivative of \(f\) in the direction \(\left\langle \frac{\sqrt{3}}{2},\frac{1}{2}\right\rangle\) is \(\frac{\sqrt{3} + 5}{2}\).

Partial derivatives

Let’s try to calculate a directional derivative of a function \(f\) of two variables in the direction of the unit basis vector \(\mathbf{i} = \left\langle 1,0\right\rangle\):

\[f_{\mathbf{i}}(x,y) = \lim_{h\to 0} \frac{f(x+1h, y + 0h) - f(x,y)}{h} = \lim_{h\to 0} \frac{f(x+h, y) - f(x,y)}{h}\]

This can be interpreted as a derivative of the function \(f(x,y)\) where the variable \(y\) is fixed and only the variable \(x\) changes.

Partial evaluation and partial functions

Given a function \(f:\mathbb{R}^n \to \mathbb{R}\), we can plug in a number for one of the variables \(x_1\), \(x_2\), …, \(x_n\). The remaining \(n-1\) variables will still be undetermined, so we will end up with a function that has \(n-1\) variables. We can repeat this several times, in the end plugging in \(k\) numbers for \(k\) of the variables, and ending up with a function of \(n-k\) variables.

This process is called partial evaluation, and the resulting function a partial function of \(f\).

In particular, we can plug in values for all but one of the variables, ending with a partial function of one variable. We can then take a derivative of this function.

Partial derivatives definition:

Given a function \(f:\mathbb{R}^n \to \mathbb{R}\), then for every index \(i = 1,2,\dots,n\) we can define the partial derivative with respect to \(x_i\):

We will consider all the variables except \(x_i\) to be fixed numbers, which will turn \(f\) into a partial function with only one variable, \(x_i\). Then the partial derivative of \(f\) with respect to \(x_i\) is the derivative of this partial function. It is also a directional derivative of \(f\) in the direction of the \(i\)-th standard basis vector.

We use the notation \(f_{x_i}(x_1, x_2, \dots, x_n)\) or, equivalently,

\[\frac{\partial f}{\partial x_i} (x_1, x_2, \dots, x_n)\]

For \(n = 2\) we get two partial derivatives:

  • Partial derivative with respect to \(x\):

    \[f_x(x,y) = \frac{\partial f}{\partial x}(x,y) = f_{\mathbf{i}}(x,y) = \lim_{h\to 0}\frac{f(x+h,y) - f(x,y)}{h}\]

  • Partial derivative with respect to \(y\):

    \[f_y(x,y) = \frac{\partial f}{\partial y}(x,y) = f_{\mathbf{j}}(x,y) = \lim_{h\to 0}\frac{f(x,y+h) - f(x,y)}{h}\]

For \(n = 3\) we get three partial derivatives:

  • Partial derivative with respect to \(x\):

    \[f_x(x,y,z) = \frac{\partial f}{\partial x}(x,y,z) = f_{\mathbf{i}}(x,y,z) = \lim_{h\to 0}\frac{f(x+h,y,z) - f(x,y,z)}{h}\]

  • Partial derivative with respect to \(y\):

    \[f_y(x,y,z) = \frac{\partial f}{\partial y}(x,y,z) = f_{\mathbf{j}}(x,y,z) = \lim_{h\to 0}\frac{f(x,y+h,z) - f(x,y,z)}{h}\]

  • Partial derivative with respect to \(z\):

    \[f_z(x,y,z) = \frac{\partial f}{\partial z}(x,y,z) = f_{\mathbf{k}}(x,y,z) = \lim_{h\to 0}\frac{f(x,y,z+h) - f(x,y,z)}{h}\]

Calculating partial derivatives

Try it yourself

Differentiability and tangent plane

Example

Given the function

\[f(x,y) = x^2 + 2y^3 - xy\]

  1. Calculate the two partial derivatives of \(f\) at \((1,1)\):

    \(f_x(x,y) = 2x - y\), so \(f_x(1,1) = 2 - 1 = 1\).

    \(f_y(x,y) = 6y^2 - x\) so \(f_y(1,1) = 6 - 1 = 5\).

  2. Define two vector functions \(\mathbf{r}(t) = \left\langle t, 1, f(t,1)\right\rangle\) and \(\mathbf{s}(t) = \left\langle 1, t, f(1,t)\right\rangle\).

    \(\mathbf{r}(t) = \left\langle t, 1, t^2 + 2 - t\right\rangle\)

    \(\mathbf{s}(t) = \left\langle 1, t, 1 + 2t^3 - t\right\rangle\)

    1. Find the equation of the tangent line to the graph of \(\mathbf{r}(t)\) at \(t = 1\).

      The line has to go through the point \(\mathbf{r}(1)\), with the direction vector \(\mathbf{r}'(1)\).

      \(\mathbf{r}(1) = \left\langle 1, 1, 1^2 + 2 - 1\right\rangle = \left\langle 1, 1, 2\right\rangle\)

      \(\mathbf{r}'(t) = \left\langle 1, 0, 2t - 1\right\rangle\) so \(\mathbf{r}'(1) = \left\langle 1,0,1\right\rangle\).

      The equation of the line is

      \[\left\{\begin{aligned} x &= 1 + t\\ y &= 1\\ z &= 2 + t \end{aligned}\right.\]

    2. Find the equation of the tangent line to the graph of \(\mathbf{s}(t)\) at \(t = 1\).

      The line has to go through the point \(\mathbf{s}(1)\), with the direction vector \(\mathbf{s}'(1)\).

      \(\mathbf{s}(1) = \left\langle 1, 1, 1 + 2\cdot 1^3 - 1\right\rangle = \left\langle 1, 1, 2\right\rangle\)

      \(\mathbf{s}'(t) = \left\langle 0, 1, 6t^2 - 1\right\rangle\) so \(\mathbf{s}'(1) = \left\langle 0,1,5\right\rangle\).

      The equation of the line is

      \[\left\{\begin{aligned} x &= 1\\ y &= 1 + t\\ z &= 2 + 5t \end{aligned}\right.\]

    3. Find en equation of the plane that contains the two tangent lines.

      Both lines pass through the point \((1,1,2)\), so the plane will contain that point. To find its normal vector, we can take the cross product of the direction vectors of the two lines:

      \[\mathbf{n} = \left\langle 1, 0, 1\right\rangle\times \left\langle 0, 1, 5\right\rangle = \left\langle -1, -5, 1\right\rangle\]

      The equation of the plane is then \(-1(x - 1) - 5(y - 1) + 1(z - 2) = 0\). Simplifying and solving for \(z\) gives us

      \[z = x + 5y - 4\]

    The following graph shows the graph of \(f\), the graphs of the two vector functions, the tangent lines, and the plane that contains them:

The following graph shows the tangent plane to a surface, together with traces that are graphs of the partial functions.

A non-differentiable function

The existence of partial derivatives of \(f\) at a point \(A\) does not guarantee that \(f\) is differentiable at \(A\):

The following graph shows the function \(f(x,y) = \frac{xy}{x^2 + y^2}\) with a “tangent plane” at \((0,0)\) which is not actually tangent to the surface:

Directional derivatives of a differentiable function

If a function \(f:\mathbb{R}^2 - \mathbb{R}\) is differentiable at \((a,b)\) with tangent plane at \((a,b,f(a,b))\) given by a linear function \(L\), then for every unit vector \(\mathbf{u}\), the directional derivative of \(f\) at \((a,b)\) in the direction \(\mathbf{u}\) is the same as the directional derivative of \(L\) at \((a,b)\) in the direction \(\mathbf{u}\).

Example

The function

\[f(x,y) = x^2 + 2y^3 - xy\]

is differentiable at \((1,1)\) with tangent plane at \((1,1,2)\) given by

\[L(x,y) = x + 5y - 4\]

To find the directional derivative of \(L\) in the direction of the unit vector \(\left\langle \frac{\sqrt{3}}{2},\frac{1}{2}\right\rangle\) at the point \((1,1)\), plug in \(x = 1 + \frac{\sqrt{3}}{2}t\) and \(y = 1 + \frac{1}{2}t\) into \(f(x,y)\) to get a function of \(t\):

\[\begin{aligned} L(t) &= 1 + \frac{\sqrt{3}}{2}t + 5\left(1 + \frac{1}{2}t\right) - 4\\ &= 1 + \frac{\sqrt{3}}{2}t + 5 + \frac{5}{2}t - 4\\ &= \frac{\sqrt{3} + 5}{2}t + 2 \end{aligned}\]

The derivative of this function is \(\frac{\sqrt{3} + 5}{2}\).

Earlier we calculated the directional derivative of \(f\) at the same point in the same direction, and it was the same.

Try it yourself