
# Section 1: Functions of Several Variables and Three Dimensional Space

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Skills to Develop

In this section, we strive to understand the ideas generated by the following important questions:

• What is a function of several variables? What do we mean by the domain of a function of several variables?
• How do we find the distance between two points in $$\mathbb{R}^3$$? What is the equation of a sphere in $$\mathbb{R}^3$$?
• What is a trace of a function of two variables? What does a trace tell us about a function?
• What is a level curve of a function of two variables? What does a level curve tell us about a function?

### Introduction

Throughout our mathematical careers we have studied functions of a single variable. We define a function of one variable as a rule that assigns exactly one output to each input. We analyze these functions by looking at their graphs, calculating limits, differentiating, integrating, and more. In this and following sections, we will study functions whose input is defined in terms of more than one variable, and then analyze these functions by looking at their graphs, calculating limits, differentiating, integrating, and more. We will see that many of the ideas from single variable calculus translate well to functions of several variables, but we will have to make some adjustments as well.

Preview Activity $$\PageIndex{1}$$:

When people buy a large ticket item like a car or a house, they often take out a loan to make the purchase. The loan is paid back in monthly installments until the entireamount of the loan, plus interest, is paid. The monthly payment that the borrower has to make depends on the amount $$P$$ of money borrowed (called the principal), the duration $$t$$ of the loan in years, and the interest rate $$r$$. For example, if we borrow $18,000 to buy a car, the monthly payment $$M$$ that we need to make to pay off the loan is given by the formula The variables $$r$$ and $$t$$ are independent of each other, so using functional notation we write (a) Find the monthly payments on this loan if the interest rate is 6% and the duration of the loan is 5 years. (b) Evaluate $$M(0.05, 4)$$. Explain in words what this calculation represents. (c) Now consider only loans where the interest rate is 5%. Calculate the monthly payments as indicated in Table 9.1. Round payments to the nearest penny.  Duration (in Years) 2 3 4 5 6 Monthly Payments (dollars) Table 9.1: Monthly payments at an interest rate of $$5%$$. (d) Now consider only loans where the duration is 3 years. Calculate the monthly payments as indicated in Table 9.2. Round payments to the nearest penny. Interest rate 0.03 0.05 0.07 0.09 0.11 Monthly payments (dollars) Table 9.2: Monthly payments over three years.  Interest rate 0.03 0.05 0.07 0.09 0.11 Monthly Payments (dollars) Table 9.2: Monthly payment over three years. (e) Describe as best you can the combinations of interest rates and durations of loans that result in a monthly payment of$200.

### Functions of Several Variables

Suppose we launch a projectile, using a golf club, a cannon, or some other device, from ground level. Under ideal conditions (ignoring wind resistance, spin, or any other forces except the force of gravity) the horizontal distance the object will travel depends on the initial velocity $$x$$ the object is given, and the angle $$y$$ at which it is launched. If we let $$f$$ represent the horizontal distance the object travels (its range), then $$f$$ is a function of the two variables $$x$$ and $$y$$, and we represent $$f$$ in functional notation by

$f(x,y)=\dfrac{x^2\sin(2y)}{h}$

where $$g$$ is the acceleration due to gravity.1

Definition

A function $$f$$ of two independent variables is a rule that assigns to each ordered pair $$(x; y)$$ in some set $$D$$ exactly one real number $$f(x; y)$$.

There is, of course, no reason to restrict ourselves to functions of only two variables—we can use any number of variables we like. For example,

$f(x,y,z) = x^2-2xz+\cos(y)$

defines $$f$$ as a function of the three variables $$x$$, $$y$$, and $$z$$. In general, a function of $$n$$ independent variables is a rule that assigns to an ordered $$n$$-tuple $$(x_1, x_2;..., x_n)$$ in some set $$D$$ exactly one real number.

As with functions of a single variable, it is important to understand the set of inputs for which the function is defined.

Definition

The domain of a function $$f$$ is the set of all inputs at which the function is defined.

Activity $$\PageIndex{1}$$

Identify the domain of each of the following functions. Draw a picture of each domain in the
x-y plane.

(a) $$f(x, y) = x^2 + y^2$$
(b) $$f(x, y) = \sqrt{x^2+y^2}$$
(c) $$Q(x, y) = \dfrac{x+y}{x^2+y^2}$$
(d) $$s(x, y) = \dfrac{1}{\sqrt{1-xy^2}}$$

