Multivariate Functions

Published

Mon, Feb 9

In Precalc, Calc I, Calc II, and just about all math classes prior to Calc III, you study functions mapping \(\mathbb R \to \mathbb R.\) Calculus III, though, is all about increasing the dimension in which we work. In the study of parametric/vector functions, we study functions mapping \(\mathbb R \to \mathbb R^n\), i.e. we increase the dimension of the range. We often think of the input as time so that we’re studying motion.

Now, we’re going to study functions mapping \(\mathbb R^n \to \mathbb R\), i.e. we increase the dimension of the domain.

Bivariate functions

A bivariate function is a real valued function of two variables, i.e. \(f:\mathbb R^2 \to \mathbb R\). Let’s start there.

Graphs of bivariate functions

The graph of a bivariate function is the set \[ \{(x,y,z)\in\mathbb R^3: z = f(x,y)\}. \] In general, this looks like a surface:

You can use the menu below to examine several of these things.

Contour plots

A contour plot offers another way to visualize bivariate functions. Given \(f(x,y)\), the idea is to consider the family of curves \[f(x,y) = k,\] for a select set of values of \(k\). If \(f(x,y)=x^2+y^2\), then each contour is a circle centered at the origin, for example.

The select menu below allows you to examine several of these things. It might be instructive to examine the common values in both menus.

The peaks function

The folks at Mathworks created a fun function called the peaks function that’s interesting to view as both a graph and as a contour plot. The formula for the peaks function is \[ f(x,y) = 3 \, (1-x)^2 e^{-x^2-(y+1)^2}-10 \, e^{-x^2-y^2} \left(-x^3+\frac{x}{5}-y^5\right)-\frac{1}{3} \, e^{-(x+1)^2-y^2}. \] Yeah, it’s complicated. Effectively, this is a combination of shifted normal distributions in two variables \(e^{-(x^2+y)^2}\).

The graph of the peaks function looks like so:

Here’s a contour plot:

And here’s another graph that emphasizes the relationship between those two:

The peaks function was built to illustrate some of the challenges involved in multivariate optimization.

Higher dimensions

You can talk about functions of as many variables as you might want.

Examples

Three variables: The ideal gas law relates pressure \(P\), volume \(V\), amount (i.e. number of moles) \(n\), and temperature \(T\) via \(PV=nRT\). Note that \(R\) is a constant called the ideal gas constant. We could solve this for \(P\) to get pressure as a function of the three variables \(n\), \(T\), and \(V\): \[P = \frac{nRT}{V}. \]

Four variables: The mass of a box of uniform density is the product of its length \(\ell\), width \(w\), height \(h\), and density \(\rho\): \[ m = \ell \times w \times h \times \rho. \]

Five variables: The force between two objects with masses \(m_1\) and \(m_2\) with a displacement vector \(\langle x,y,z \rangle\) between them can be expressed as a function of five variables: \[ F(m_1,m_2,x,y,z) = G \frac{m_1 m_2}{x^2 + y^2 + z^2} \]

I could go on.

Even more variables

The graph of a function of three variables lives in four dimensional space so I guess we don’t draw those.

We can draw the contours of functions of three variables, though, and they are often called level surfaces in that context. Here are a few examples:

Better, we can plot a collection of level surfaces. When doing so, it might make sense to slice them in some way to reveal things that would otherwise be obscured. We could also include a fourth variable using color to yield an animation. The animation below, for example, indicates how a solid, hot sphere might cool when dropped in an ice bath.

This example uses partial differential equations and you can learn more about the implementation in this dynamic notebook.

Using Desmos

It’s pretty easy to plot functions of two variables with Desmos3D:

You can also plot level surfaces with Desmos3D:

And you can plot good old level curves with plain old Desmos:

Problems

  1. The contour diagram of \(f(x,y)=(x + y)\cos(x)\cos(y)/2\) is shown in Figure 1. Mark the locations of any maxima, minima, or saddle points that you see.

  2. Match the groovy function below with the groovy graph shown in Figure 2.

    1. \(\vec{p}(t) = \langle 2\cos(t), \sin(t) \rangle\)
    2. \(\vec{p}(t) = \langle 2t\cos(t), t\sin(t) \rangle\)
    3. \(\vec{p}(t) = \langle 2\cos(t), \sin(t), t/4 \rangle\)
    4. \(f(x,y) = 1 - (4 x^2 + y^2)\)
    5. \(f(x,y) = e^{-(4 x^2 + y^2)}\)
    6. \(x^2 + 4 y^2 + 4 z^2 = 4\)
  3. Sketch contour diagrams of the following functions:

    1. \(f(x,y) = 9x^2 + y^2\)
    2. \(f(x,y) = 9x^2 - y^2\)
    3. \(f(x,y) = 9x - y\)
    4. \(f(x,y) = x\,y\)
Figure 1: A contour diagram for \(f(x,y)=(x + y)\cos(x)\cos(y)/2\)
Figure 2: Some groovy graphs