Chapter 7 Functions of two or more variables

7.1 Introduction

‘’If I have seen farther than other men, it is because I have stood on the shoulders of giants.’’

Isaac Newton (1642-1727)

‘’If I have not seen as far as others, it is because giants were standing on my shoulders.’’

Hal Abelson (1947-)

In this chapter we are going to study real functions of two variables, that is, functions f:R×RRf:R×RR associating to each pair of real number (x,y)(x,y) a real number y=f(x,y)y=f(x,y). Next semester we will look at the concepts of limit and continuity. In this chapter we will look at derivatives, for the purpose of understanding gradient on surfaces, as well as finding maxima and minima in two dimensions.

We begin with some examples.

Example 7.1 The simplest example of a surface is a plane, which is a linear function: z=ax+by+c,a,b,cR.z=ax+by+c,a,b,cR. In the example below z=3x+4y+5/2z=3x+4y+5/2.
Example 7.2 Suppose we want to describe the elevation above see level of each point on the surface of a mountain. For simplicity, suppose that the mountain just looks like a cone, with the base at sea level. The altitude can be represented by the function f:DRz=f(x,y),f:DRz=f(x,y), associating to each point in the cone’s base to the corresponding altitude. Here, the cone base is represented by a subset of the real plane DR2DR2: this is the map of the mountain. Each point in DD can be uniquely represented by a pair of coordinates (x,y)(x,y). An appropriate function here is z=2x2+y2,z=2x2+y2, and the region D={(x,y):x,y[1,1]}D={(x,y):x,y[1,1]}.
Cone

Example 7.3 To represent the temperature in each point of your study room, we can use a function of three variables: f:DR,T=f(x,y,z).f:DR,T=f(x,y,z). Here, the domain DR3DR3 describes the room and the the output value TT the temperature as a function of position in space. For instance T=(a2x2)(y2b2)(z2c2),T=(a2x2)(y2b2)(z2c2), where D=[a,a]×[b,b]×[c,c]D=[a,a]×[b,b]×[c,c]. Obvioulsy it is difficult to visualise such functions, and it is a skill to find a good way to visualise information.

Example 7.4 What if we want also to keep track on how the temperature changes with time? Well, just add one more variable, tt for time, and describe the temperature as a function of both position in space and time: f:DR,T=f(t,x,y,z).f:DR,T=f(t,x,y,z). Here, the domain DR4DR4 describes the time-space domain given by the room the time interval of interest. For instance, suppose the temperature decays in time exponentially then we might have a formula of the type T=(a2x2)(y2b2)(zcc2)exp(2t),T=(a2x2)(y2b2)(zcc2)exp(2t), with D=[0,)×[a,a]×[b,b]×[c,c]D=[0,)×[a,a]×[b,b]×[c,c].

7.2 Partial Derivatives

If we imagine ourselves on a mountainside, we know that the slope can be different in different directions. This is how we skiers manage to get down very steep slopes slowly, by moving across the slope. We can work out how much things are changing along a particular line. In the following picture from Mathsinsight.org https://mathinsight.org/

Picture from Mathsinsight.org

We are looking at the changes to the function f(x,y)f(x,y) if we fix y=by=b. For instance, suppose we think about the cone f(x,y)=2x2+y2f(x,y)=2x2+y2, and put y=0.5y=0.5, then we are looking at the function g(x)=f(x,0.5)=2x2+1/4g(x)=f(x,0.5)=2x2+1/4. Then we can explore the rate of change of ff along the line y=0.5y=0.5 by differentiating gg with respect to xx.

Remark. The following are other notations for first partial derivatives you should be aware of: fx(x,y)=f1(x,y)=fx(x,y)=D1f(x,y),fy(x,y)=f2(x,y)=fy(x,y)=D2f(x,y).fx(x,y)=f1(x,y)=fx(x,y)=D1f(x,y),fy(x,y)=f2(x,y)=fy(x,y)=D2f(x,y).

Finding the partial derivatives of a function, is pretty straightforward if you know how to take derivatives of single-variable functions. Indeed, by definition, the partial derivative, say, with respect to xx, is the derivative of the function when yy is fixed. The procedure is illustrated with the following examples.