### Representing Functions of Two Variables

One of the techniques we use to study functions of one variable is to create a table of values. We can do the same for functions of two variables, except that our tables will have to allow us to keep track of both input variables. We can do this with a 2-dimensional table, where we list the x-values down the first column and the y-values across the first row. Let $$f$$ be the function defined by $$f(x; y) = \dfrac{x^2 \sin(2y)}{g}$$ that gives the range of a projectile as a function of the initial velocity $$x$$ and launch angle $$y$$ of the projectile. The value $$f(x, y)$$ is then displayed in the location where the $$x$$ row intersects the $$y$$ column, as shown in Table 9.3 (where we measure $$x$$ in feet and $$y$$ in radians).

$$x/y$$ 0.2 0.4 0.6 0.8 1.0 1.2 1.4
25 7.6 14.0 19.5 19.5 17.8 13.2 6.5
50 30.4 56.0 78.1 87.1 71.0 52.8 26.2
75 68.4 126.1 163.8 175.7 159.8 118.7 58.9
100 121.7 224.2 291.3 312.4 284.2 221.1 104.7
125 190.1 350.3 455.1 448.1 444.0 329.8 163.6
150 273.8 504.4 655.3 702.8 639.3 474.9 235.5
175 372.7 686.5 892.0 956.6 870.2 646.4 320.6
200 486.8 896.7 1165.0 1249.5 1136.6 884.3 418.9
225 616.2 1134.9 1474.5 1581.4 1438.5 1068.6 530.0
250

Table 9.3: Values of $$f(x; y) = \dfrac{x^2 \sin(2y)}{g}.$$

Activity $$\PageIndex{2}$$

Complete the last row in Table 9.3 to provide the needed values of the function $$f$$.

If $$f$$ is a function of a single variable $$x$$, then we define the graph of $$f$$ to be the set of points of the form $$(x; f(x))$$, where $$x$$ is in the domain of $$f$$. We then plot these points using the coordinate axes in order to visualize the graph. We can do a similar thing with functions of several variables. Table 9.3 identifies points of the form $$(x, y, f(x, y))$$, and we define the graph of $$f$$ to be the set of these points.

Definition

The graph of a function $$f = f(x, y)$$ is the set of points of the form $$(x, y, f(x, y))$$, where the point $$(x, y)$$ is in the domain of $$f$$.

We also often refer to the graph of a function $$f$$ of two variables as the surface generated by $$f$$. Points in the form $$(x, y, f(x, y))$$ are in three dimensions, so plotting these points takes a bit more work than graphs of functions in two dimensions. To plot these three-dimensional points, we need to set up a coordinate system with three mutually perpendicular axes – the x-axis, the y-axis, and the z-axis (called the coordinate axes). There are essentially two different ways we could set up a 3D coordinate system, as shown in Figures 9.1 and 9.2; thus, before we can proceed, we need to establish a convention.

Figure $$\PageIndex{1}$$ : A right hand system

Figure  $$\PageIndex{2}$$ : A left hand system

The distinction between these two figures is subtle, but important. In the coordinate system shown in 9.1, imagine that you are sitting on the positive z-axis next to the label “z.” Looking down at the x- and y-axes, you see that the y-axis is obtained by rotating the x-axis by 90 in the counterclockwise direction. Again sitting on the positive z-axis in Figure 9.2, you see that the y-axis is obtained by rotating the x-axis by 90 in the clockwise direction.

We call the coordinate system in 9.1 a right-hand system; if we point the index finger of our right hand along the positive x-axis and our middle finger along the positive y-axis, then our thumb points in the direction of the positive z-axis. Following mathematical conventions, we choose to use a right-hand system throughout this book.

Now that we have established a convention for a right hand system, we can draw a graph of the range function defined by $$f(x, y) = \dfrac{x^2 \sin(2y)}{ g}$$. Note that the function $$f$$ is continuous in both variables, so when we plot these points in the right hand coordinate system, we can connect them all to form a surface in 3-space. The graph of the range function $$f$$ is shown in Figure 9.3.

Figure $$\PageIndex{3}$$: The range surface.

There are many graphing tools available for drawing three-dimensional surfaces.2 Since we will be able to visualize graphs of functions of two variables, but not functions of more than two variables, we will primarily deal with functions of two variables in this course. It is important to note, however, that the techniques we develop apply to functions of any number of variables.

Notation: We let $$\mathbb{R}^2$$ denote the set of all ordered pairs of real numbers in the plane (two copies of the real number system) and let $$\mathbb{R}^3$$ represent the set of all ordered triples of real numbers (which constitutes three-space).

### Some Standard Equations in Three-Space

In addition to graphing functions, we will also want to understand graphs of some simple equations in three dimensions. For example, in $$\mathbb{R}^2$$, the graphs of the equations $$x = a$$ and $$y = b$$, where $$a$$ and $$b$$ are constants, are lines parallel to the coordinate axes. In the next activity we consider their three-dimensional analogs.

Activity $$\PageIndex{3}$$

a) Consider the set of points $$(x, y, z)$$ that satisfy the equation $$x = 2$$. Describe this set as best you can.
(b) Consider the set of points $$(x, y, z)$$ that satisfy the equation $$y =-1$$. Describe this set as best you can.
(c) Consider the set of points $$(x, y, z)$$ that satisfy the equation $$z = 0$$. Describe this set as best you can.

Activity 9.3 shows that the equations where one independent variable is constant lead to planes parallel to ones that result from a pair of the coordinate axes. When we make the constant 0, we get the coordinate planes. The xy-plane satisfies $$z = 0$$, the xz-plane satisfies $$y = 0$$, and the yz-plane satisfies $$z = 0$$ (see Figure 9.4).

Figure $$\PageIndex{4}$$: The coordinate planes.

On a related note, we define a circle in $$\mathbb{R}^2$$ as the set of all points equidistant from a fixed point. In $$\mathbb{R}^3$$, we call the set of all points equidistant from a fixed point a sphere. To find the equation of a sphere, we need to understand how to calculate the distance between two points in three-space, and we explore this idea in the next activity.

Activity $$\PageIndex{4}$$

Let $$P = (x_0, y_0, z_0)$$ and $$Q = (x_1, y_1, z_1)$$ be two points in $$\mathbb{R}^3$$. These two points form opposite vertices of a rectangular box whose sides are planes parallel to the coordinate planes as illustrated in Figure 9.5, and the distance between $$P$$ and $$Q$$ is the length of the diagonal shown in Figure $$\PageIndex{5}$$.

Figure $$\PageIndex{5}$$: The distance formula in $$\mathbb{R}^3$$.

(a) Consider one of the right triangles in the base of the box whose hypotenuse is shown as the red line in Figure 9.5. What are the vertices of this triangle? Since this right triangle lies in a plane, we can use the Pythagorean Theorem to find a formula for the length of the hypotenuse of this triangle. Find such a formula, which will be in terms of $$x_0$$, $$y_0$$, $$x_1$$, and $$y1$$.

(b) Now notice that the triangle whose hypotenuse is the blue segment connecting the points $$P$$ and $$Q$$ with a leg as the hypotenuse of the triangle found in part (a) lies entirely in a plane, so we can again use the Pythagorean Theorem to find the length of its hypotenuse. Explain why the length of this hypotenuse, which is the distance between the points $$P$$ and $$Q$$, is

$\sqrt{(x_1-x_0)^2 +(y_1-y_0)^2 +(z_1-z_0)^2}.$

The formula developed in Activity 9.4 is important to remember.

Definition

The distance between points $$P = (x_0, y_0, z_0)$$ and $$Q = (x_1, y_1, z_1)$$ (denoted as |PQ|) in $$\mathbb{R}^3$$ is given by the formula

$|PQ| \sqrt{(x_1-x_0)^2 +(y_1-y_0)^2 +(z_1-z_0)^2}.$

Equation (9.2) can be used to derive the formula for a sphere centered at a point $$(x_0, y_0, z_0)$$ with radius $$r$$. Since the distance from any point $$(x, y, z)$$ on such a sphere to the point $$(x_0, y_0, z_0)$$ is $$r$$, the point $$(x, y, z)$$ will satisfy the equation

$\sqrt{(x_1-x_0)^2 +(y_1-y_0)^2 +(z_1-z_0)^2}=r$

Squaring both sides, we come to the standard equation for a sphere.

Definition

The equation of a sphere with center $$(x_0, y_0, z_0)$$ and radius $$r$$ is

$(x_1-x_0)^2 +(y_1-y_0)^2 +(z_1-z_0)^2=r^2.$

