For full functionality of this site it is necessary to enable JavaScript. Here are the instructions how to enable JavaScript in your web browser.

# Chapter 4: Functions of Two Variables

## Pre-Calculus Idea – Topological Maps

If you’ve ever hiked, you have probably seen a topographical map. Here is part of a topographic map of Stowe, Vermont.

Points with the same elevation are connected with curves, so you can read not only your east-west and your north-south location, but also your elevation. You may have also seen weather maps that use the same principle – points with the same temperature are connected with curves (isotherms), or points with the same atmospheric pressure are connected with curves (isobars). These maps let you read not only a places location but also its temperature or atmospheric pressure.

In this chapter, we will use that same idea to make graphs of functions of two variables.

# Section 4.1: Functions of Two [Indepedent] Variables

## Introduction

Real life is rarely as simple as one input / one output. Many relationships depend on lots of variables. Examples:

• If I put a deposit into an interest-bearing account and let it sit, the amount I have at the end of 3 years depends on $$P$$ (how much my initial deposit is), $$r$$ (the annual interest rate), and $$n$$ (the number of compoundings per year).
• The air resistance on a wing in a wind tunnel depends on the shape of the wing, the speed of the wind, the wing's orientation (pitch, yaw, and roll), plus a myriad of other things that I can't begin to describe.
• The amount of your television cable bill depends on which basic rate structure you have chosen and how many pay-per-view movies you ordered.

Since the real world is so complicated, we want to extend our calculus ideas to functions of several variables.

## Functions of Two Variables

If $$x_1, x_2, x_3, \dots, x_n$$ are real numbers, then $$(x_1, x_2, x_3, \dots, x_n)$$ is called an $$n$$-tuple. This is an extension of ordered pairs and triples. A function of n variables is a function whose domain is some set of $$n$$-tuples and whose range is some set of real numbers.

For much of what we do here, everything will work the same whether we were working with 2, 3, or 47 variables. Because we're trying to keep things a little bit simpler, we'll concentrate on functions of two variables.

#### A Function of Two Variables

A function of two variables is a function, that is, to each input is associated exactly one output.

The inputs are ordered pairs, $$(x, y)$$. The outputs are real numbers (each output is a single real number). The domain of a function is the set of all possible inputs (ordered pairs); the range is the set of all possible outputs (real numbers).

The function can be written $$z = f(x,y)$$.

Functions of two variables can be described numerically (a table), graphically, algebraically (a formula), or in English.

We will often now call the familiar $$y = f(x)$$ a function of one variable.

#### Example 1

The cost of renting a car depends on how many days you keep it and how far you drive. Represent this using a function.

Let $$d$$ be the number of days you rent the car, and $$m$$ be the number of miles you drive. Then the cost of the car rental $$C(d, m)$$ is a function of two variables.

#### Example 2

The demand for hot dog buns depends on the price for the hot dog buns and also on the price for hot dogs. Represent this as a function.

The demand $$q_B=f\left(p_B,p_D \right)$$ is a function of two variables. (The demand for hot dogs also depends on the price of both dogs and buns).

## Formulas and Tables

Just as in the case of functions of one variable, we can display a function of two variables in a table. The two inputs are shown in the margin (top row, left column), and the outputs are shown in the interior cells.

#### Example 3

Here is a table that shows the cost $$C(d, m)$$ in dollars for renting a car for $$d$$ days and driving it $$m$$ miles:

 $$d$$ (labels in left column), $$m$$ (labels in top row) 100 200 300 400 1 55 70 85 100 2 95 110 125 140 3 135 150 165 180
1. What is the cost of renting a car for 3 days and driving it 200 miles?
2. What is $$C(100, 4)$$? What is $$C(4, 100)$$?
3. Suppose we rent the car for three days. Is $$C$$ an increasing function of miles?
1. According to the table, renting the car for three days (row with $$d = 3$$) and driving it 200 miles (column with $$m = 200$$) will cost $150 (italicized in the table). 2. Careful now – the input is an ordered pair, so in $$C(100, 4)$$, the 100 has to be a value of $$d$$ and the 4 has to be a value of $$m$$. $$C(100, 4)$$ would be the cost of renting a car for 100 days and driving it 4 miles. That cost is not in the table. (And that would be a pretty silly way to rent a car.) On the other hand, $$C(4, 100)$$ is the cost of renting for 4 days and driving 100 miles – the table says that would cost$175.
3. If we know that $$d$$ is fixed at 3, we're looking at $$C(3, m)$$. This is now a function of one variable: just $$m$$. We can see the table that displays values of this function by focusing our attention on just the row where $$d = 3$$:

 $$d$$ (label in left column), $$m$$ (labels in top row) 100 200 300 400 3 135 150 165 180