Example 7.5 Let f(x,y)=x2y3+3x2yf(x,y)=x2y3+3x2y. Then fx(x,y)=2xy3+6xy,fy(x,y)=3xy2+3x2.fx(x,y)=2xy3+6xy,fy(x,y)=3xy2+3x2.

The following is a more complicated example.

Example 7.6 Find the first partial derivatives of the function f(x,y)=xarctan(xy)+exp(2y)f(x,y)=xarctan(xy)+exp(2y). Evaluate the partial derivatives at the point (x,y)=(1,0)(x,y)=(1,0).

Thinking of yy as a consant we have fx=arctan(xy)+xy1+(xy)2=0,fx=arctan(xy)+xy1+(xy)2=0, when (x,y)=(1,0)(x,y)=(1,0). With xx as a constant we have fy=x21+(xy)2+2exp(2y)=3.fy=x21+(xy)2+2exp(2y)=3. when (x,y)=(1,0)(x,y)=(1,0).

Here is a video with some more examples:

YOutube clip with more examples

7.2.1 Test yourself

7.3 Partial derivatives of higher order

Again, we consider first just functions of two variables. Suppose that ff is a function of the two variables x,yx,y admitting first partial derivatives in its domain of definition. As the partial derivatives fxfx and fyfy are again functions of xx and yy, they may themselves possess partial derivatives (fx)x(fx)x, (fx)y(fx)y, (fy)x(fy)x (fy)y(fy)y. These functions are the second-order partial derivatives of ff. For these, we introduce the following notation. The two pure second partial derivatives fxx=f11=2fx2=x(fx):=(fx)x,fyy=f22=2fy2=y(fy):=(fy)y,fxx=f11=2fx2=x(fx):=(fx)x,fyy=f22=2fy2=y(fy):=(fy)y, and two mixed second partial derivatives fxy=f12=2fyx=y(fx):=(fx)y,fyx=f21=2fxy=x(fy):=(fy)x.fxy=f12=2fyx=y(fx):=(fx)y,fyx=f21=2fxy=x(fy):=(fy)x. These are, by definition, calculated by taking partial derivatives of already calculated partial derivatives.

Example 7.7 Calculate the second partial derivative of the function f(x,y)=yexp(x2)+xyf(x,y)=yexp(x2)+xy.

We start by calculating the first partial derivatives: fx(x,y)=2xyexp(x2)+y,fy(x,y)=exp(x2)+x,fx(x,y)=2xyexp(x2)+y,fy(x,y)=exp(x2)+x, and then get the second partial derivatives by taking the partial derivatives of fxfx and fyfy: fxx=(2xyexp(x2)+y)x=(2y+4x2y)exp(x2),fxy=(2xyexp(x2)+y)y=2xexp(x2)+1,fyx=(exp(x2)+x)x=2xexp(x2)+1,fyy=(exp(x2)+x)y=0.fxx=(2xyexp(x2)+y)x=(2y+4x2y)exp(x2),fxy=(2xyexp(x2)+y)y=2xexp(x2)+1,fyx=(exp(x2)+x)x=2xexp(x2)+1,fyy=(exp(x2)+x)y=0.

Notice that, in the example above, it happened that fxy=fyxfxy=fyx. It turns out that this is not by chance.

We can have examples in higher dimensions.

Example 7.8 Calculate all first and second partials of f(x,y,z)=sin(x)yz3f(x,y,z)=sin(x)yz3. Verify the equality of the mixed partial derivatives, namely: fxy=fyx,fxz=fzx,fyz=fzy.fxy=fyx,fxz=fzx,fyz=fzy.

The three first partial derivatives of ff are: fx=cos(x)yz3,fy=sin(x)z3,fz=3sin(x)yz2.fx=cos(x)yz3,fy=sin(x)z3,fz=3sin(x)yz2. We get the second partials by computing, for each first partial derivative, its three first partial derivatives: fxx=sin(x)yz3,fxy=cos(x)z3,fxz=3cos(x)yz2,fyx=cos(x)z3,fyy=0,fyz=3sin(x)z2,fzx=3cos(x)yz2,fzy=3sin(x)z2,fzz=6sin(x)yz.fxx=sin(x)yz3,fxy=cos(x)z3,fxz=3cos(x)yz2,fyx=cos(x)z3,fyy=0,fyz=3sin(x)z2,fzx=3cos(x)yz2,fzy=3sin(x)z2,fzz=6sin(x)yz. We can see that the mixed derivatives are equal.