This makes sense if we compare this equation to its two-dimensional analogue, the equation of a circle of radius $$r$$ in the plane centered at $$(x_0, y_0)$$:

$(x_1-x_0)^2 +(y_1-y_0)^2 =r^2.$

### Traces

When we study functions of several variables we are often interested in how each individual variable affects the function in and of itself. In Preview Activity 9.1, we saw that the monthly payment on an \$18,000 loan depends on the interest rate and the duration of the loan. However, if we fix the interest rate, the monthly payment depends only on the duration of the loan, and if we set the duration the payment depends only on the interest rate. This idea of keeping one variable constant while we allow the other to change will be an important tool for us when studying functions of several variables.

As another example, consider again the range function $$f$$ defined by

$f(x,y) = \dfrac{x^2\sin(2y)}{g}$

where $$x$$ is the initial velocity of an object in feet per second, $$y$$ is the launch angle in radians, and $$g$$ is the acceleration due to gravity (32 feet per second squared). If we hold the launch angle constant at $$y = 0.6$$ radians, we can consider $$f$$ a function of the initial velocity alone. In this case we have

$f(x) = \dfrac{x^2}{32}\sin (2\cdot 0.6).$

We can plot this curve on the surface by tracing out the points on the surface when $$y = 0.6$$, as shown in Figure 9.6. The graph and the formula clearly show that $$f$$ is quadratic in the x-direction. More descriptively, as we increase the launch velocity while keeping the launch angle constant, the range increases proportional to the square of the initial velocity.

Similarly, if we fix the initial velocity at 150 feet per second, we can consider the range as a function of the launch angle only. In this case we have

$f(y) =\dfrac{150^2 \sin(2y)}{32}$

We can again plot this curve on the surface by tracing out the points on the surface when $$x = 150$$, as shown in Figure 9.7. The graph and the formula clearly show that $$f$$ is sinusoidal in the y-direction. More descriptively, as we increase the launch angle while keeping the initial velocity constant, the range is proportional to the sine of twice the launch angle.

Figure 9.6: The trace with $$y = 0.6$$.

Figure 9.7: The trace with $$x = 150$$.

The curves we define when we fix one of the independent variables in our two variable function are called traces.

Definition

A trace of a function $$f$$ of two independent variables $$x$$ and $$y$$ is a curve of the form $$z = f(c, y)$$ or $$z = f(x, c)$$, where $$c$$ is a constant.

Understanding trends in the behavior of functions of two variables can be challenging, as can sketching their graphs; traces help us with each of these tasks.

Activity $$\PageIndex{5}$$

In the following questions, we investigate the use of traces to better understand a function through both tables and graphs.
(a) Identify the $$y = 0.6$$ trace for the range function $$f$$ defined by $$f(x, y) = \dfrac{x^2 \sin(2y)}{g}$$ by

highlighting or circling the appropriate cells in Table 9.3. Write a sentence to describe the behavior of the function along this trace. (b) Identify the $$x = 150$$ trace for the range function by highlighting or circling the appropriate cells in Table 9.3. Write a sentence to describe the behavior of the function along this trace.

Figure 9.8: Coordinate axes to sketch traces.

(c) For the function $$g$$ defined by $$g(x, y) = x^2+y^2+1$$, explain the type of function that each trace in the $$x$$ direction will be (keeping $$y$$ constant). Plot the $$y=-4$$, $$y=-2$$, $$y=0$$, $$y=2$$, and $$y=4$$ traces in 3-dimensional coordinate system provided in Figure 9.8.
(d) For the function $$g$$ defined by $$g(x, y) = x^2+y^2+1$$, explain the type of function that each trace in the $$y$$ direction will be (keeping $$x$$ constant). Plot the $$x = -4$$, $$x =-2$$, $$x = 0$$, $$x = 2$$, and $$x = 4$$ traces in 3-dimensional coordinate system in Figure 9.8.
(e) Describe the surface generated by the function $$g$$.

### Contour Maps and Level Curves

We have all seen topographic maps such as the one of the Porcupine Mountains in the upper peninsula of Michigan shown in Figure 9.9.3 The curves on these maps show the regions of constant altitude. The contours also depict changes in altitude: contours that are close together signify steep ascents or descents, while contours that are far apart indicate only slight changes in elevation. Thus, contour maps tell us a lot about three-dimensional surfaces. Mathematically, if $$f(x, y)$$ represents the altitude at the point $$(x, y)$$, then each contour is the graph of an equation of the form $$f(x, y) = k$$, for some constant $$k$$.