Now we can see that if we rent for 3 days, the cost appears to be an increasing function of the number of miles we drive, which shouldn't be surprising.

The idea of fixing one variable and watching what happens to the function as the other varies will come up again and again.

It's hard to display a function of more than two variables in a table. But it's convenient to work with formulas for functions of two variables, or as many variables as you like.

#### Example 4

The cost $$C(d,m)$$ in dollars for renting a car for $$d$$ days and driving it $$m$$ miles is given by the formula $C(d,m)=40d+0.15m.$

1. What is the cost of renting a car for 3 days and driving it 200 miles?
2. What is $$C(100, 4)$$? What is $$C(4, 100)$$?
3. Suppose we rent the car for 3 days. Is $$C$$ an increasing function of miles?
1. $$C(3,200)=40(3)+0.15(200)=\150$$. This is the same value we got from the table. The formula will give us the same answers for any of the table values.
2. $$C(100, 4)$$ makes perfect sense to the formula (even if it doesn't make sense for actually renting a car). So now we can get an answer. To rent the car for 100 days and drive it for 4 miles should cost 4000.60. $$C(4, 100) = \175$$, as before. 3. If we fix $$d = 3$$, then $$C(d, m)$$ becomes $$C(3, m) = 40(3) + 0.15m = 120 + 0.15m$$. Yes, this is an increasing function of $$m$$ – we can tell because it's linear and its slope is $$0.15 \gt 0$$. Reality check – the formula that gives the cost for the rental car makes sense for all values of $$d$$ and $$m$$. But that's not how the real cost works – you can't rent the car for a negative number of days or drive a negative number of miles. (That is, there are domain restrictions.) In addition, most car rental agreements don't compute a charge for fractions of days; they round up to the next whole number of days. #### Example 5 Let $$f(x,y,z,w)=35x^2w-\frac{1}{z}+yz^2$$. Evaluate $$f(0,1,2,3)$$. Remember that this is an ordered 4-tuple; make sure the numbers get substituted into the correct places: $f(0,1,2,3)=35(0)^2(3)-\frac{1}{2}+(1)(2)^2=3.5$ ## Graphs The graph of a function of two variables is a surface in three-dimensional space. Let's start by looking at the 3-dimensional rectangular coordinate system, how to locate points in three dimensions, and distance between points in three dimensions. In the 2-dimensional rectangular coordinate system we have two coordinate axes that meet at right angles at the origin, and it takes two numbers, an ordered pair $$(x, y)$$, to specify the rectangular coordinate location of a point in the plane (two dimensions). Each ordered pair $$(x, y)$$ specifies the location of exactly one point, and the location of each point is given by exactly one ordered pair $$(x, y)$$. The $$x$$ and $$y$$ values are the coordinates of the point $$(x, y)$$. The situation in three dimensions is very similar. In the 3-dimensional rectangular coordinate system we have three coordinate axes that meet at right angles, and three numbers, an ordered triple $$(x, y, z)$$, are needed to specify the location of a point. Each ordered triple $$(x, y, z)$$ specifies the location of exactly one point, and the location of each point is given by exactly one ordered triple $$(x, y, z)$$. The $$x$$, $$y$$, and $$z$$ values are the coordinates of the point $$(x, y, z)$$. The figure below shows the location of the point (4, 2, 3). Typically we use a right-hand orientation. To see what this means, imagine your right hand in front hand in front of you with the palm toward your face, your thumb pointing up, you index finger straight out, and your next finger toward your face (and the two bottom fingers bent into the palm). Then, in the right hand coordinate system, your thumb points along the positive $$z$$-axis, your index finger along the positive $$x$$-axis, and the other finger along the positive $$y$$-axis. Other orientations of the axes are possible and valid (with appropriate labeling), but the right-hand system is the most common orientation and is the one we will generally use. If another orientation is used, then the axes will be explicitly labeled. Each ordered triple $$(x, y, z)$$ specifies the location of a single point, and this location point can be plotted by locating the point $$(x, y, 0)$$ on the $$xy$$-plane and then going up $$z$$ units (the red path in the figure below). We could also get to the same $$(x, y, z)$$ point in other ways. For instance, we could start by finding the point $$(x, 0, z)$$ on the $$xz$$-plane and then going $$y$$ units parallel to the $$y$$-axis, or by finding $$(0, y, z)$$ on the $$yz$$-plane and then going $$x$$ units parallel to the $$x$$-axis (the blue path in the figure above). #### Example 6 Plot the locations of the points • $$P=(0,3,4)$$, • $$Q=(2,0,4)$$, • $$R=(1,4,0)$$, • $$S=(3,2,1)$$, and • $$T=(-1,2,1)$$. The points are shown below. Once we can locate points, we can begin to consider the graphs of various collections of points. By the graph of $$z = 2$$ we mean the collection of all points $$(x, y, z)$$ which have the form $$(x, y, 2)$$. Since no condition is imposed on the $$x$$ and $$y$$ variables, they take all possible values. The graph of $$z = 2$$ is a plane parallel to the $$xy$$-plane and 2 units above the $$xy$$-plane. Similarly, the graph of $$y = 3$$ is a plane parallel to the $$xz$$-plane, and $$x = 4$$ is a plane parallel to the $$yz$$-plane. (Note: The planes have been drawn as rectangles, but they actually extend infinitely far.) ### Distance Between Points In two dimensions we can think of the distance between points as the length of the hypotenuse of a right triangle, and that leads to the Pythagorean formula: $\text{distance}=\sqrt{\Delta x^2+\Delta y^2}.$ In three dimensions we can also think of the distance between points as the length of the hypotenuse of a right triangle. In this situation the calculations may appear more complicated, but they are straightforward and the final formula is what we hope it would be given the 2-dimensional formula: \begin{align*} \text{distance}^2=& \text{base}^2+\text{height}^2 \\ =& \left(\sqrt{\Delta x^2+\Delta y^2}\right)^2+\Delta z^2 \\ =& \Delta x^2+\Delta y^2+\Delta z^2 \end{align*} so $\text{distance}=\sqrt{\Delta x^2+\Delta y^2+\Delta z^2}.$ #### Distance in 3-Dimensions If $$P = (x_1 , y_1 , z_1 )$$ and $$Q = (x_2 , y_2 , z_2 )$$ are points in space, then the distance between $$P$$ and $$Q$$ is \begin{align*} \text{distance}=& \sqrt{\Delta x^2+\Delta y^2+\Delta z^2} \\ =& \sqrt{\left(x_2-x_1\right)^2+\left(y_2-y_1\right)^2+\left(z_2-z_1\right)^2} \end{align*} The 3-dimensional pattern is very similar to the 2-dimensional pattern with the additional piece $$\Delta z^2$$. #### Example 7 Find the distances between points $$A = (1, 2, 3)$$ and $$B = (7, 5, –3)$$. $\text{Dist}(A,B)=\sqrt{6^2+3^2+(-6)^2}=\sqrt{36+9+36}=\sqrt{81}=9.$ In two dimensions, the set of points at a fixed distance from a given point is a circle, and we used the distance formula to determine equations describing circles: the circle with center (2, 3) and radius 5 is given by $$(x–2)^2 + (y–3)^2 = 5^2$$ or $$x^2 + y^2 – 4x – 6y = 12$$. The same ideas work for spheres in three dimensions. #### Spheres The set of points $$(x, y, z)$$ at a fixed distance $$r$$ from a point $$(a, b, c)$$ is a sphere with center $$(a, b, c)$$ and radius $$r$$. The sphere is given by the equation $(x-a)^2+(y-b)^2+(z-c)^2=r^2.$ #### Example 8 Write the equations of a sphere with center (2, -3, 4) and radius 3. The equation is $(x-2)^2+(y+3)^2+(z-4)^2=3^2.$ Now suppose that we want to graph a surface. We can think of each input $$(x,y)$$ as a location on the plane, and plot the point $$f(x,y)$$ units above that point. Graphing that can be challenging. We have a few options: 1. Use a computer program (such as GeoGebra or Mathematica) to draw beautiful perspective drawings. If such a program is available, then this is usually the most accurate option. 2. Try to draw a perspective drawing by hand. This is very challenging, and usually not worth the effort. 3. Use level curves to draw contour diagrams (or contour maps), which is the approach we'll focus on here. A contour diagram is like a topographical map – points with the same elevation (outputs) are connected with curves. Each particular output is called a level, and these curves are called level curves or contours. The closer the curves are to each other, the steeper that section of the surface. Topographical maps give hikers information about elevation, steep and shallow grades, peaks and valleys. Contour diagrams give us the same kind of information about a function. Below is a contour diagram of the same surface shown in above. The level curves are graphs in the $$xy$$-plane of curves $$f(x, y) = c$$ for various constants $$c$$. Each of the squares corresponds to one of the bumps on the surface. If the contours are positive, as highlighted below, the bump is above the $$xy$$-plane. If the contours are negative, the bump extends below the $$xy$$-plane. Everywhere on the crisscrossed pattern of diagonal lines, the height of the surface is 0, so the surface is on the $$xy$$-plane. This is a feature that we wouldn't necessarily have seen when we looked at the perspective drawing. Contour maps can help us see features of the surface that the 3-dimensional graph doesn't show. To better understand contour diagrams, suppose we had a table of elevation data. We could graph this by plotting the height at each point and connecting the dots with smooth curves, which would result in the something like the graph shown. If we slice the surface above with the plane $$z = 8$$, the points where the plane cuts the surface are those points where the elevation of the surface is 8 units above the $$xy$$-plane. The figure below shows the surface being sliced by the planes $$z = 8$$ and $$z = 4$$. Slicing the surface at different elevations and sketching the curves where the plane intersects the surface results in the second graph below. If we move all of those curves to the xy–plane (or, equivalently, view them from directly overhead), the result is a 2-dimensional graph of the level curves of the original surface. This is the contour diagram. #### Example 9 Create a contour diagram for our car rental example with cost function $$C(d,m)=40d+0.15m$$. Draw curves for when the cost is 0, 100, 200, 300, and 400. We'll set $$C(d,m)=40d+0.15m=c$$ for $$c =$$ 0, 100, 200, 300, and 400 and draw the curves in the $$dm$$-plane. The first coordinate of the ordered pair is $$d$$, so the $$d$$-axis will be horizontal; the $$m$$-axis will be vertical. Remember that the domain for this function is really just where $$d \geq 0$$ and $$m \geq 0$$, so we will only draw the curves in the first quadrant. When $$c=0$$: \begin{align*} C(d,m)=& 40d+0.15m=0 \\ 0.15m=& -40d \\ m=& -\frac{40}{0.15}d\approx -267d \end{align*} This is the equation of a line, with slope about -267, passing through the origin. Because of the domain restrictions, the curve we will draw for this level is simply the origin. Putting this back into the car rental context, the only point where we pay0 for renting the car is when we rent the car for 0 days and drive it 0 miles – that is, if we don't rent it at all.

When $$c=100$$: \begin{align*} C(d,m)=& 40d+0.15m=100 \\ 0.15m=& -40d+100 \\ m=& -\frac{40}{0.15}d+\frac{100}{0.15}\approx -267d+667 \end{align*}

This is the equation of a line, with slope about -267, and $$d$$-intercept of about 667. This section of this line that lies in the first quadrant is shown with 100 labeling it.

Putting this into context, any point on that line represents a $$(d, m)$$ combination of days and miles that will make the cost exactly $100. So, for example – if we rent the car for 0 days and drive it 667 miles, it will cost us$100. If we rent the car for 2.5 days and don't drive any miles, it will cost us $100. We continue for $$c =$$ 200, 300, and 400 and sketch the curves in the plane, resulting in the contour diagram shown to the right. #### Example 10 The contour diagram for the cost $$C(d,m)$$ in dollars for renting a car for $$d$$ days and driving it $$m$$ miles is shown in the previous example. Use the diagram to answer the following questions. 1. What is the cost of renting a car for 3 days and driving it 200 miles? 2. What is $$C(100, 4)$$? What is $$C(4, 100)$$? 3. Suppose we rent the car for 3 days. Is $$C$$ an increasing function of miles? 1. The point (3, 200) is between contours on this graph, so we can’t get an exact answer for $$C(3, 200)$$. (But it’s typical for a graph that we would have to estimate). It looks to me as if (3, 200) is halfway between the 100 and the 200 contours, so let's estimate that $$C(3, 200)$$ is about$150.

Estimates from the graph are necessarily very rough. The graph only shows a little information (in this way, a contour diagram is like a table), so we have to extrapolate in between. But for most graphs, we don’t actually know what happens between the contours. All we know for sure is that the output at (3, 200) is between the two levels we see. For this car rental example, we also know a formula, and my table showed this particular input, so we have other ways to get a better answer.

### Cobb-Douglas Production Function

Production functions are used to model the total output of a firm for a variety of inputs (doesn't this sound like a function of several variables?). One example is a Cobb-Douglas Production function: $P=AL^{\alpha}K^{\beta}$

In this function $$P$$ is the total production, $$A$$ is a constant, $$\alpha$$ and $$\beta$$ are constants between 0 and 1, $$L$$ is the labor force, and $$K$$ is the capital expenditure. (The units must be massaged well.)