7.3.1 Test yourself

7.4 Space Curves

Another key idea in multidimensional geometry is curves in space. A space curve is a function of one variable (often we call it tt because we like to think about the motion of a particle along a path in time). For instance, in the picture below we see a helical path in three dimensions:

This is the curve (cos(t),sin(t),t)(cos(t),sin(t),t), t[0,10]t[0,10].

MOre generally, we have

Example 7.9 {r(t)=(ax+bxt,ay+byt,az+bzt),t[c,d]}{r(t)=(ax+bxt,ay+byt,az+bzt),t[c,d]} is the equation of a section of straight line in 3 dimensions. If we write a=(ax,ay,az)a=(ax,ay,az) and b=(bx,by,bz)b=(bx,by,bz), then we can write the vector equation of a line in the form r(t)=a+bt,t[c,d]}r(t)=a+bt,t[c,d]}. The direction vector for the line is bb.


Example 7.10 {r(t)=(tcost,tsint,t),t[0,3π]}{r(t)=(tcost,tsint,t),t[0,3π]} is a curve on a cone.

What we are often interested in is the velocity at which the particle goes along the curve. This will tell us not only its speed but its direction. We compute the velocity (as we have always done before) by differentiating the position of the particle.

We note that the velocity at time tt is always tangent to the curve at that point, so differentiation gives us a straightforward way of computing tangents to space curves. In the next example we see the tangent to the previous space curve at t=πt=π,

Example 7.11 Suppose a particle has position r(t)=(tcost,tsint,t)r(t)=(tcost,tsint,t) at time tt. Calculate the velocity of the particle at time tt.

The velocity v(t)=r(t)=(costtsint,sint+tcost,1)v(t)=r(t)=(costtsint,sint+tcost,1).

Example 7.12 Suppose a particle moves on the plane z(x,y)=ax+by+cz(x,y)=ax+by+c and has position r(t)=(x,0,z(x,0))r(t)=(x,0,z(x,0)) at time tt. What is the velocity of the particle?

The velocity of the particle at time tt is v(t)=r(t)=(1,0,a)v(t)=r(t)=(1,0,a). This vector is parallel to the plane. Similarly, (0,1,b)(0,1,b) is also parallel to the plane. Thus we can write a vector equation for the plane r(λ,μ)=(0,0,c)+λ(1,0,a)+μ(0,1,b),λ,μR.r(λ,μ)=(0,0,c)+λ(1,0,a)+μ(0,1,b),λ,μR.

7.4.1 Test yourself



The following is a challenging question, and you will be doing very well if you learn how to answer all parts. In particular, there are some things you have not been told how to do in the module. See if you can find out for yourself how to do these things (find the angle between vectors for instance).

7.5 Chain Rules

You are familiar with the chain rule for calculating the derivative of compositions of single-variable functions. Given two functions f(x)f(x) and g(t)g(t), if gg is differentiable at some tt and ff is differentiable at x=g(t)x=g(t), then the derivative of the composite function f(g(t))f(g(t)) is given by the chain rule: ddt(f(g(t)))=f(g(t))g(t).ddt(f(g(t)))=f(g(t))g(t).(7.1) This can be re-written using other, which is helpful in our context. As ff is function of xx, which is function of tt (through the law given by gg), we can write (7.1) as dfdt=dfdxdxdtto meandfdt(x(t))=dfdx(x(t))dxdt(t).dfdt=dfdxdxdtto meandfdt(x(t))=dfdx(x(t))dxdt(t).(7.2)

Here you will learn generalisations of the chain rule for functions of several variables. To start with, let us motivate with an example, referring back to our bivariate function describing the elevation of a mountain.

Example 7.13 Let z=f(x,y)z=f(x,y) be the function describing the elevation of a mountain above see level as in Example 7.2. Suppose we are walking along a trail climbing up the mountain and that the trail position as a function of time on the xyxy-plane (the map) is given by x=u(t)andy=v(t).x=u(t)andy=v(t). We call this parametric equations of the trail on the xyxy-plane map, with respect to the parameter tt, here representing the time variable.

