$$ \newcommand{\RR}{\mathbb{R}} \newcommand{\QQ}{\mathbb{Q}} \newcommand{\CC}{\mathbb{C}} \newcommand{\NN}{\mathbb{N}} \newcommand{\ZZ}{\mathbb{Z}} \newcommand{\EE}{\mathbb{E}} \newcommand{\HH}{\mathbb{H}} \newcommand{\SO}{\operatorname{SO}} \newcommand{\dist}{\operatorname{dist}} \newcommand{\length}{\operatorname{length}} \newcommand{\uppersum}[1]{{\textstyle\sum^+_{#1}}} \newcommand{\lowersum}[1]{{\textstyle\sum^-_{#1}}} \newcommand{\upperint}[1]{{\textstyle\smallint^+_{#1}}} \newcommand{\lowerint}[1]{{\textstyle\smallint^-_{#1}}} \newcommand{\rsum}[1]{{\textstyle\sum_{#1}}} \newcommand{\partitions}[1]{\mathcal{P}_{#1}} \newcommand{\erf}{\operatorname{erf}} \newcommand{\ihat}{\hat{\imath}} \newcommand{\jhat}{\hat{\jmath}} \newcommand{\khat}{\hat{k}} \newcommand{\pmat}[1]{\begin{pmatrix}#1\end{pmatrix}} \newcommand{\smat}[1]{\left(\begin{smallmatrix}#1\end{smallmatrix}\right)} $$

8  Graphs & Level Sets

So far in this course we have been studying parametric curves. These are functions which have a single input (the parameter) and multiple outputs (perhaps \(x,y,z\) or a color for each pixel of an image, etc.) Now we turn to reverse the situation, a function which has multiple inputs but a single output! These are sometimes called multivariable functions (to emphasize the number of inputs), but also are called scalar functions (to emphasize the output is a single number, or a scalar).

In physics, functions with multiple inputs are often called fields. So yet another name for this class of things is a scalar field! Just as I have done in these notes elsewhere (with vector notation, for example) I will try to use all of these terms to help you prepare for the real world where there’s no standardization.

Definition 8.1 (Multivariate Function) A function \(f\colon\RR^n\to\RR\) taking in an \(n\)-tuple of real numbers, and outputting a single real number.

uch a function is written \(f(x,y,z,\ldots)\) for example \[f(x,y,z)=2x^2-3x+sin(e^z)\] The domain of a scalar function is the set of inputs for which the function makes sense.

Example 8.1 The domain of \(f(x,y)=\ln(x^2+y^2-1)\) is the exterior of the unit circle in the plane \(D=\{(x,y)\mid x^2+y^2>1\}\). This is because the logarithm of zero or a negative nuumber is underfined, so the only allowable inputs are when \(x^2+y^2-1\) is positive.

Our goal in this chapter is to get comfortable with multivariable functions from two different perspectives: drawing graphs and drawing level sets.

8.0.1 Examples

Scalar fields show up everywhere in mathematics and the sciences. Consider the temperature in a room: this is a function that takes in a point (say, with three coordinates \((x,y,z)\) ) and returns a single number - the temperature of the air at that point in space. This is then a function \(T\colon\RR^3\to \RR\).

If we wanted to track the temperature over time, this could be done with a function \(\RR^4\to\RR\) which takes \((x,y,z,t)\) and returns the temperature there.

Of course - temperature is just an arbitrary (but conceptually useful!) example. Any quantity you can measure at differet points in space(time) gives a scalar function of 3 or 4 variables!

Exercise 8.1 Come up with some examples of scalar functions that you think about in daily life (without necessarily having ever thought about them mathematically!)

8.1 Graphs

The graph of a 1-variable function \(f\) is a curve in the plane: its the set of points \((x,y)\) where \(y=f(x)\). We can make a similar definition for the graph of a scalar function

Definition 8.2 The graph of a function \(f\colon\RR^n\to\RR\) is a subset of \(\RR^{n+1}\): its the set of points \((\vec{x},y)\) where \(\vec{x}\in\RR^n\) and \(y=f(\vec{x})\).

This isn’t that useful for visualizing unless dimenisons are pretty small! If there are \(n\) inputs and \(1\) output we need \(n+1\) dimensions to put them all on a graph. And, if we want to actually see the graph it better fit inside of 3D space so \(n\) can only be 1 (the case we already know!) or \(2\).

If \(n=2\), then we have two input variables and its easiest to think of them as being on the \(xy\) plane. Then we may name the output variable \(z\), and plot our function \(z=f(x,y)\) as the points \((x,y,f(x,y))\) in 3D space.

Here’s a graphing calculator for functions \(z=f(x,y)\):

8.1.1 How to Draw Graphs

Drawing a 3D graph is difficult to do in general: but often we can use our knowledge of 2D graphs to try and build up an understanding by slicing. The idea is to take a function \(z=f(x,y)\) and plug in constant values for one of the variables, then try to stack these slices to get a model of the entire surface.

Example 8.2 (Slicing \(z=xy\)) Draw the slices of \(z=xy\) - When \(y=0\) this is the horizongal line \(z=0\) - When \(y=1\) this is the line \(z=x\) - When \(y=2\) this is the line \(z=2x\)

Thus, as \(y\) increases, the slope of the graph’s cross section increases!

Example 8.3 (Slicing \(z=ye^x\)) Here the slices for \(y=0\), \(y=1\) and \(y=2\) look like \(0\) \(e^x\) and \(2e^x\). They are copies of the exponential getting steeper and steeper.

Example 8.4 (Slicing \(z=x^2+y^2\)) Slices of this function are parabolas in both the \(x\) and \(y\) directions. Fixing \(y\) equal to different values, the parabolas shift upwards! For \(y=0,1,2\) we get \[z=x^2,\hspace{0.5cm}z=x^2+1\hspace{0.5cm}z=x^2+4\]

8.1.2 Useful Graphs to Know

There are a couple multivariable functions whose graphs are good to know. Indeed - we’ve already met some of these before! If \(f(x,y)\) is a linear equation like \(ax+by+c\), the graph is the set of points

\[z=ax+by+c\]

This is a plane! (It might help to rewrite as \(ax+by-z=-c\) to see its an implicit equation, with normal vector \(\langle a,b,-1\rangle\).)

What about \(z=x^2+y^2\)? We saw this one above in our discussion of slicing, and we also saw it earlier (in “Shapes”): its a parabola of revolution!

The graph of \(z=x^2+y^2\)

Another useful function to know is the saddle surface \(z=x^2-y^2\). We also met this one back in the discussion of “Shapes”.

The graph of \(z=x^2-y^2\)

8.2 Level Sets

Above we looked at one means of drawing a graph by slicing: we attempted to slice it by vertical planes into the graphs of simpler 1-dimensional functions that we already knew! This works sometimes, but if you can’t quickly stack the slices into a coherent image in your mind, knowing the slices won’t help you with much else.

So here, we seek other methods of understanding these functions, beyond their graphs. By far the most useful way to depict multivariable functions is by instead slicing with horizontal planes and drawing their level sets.

Definition 8.3 (Level set) The level set corresponding to \(c\in\RR\) for a function \(f(x,y)\) is the set of points in the plane that \(f\) maps to \(c\):

\[L_c = \{(x,y)\mid f(x,y)=c\}\]

Here’s a graphing calculator that will draw for you the level sets of a function: I often think about “sea level” when I think of a level set - a coastline is the level set \(h(x,y)=0\) above the water. And different level sets correspond to what the coastlines would be if the sea was different heights.

A contour plot is a drawing of the domain of a function, with level sets representing various values of the range. These are perhaps most familiar from elevation maps. Drawing multiple level sets at once gives a good sense of the behavior of the entire function, though its most effective when the individual level sets are labled somehow (often by color) so you can get a sense of their relative values.

A topographic map of San Francisco

Some Level curves of the map. Can you see lone mountain?

Below, we draw the same map but only plot the level curve corresponding to 200ft above sea level. \[L_{200}=\{(x,y)\mid h(x,y)=200\}\]

The 200ft-level set

A single level set of a function is actually something that you’ve encountered in previous courses: we called it an implicit equation as it defines a shape implicitly by saying \((x,y)\) lives on the curve if \(h(x,y)\) has a specific value - instead of specifying it explicitly liek a function.

Some contour plots of various functions.

Below is a graphing calculator to let you draw some contour plots. Can you imagine the 3D shape from its 2D slices?

After looking at several functions and their level sets, you’ll start to notice that there are a couple “important behaviors” that show up again and again. These are

  • Concentric rings, around a point
  • Nearly parallel lines
  • Two lines crossing each other.

These signify three important types of behaivor, which we can see by looking back to our “useful graphs to know”

Concentric rings around a point signifies the function has either a maximum or a minimum there.

Nearly parallel lines means the function is increasing or decreasing there.

Two lines crossing means that we are at a saddle shaped point on our graph - it increases in two directions and decreases in the other two.

It turns out, that all behavior of level sets is built out of these three basic behaivors.

8.3 Functions of \(\geq 3\) Variables

Drawing a contour plot is a form of dimension reduction: we’ve managed to understand the behavior of a function \(f\) whose graph \(z=f(x,y)\) lies in 3 dimensional space, by only looking at a 2-dimenisonal image (its domain, covered in level sets).

This technique can help us level up our intuition to functions of three variables: things like \(w=f(x,y,z)\) whose graphs would naturally live in four dimensional space!

Exercise 8.2 What do the level sets of the function \(w=x^2+y^2+z^2\) look like, for different values of \(w\)?

In three dimensions there are more types of basic behavior than the ones we saw in 2D. You don’t need to learn all of them: but to try and get some intuition for the fourth dimension its a good exercise to try and imagine what the graphs of these functions must be like, if their contours are drawn below.

Three dimensional level sets describe implicit surfaces which are extremely useful objects. As we’ve already seen with curves, sometimes writing down a paramterization can be hard. Adn this is even more true for surfaces! So having another way to express complicated ones can be a huge help. Below are two examples where I have used implicit surfaces in mathematical rendering.

The implicit surface \(\sin(x)\cos(t)+\sin(y)\cos(z)+\sin(z)\cos(x)=0\). This is a good approximation to a particularly important mathematical surface called the gyroid.

This surface is called the Barth Decic and arises in a field of mathematics called algebraic geometry. Its equation is given below

\[\begin{align*} & 8 (x^2 - p^4 y2^) (y^2 - p^4 z^2) (z^2 - p^4 x^2) \left(x^4 + y^4 + z^4 - 2 x^2 y^2 - 2 x^2 z^2 - 2 y^2 z^2\right) \\ &+a (3 + 5 p) \left((x^2 + y^2 + z^2 - a)\right)^2 \left((x^2 + y^2 + z^2 - (2-p) a)\right)^2\\ &= 0 \end{align*}\]

8.4 Videos

The Calculus Blue Series introduction to multivariate functions:

The Calculus Blue series on Level Sets: