\(\def\ans#1{\bbox[border:1px solid green,6pt]{#1}}\)

Functions of Two Variables and Their Graphs


We've been graphing curves in space using parametric equations, where x, y, and z vary with respect to t. Now we're going to switch gears a bit and look at graphs of functions like \[z=f(x,y),\] where z is a function of x and y. In other words, each combination of x and y corresponds to a value of z. What will these graphs look like, in general? In two dimensions, we had \(y=f(x)\), which described a curve in the xy plane, as each value of x corresponded to a value of y. Now, in three dimensions, a function \(z=f(x,y)\) will trace out a surface in \(\mathbb{R}^3\), where the height of the surface at any given point \((x,y)\) is \(z\).

For example, consider \[z=\dfrac{\sqrt{2x+y-2}}{x-2}.\] The domain of this function depends on where the denominator is 0 and where the square root in the numerator is negative. Specifically, the domain is \[\ans{D = \{(x,y)\ :\ x \neq 2,\ y \geq -2x+2\}.}\] The graph is shown below (note that Matlab goes a bit wacky at \(x=2\), the discontinuity.


Graph the following equation. Note that it is not actually a function, since it isn't one-to-one. \[\dfrac{x^2}{9}+\dfrac{y^2}{16}+\dfrac{z^2}{25} = 1\]


One way to graph an equation like this is to use traces, which are curves in a plane parallel to one of the coordinate planes. For instance, if we let \(z=0\), we get a graph in the xy plane: \[\dfrac{x^2}{9}+\dfrac{y^2}{16}+\dfrac{0^2}{25} = 1 \longrightarrow \dfrac{x^2}{9}+\dfrac{y^2}{16} = 1\] This is an ellipse with major and minor axes of 4 and 3. For other values of z, we graph ellipses in planes above or below \(z=0\), until \(z=\pm 5\), where the ellipse shrinks to a point.

The graph looks like the following (kind of like an M&M shape):


Graph the following function. \[z=f(x,y)=x^2+y^2\]


Consider different values of z again:

\[\begin{array}{l l l} z & \textrm{Curve} & \textrm{Description}\\ \hline -1 & x^2+y^2=-1 & \textrm{Impossible}\\ 0 & x^2+y^2=0 & \textrm{Point at the origin}\\ 1 & x^2+y^2=1 & \textrm{Circle of radius 1 centered at the origin}\\ 2 & x^2+y^2=2 & \textrm{Circle of radius 2 centered at the origin}\\ 4 & x^2+y^2=4 & \textrm{Circle of radius 4 centered at the origin}\\ 9 & x^2+y^2=9 & \textrm{Circle of radius 9 centered at the origin}\\ \end{array}\]

We'll use Matlab to see the graph of this function:

        	>> fsurf(@(x,y) x.^2+y.^2)

This is called a paraboloid, and as the name suggests, it looks like a parabola in both directions.

The domain of this function is \[D = \{(x,y)\ :\ -\infty < x < \infty,\ -\infty < y < \infty\}\] and the range is \[R = \{z\ :\ 0 \leq z < \infty\}.\]

Level Curves

We've already used level curves; when we held z constant and described the resulting curve in a horizontal plane, we were finding paths where the elevation doesn't change. Think about a topographic map; it shows the level curves of terrain.

Describe the level curves of the following function. \[f(x,y) = y-x^2-1\]


If we hold the function constant (\(f(x,y)=z=z_0\)), we get curves like

\[y-x^2-1=z_0 \longrightarrow y=x^2+1+z_0\]

Since \(1+z_0\) is a constant, these are parabolas.

The graph of the function and a few of the level curves are shown below.

Describe the level curves of the following function. \[f(x,y) = 2+\sin (x-y)\]


Hold \(z\) constant:

\[2+\sin (x-y)=z_0 \longrightarrow y=x-\sin^{-1}(z_0-2)\]

Note that \(\sin^{-1}(z_0-2)\) is a constant, so these are straight lines \(y=x-k\).

The graph of the function is shown below, and you should be able to see that the function stays constant along straight lines.


The electric potential function for two positive charges, one at \((0,1)\) with twice the charge of one at \((0,1)\) is given by

\[\phi (x,y) = \dfrac{2}{\sqrt{x^2+(y-1)^2}} + \dfrac{1}{\sqrt{x^2+(y+1)^2}}\]

First, we'll graph this function using Matlab:

        	>> fsurf(@(x,y) 2./sqrt(x.^2+(y-1).^2) + 1./sqrt(x.^2+(y+1).^2))

  1. For what values of \(x\) and \(y\) is \(\phi\) defined?
  2. Is the electric potential greater at \((3,2)\) or \((2,3)\)?
  3. Describe how the electric potential varies along the line \(y=x\)


  1. Domain: where is the denominator in each term 0? \[\begin{align} x^2+(y-1)^2 = 0 &\longrightarrow (0,1)\\ x^2+(y+1)^2 = 0 &\longrightarrow (0,-1) \end{align}\]

    Therefore, the domain is every point except for these two (the potential approaches infinity near these points).

    \[D = \{(x,y)\ :\ \mathbb{R}^2 \setminus \{(0,1) \cup (0,-1)\}\}\]
  2. Plug these two points into the function: \[\begin{align} \phi (3,2) &= \dfrac{2}{\sqrt{9+1}} + \dfrac{1}{\sqrt{9+9}} \approx 0.868\\ \phi (2,3) &= \dfrac{2}{\sqrt{4+4}} + \dfrac{1}{\sqrt{4+16}} \approx 0.931 \end{align}\]

    Therefore, the potential is greater at \((2,3)\).

  3. Replace \(y\) with \(x\): \[\begin{align} \phi &= \dfrac{2}{\sqrt{x^2+(x-1)^2}} + \dfrac{1}{\sqrt{x^2+(x+1)^2}}\\ &= \dfrac{2}{\sqrt{2x^2-2x+1}} + \dfrac{1}{\sqrt{2x^2+2x+1}} \end{align}\]

The output \(Q\) of an economic system subject to two inputs, such as labor \(L\) and capital \(K\), can be modeled by the Cobb-Douglas production function \[Q (L,K) = cL^aK^b\] where \(a\), \(b\), and \(c\) are positive real numbers.

Suppose \(a=\dfrac{1}{3}\), \(b=\dfrac{2}{3}\), and \(c=40\). We can graph this with Matlab:

        >> fsurf(@(x,y) 40.*x.^(1/3).*y.^(2/3))

If \(L\) is held constant at 10, find the dependence of \(Q\) on \(K\).



This is a trace along a vertical plane.

Try it yourself:

(click on a problem to show/hide its answer)

  1. Find the domain of \(f(x,y) = 2xy-3x+4y\).
  2. \(D = \{(x,y)\ :\ -\infty < x < \infty,\ -\infty < y < \infty\}\)

  3. Find the domain of \(f(x,y) = \dfrac{12}{y^2-x^2}\).
  4. \(D = \{(x,y)\ :\ y \neq \pm x\}\)

  5. Find the domain of \(f(x,y) = \sqrt{25-x^2-y^2}\).
  6. \(D = \{(x,y)\ :\ x^2+y^2 \leq 25\}\)

  7. Find the domain of \(f(x,y) = \ln(x^2-y)\).
  8. \(D = \{(x,y)\ :\ y < x^2\}\)

  9. Describe the level curves of \(z=x-y^2\).
  10. These are horizontal parabolas \(x=y^2+z_0\).

  11. Describe the level curves of \(z=2x-y\).
  12. These are straight lines \(y=2x-z_0\).

  13. Describe the level curves of \(z=3\cos(2x+y)\).
  14. These are straight lines \(y=\cos^{-1}\left(\dfrac{z_0}{3}\right)-2x\).