Figure 9.9: Contour map of the Porcupine Mountains

Activity $$\PageIndex{6}$$

On the topographical map of the Porcupine Mountains in Figure 9.9,
(a) identify the highest and lowest points you can find;
(b) from a point of your choice, determine a path of steepest ascent that leads to the highest point;
(c) from that same initial point, determine the least steep path that leads to the highest point.

Definition 9.5.

A level curve (or contour) of a function $$f$$ of two independent variables $$x$$ and $$y$$ is a curve of the form $$k = f(x, y)$$, where $$k$$ is a constant.

Topographical maps can be used to create a three-dimensional surface from the two-dimensional contours or level curves. For example, level curves of the range function defined by $$f(x, y) =\dfrac{x^2 \sin(2y)}{32}$$ plotted in the xy-plane are shown in Figure 9.10. If we lift these contours and plot them  at their respective heights, then we get a picture of the surface itself, as illustrated in Figure 9.11.

Figure 9.10: Several level curves.

Figure 9.11: Level curves at the appropriate height.

The use of level curves and traces can help us construct the graph of a function of two variables.

Activity $$\PageIndex{7}$$

(a) Let $$f(x, y) = x^2 + y^2$$. Draw the level curves $$f(x, y) = k$$ for $$k = 1,$$ $$k = 2$$, $$k = 3$$, and $$k = 4$$ on the left set of axes given in Figure 9.12. (You decide on the scale of the axes.) Explain what the surface defined by $$f$$ looks like.

Figure 9.12: Left: Level curves for $$f(x, y) = x^2 + y^2$$. Right: Level curves for $$g(x, y) = \sqrt{x^2+y^2}$$.

(b) Let $$g(x, y) =\sqrt{x^2+y^2}$$.  Draw the level curves $$g(x, y) = k$$ for $$k = 1$$, $$k = 2$$, $$k = 3$$, and $$k = 4$$ on the right set of axes given in Figure 9.12. (You decide on the scale of the axes.) Explain what the surface defined by $$g$$ looks like.
(c) Compare and contrast the graphs of $$f$$ and $$g$$. How are they alike? How are they different? Use traces for each function to help answer these questions.

The traces and level curves of a function of two variables are curves in space. In order to understand these traces and level curves better, we will first spend some time learning about vectors and vector-valued functions in the next few sections and return to our study of functions of several variables once we have those more mathematical tools to support their study.

### A gallery of functions

We end this section by considering a collection of functions and illustrating their graphs and some level curves.

Figure 9.13: $$z = x^2 + y^2$$

Figure 9.14: $$z = 4-(x^2+y^2)$$

Figure 9.15: $$z =\sqrt{x^2+y^2}$$

Figure 9.16: $$z = x^2 -y^2$$

Figure 9.17: $$z = \sin(x) + \sin(y)$$

Figure 9.18: $$z = y^2 -x^3+x$$

Figure 9.19: $$z = xye^{-x^2-y^2} ### Summary A function \(f$$ of several variables is a rule that assigns a unique number to an ordered collection of independent inputs. The domain of a function of several variables is the set of all inputs for which the function is defined. In $$\mathbb{R}^3$$, the distance between points $$P = (x_0, y_0, z_0)$$ and $$Q = (x_1, y_1, z_1)$$ (denoted as $$|PQ|$$) is given by the formula

$|PQ| = \sqrt{(x_1-x_0)^2+ (y_1-y_0)^2 +(z_1-z_0)^2}.$

and thus the equation of a sphere with center $$(x_0, y_0, z_0)$$ and radius $$r$$ is

$(x-x_0)^2 + (y-y_0)^2 +(z-z_0)^2 =r^2.$

A trace of a function $$f$$ of two independent variables $$x$$ and $$y$$ is a curve of the form $$z = f(c, y)$$ or $$z = f(x, c)$$, where $$c$$ is a constant. A trace tells us how the function depends on a single independent variable if we treat the other independent variable as a constant.

A level curve of a function $$f$$ of two independent variables $$x$$ and $$y$$ is a curve of the form $$k = f(x, y)$$, where $$k$$ is a constant. A level curve describes the set of inputs that lead to a specific output of the function.