Mountain Path

At time tt, the elevation reached is given by the composite function z=f(u(t),v(t))=:g(t).z=f(u(t),v(t))=:g(t). The derivative of the function g(t)g(t) tells us how fast we are climbing up the mountain, how fast our height is changing. To compute that we need a chain rule for the derivative of composite functions were one of the function (the outer one in this case) is bivariate.

Example 7.14 Let us go back to the mountain climbing example. Assume that the mountain elevation is given by z=f(x,y)=1x2+y2z=f(x,y)=1x2+y2 for x2+y21x2+y21. This is a cone, with the vertex on (0,0,1)(0,0,1), the base being the unit disk, as in the picture above. Further, assume that the trail followed is given by x=u(t)=(1t)cos(2πt)x=u(t)=(1t)cos(2πt) and y=v(t)=(1t)sin(2πt)y=v(t)=(1t)sin(2πt) for t[0,1)t[0,1); notice that these are the parametric equations of a curve. Calculate the vertical speed.

Using the expressions defining xx and yy in the definition of zz we have: z=f(u(t),v(t))=f((1t)cos(2πt),(1t)sin(2πt))=1(1t)2=t.z=f(u(t),v(t))=f((1t)cos(2πt),(1t)sin(2πt))=1(1t)2=t. Hence, rather simply in this case, we get dzdt=1dzdt=1 and the vertical speed is constant.

By reading the example, you may have realised that we may think of a number of composition of functions. Here we will just consider two cases:

  • composition of single-variable functions with a function of several variable: z=f(u(t),v(t)),z=f(u(t),v(t)),
  • composition of functions of several variable with a function of several variables z=f(u(s,t),v(s,t)).z=f(u(s,t),v(s,t)).

We can calculate the rate of change of height in a different way (often more convenient that in the previous simple expample) using the following theorem.

Example 7.15 Let us go back to Example~7.14. This time we use the chain rule (7.3): zx=xx2+y2=cos(2πt),zy=yx2+y2=sin(2πt), and dxdt=cos(2πt)2π(1t)sin(2πt),dydt=sin(2πt)+2π(1t)sin(2πt). Thus, dzdt=cos2(2πt)+2π(1t)cos(2πt)sin(2πt)+sin2(2πt)2π(1t)cos(2πt)sin(2πt)=1. So, the vertical speed is constant, exaclty as we got in Example~7.14.


In the next theorem we have a more sophisticated chain rule when the functions x and y also depend on two variables. This is typical of the situation when we are making a change of variable (e.g. to polar coordinates x=rcosθ, y=rsinθ) and we want to explore changes in the function with respect to these variables.

Notice that (7.4) can be re-written in matrix form as follows: [zszt]=[xsysxtyt][zxzy]. The matrix in (7.4) is called the Jacobian matrix of the transformation (s,t)(x(s,t),y(s,t)).

Example 7.16 Calculate the Jacobian matrix of the transformation from polar to Cartesian variables.

The change of variables polar to cartesian coordinates is given by x(r,θ)=rcos(θ),y(r,θ)=rsin(θ). The Jacobian of the transformation (r,θ)(x(r,θ),y(r,θ)) is given by [xryrxθyθ]=[cosθsinθrsinθrcosθ]

Sometimes, when, say, y is function of x and their relationship is given implicitly, it is possible to calculate the rate of change of y with respect to x, that is to get dydx without finding first the explicit dependence of y with respect to x. This technique is called implicit differentiation and can be easily derived using the chain rule.

Example 7.17 Suppose that x2+y2=1. Find dy/dx using implicit differentiation and by direct calculation.

The function z=u(x,y)=x2+y21 defines the equation relating x to y, that is u(x,y)=0. Thus, the implicit differentiation method gives: dydx=2x2y=xy. To get the same result by direct calculation, we first need to find y explicitly in function of f. Clearly, y=1x2, at least for x[1,1]. Then, dydx=x1x2, which coincides with the previous result if you consider that y=1x2.

7.5.1 Test yourself