Chapter 13. Level curves (aka contour plots)

§13.1 [TEXT] Level curves replace 𝑥𝑦-graphs

In high school and 18.01, you were usually taught to plot single-variable functions in two dimensions, so 𝑓(𝑥)=𝑥2 would be drawn as a parabola 𝑦=𝑥2, and so on. You may have drilled into your head that 𝑥 is an input and 𝑦 is an output.

However, for 18.02 we’ll typically want to draw pictures of functions like 𝑓(𝑥,𝑦)=𝑥2+𝑦2 in a different way14, using what’s known as a level curve.

Definition
For any number 𝑐 and function 𝑓(𝑥,𝑦) the level curve for the value 𝑐 is the plot of points for which 𝑓(𝑥,𝑦)=𝑐.

The contrast to what you’re used to is that:

To repeat that in table format:

18.01 𝑥𝑦-graphs18.02 level curves
𝑥 is inputBoth variables are inputs
𝑦 is outputNo variable name for output
Table 5: Comparison between 18.01 𝑥𝑦-graphs and 18.02 level curve pictures.

We give some examples.

Example: the level curves of 𝑓(𝑥,𝑦)=𝑦−𝑥2

To draw the level curves of the function 𝑓(𝑥,𝑦)=𝑦−𝑥2, we begin by recalling that a level curve corresponds to the points (𝑥,𝑦) such that the function takes on a constant value, say 𝑐. For our function, this becomes:

𝑦−𝑥2=𝑐

which rearranges to

𝑦=𝑥2+𝑐.

Let’s talk through some values of 𝑐.

  • As an example, if 𝑐=0, then some points on the level curve would be (−3,9), (−2,4), (−1,1), (0,0), (1,1), (2,4), (3,9), or even (5,5) and (11,11). You probably already recognize what’s happening: 𝑦=𝑥2 happens to be an equation you met before in 18.01 form, so you get a parabola. (More generally, if you get an equation in 18.01 form where 𝑦 is a function of 𝑥, you can sketch it like you did before).
  • If we change the value of 𝑐=2, this equation represents a family of parabolas. For example, the level curve for 2 will be the parabola with points like (−2,6), (−1,3), (0,2), (1,3), (2,6).

In general, as 𝑐 varies, the level curves are parabolas that shift upward or downward along the 𝑦-axis. The shape of these curves is determined by the quadratic term 𝑥2, which indicates that all level curves will have the same basic “U” shape.

Figure 29: The level curves of 𝑓(𝑥,𝑦)=𝑦−𝑥2.
Example: the level curves of 𝑓(𝑥,𝑦)=𝑥−𝑦2

Let’s draw level curves for 𝑓(𝑥,𝑦)=𝑥−𝑦2. This example is exactly like the previous one, except the roles of 𝑥 and 𝑦 are flipped.

Figure 30: The level curves of 𝑓(𝑥,𝑦)=𝑥−𝑦2.
Example: the level curves of 𝑓(𝑥,𝑦)=𝑥2+𝑦2

Let’s draw level curves of 𝑓(𝑥,𝑦)=𝑥2+𝑦2. For each 𝑐 we want to sketch the curve

𝑥2+𝑦2=𝑐.

When 𝑐<0, no points at all appear on this curve, and when 𝑐=0 the only point is the origin (0,0). For 𝑐>0 this equation represents a family of circles centered at the origin (0,0), with radius 𝑐. For example:

  • For 𝑐=1, the level curve is a circle with radius 1.
  • For 𝑐=4, the level curve is a circle with radius 2.
  • For 𝑐=9, the level curve is a circle with radius 3.

As 𝑐 increases, the circles expand outward from the origin. These concentric circles represent the level curves of the function 𝑓(𝑥,𝑦)=𝑥2+𝑦2.

Figure 31: Four of the level curves for 𝑓(𝑥,𝑦)=𝑥2+𝑦2.
Example: the level curves of 𝑓(𝑥,𝑦)=|𝑥|+|𝑦|

Let’s draw level curves of 𝑓(𝑥,𝑦)=|𝑥|+|𝑦|. To draw the level curve for 𝑐, we are looking at

|𝑥|+|𝑦|=𝑐.

Like before, if 𝑐<0 there are no pairs (𝑥,𝑦) at all and for 𝑐=0 there is only a single point.

This equation represents a family of polygons. Specifically, for a given value of 𝑐, the points that satisfy this equation form a diamond shape centered at the origin. Indeed, in the first quadrant (where the absolute values don’t do anything) it represents the line segment joining (0,𝑐) to (𝑐,0).

So for example,

  • When 𝑐<0, there are no points.
  • For 𝑐=0, the level curve is just the point (0,0).
  • For 𝑐=1, the level curve is a diamond with vertices at (1,0), (−1,0), (0,1), and (0,−1).
  • For 𝑐=2, the level curve is a larger diamond with vertices at (2,0), (−2,0), (0,2), and (0,−2).
  • For 𝑐=3, the diamond expands further, with vertices at (3,0), (−3,0), (0,3), and (0,−3).

As 𝑐 increases, the diamonds expand outward, maintaining their shape but increasing in size. Each level curve is a square rotated by 45 degrees.

Figure 32: Four of the level curves for 𝑓(𝑥,𝑦)=|𝑥|+|𝑦|.

§13.2 [RECIPE] Drawing level curves

Despite the fact this section is labeled “recipe”, there isn’t an easy method that works for every function. You have to do it in an ad-hoc way depending on the exact function you’re given. For many functions you’ll see on an exam, it’ll be pretty easy.

To summarize the procedure, given an explicit function like 𝑓(𝑥,𝑦) and the value of 𝑐, one tries to plot all the points (𝑥,𝑦) in space with 𝑓(𝑥,𝑦)=𝑐. We gave three examples right above, where:

So you can see it really depends on the exact 𝑓 you are given. If you wrote a really nasty function like 𝑓(𝑥,𝑦)=𝑒sin𝑥𝑦+cos(𝑥+𝑦), there’s probably no easy way to draw the level curve by hand.

§13.3 [TEXT] Level surfaces are exactly the same thing, with three variables instead of two

Nothing above really depends on having exactly two variables. If we had a three-variable function 𝑓(𝑥,𝑦,𝑧), we could draw level surfaces for a value of 𝑐 by plotting all the points in ℝ3 for which 𝑓(𝑥,𝑦,𝑧)=𝑐.

Example: Level surface of 𝑓(𝑥,𝑦,𝑧)=𝑥2+𝑦2+𝑧2
If 𝑓(𝑥,𝑦,𝑧)=𝑥2+𝑦2+𝑧2, then the level surface for the value 𝑐 will be a sphere with radius 𝑐 if 𝑐≥0. (When 𝑐<0, the level surface is empty.)
Example: Level surface of 𝑓(𝑥,𝑦,𝑧)=𝑥+2𝑦+3𝑧
If 𝑓(𝑥,𝑦,𝑧)=𝑥+2𝑦+3𝑧, all the level surfaces of 𝑓 are planes in ℝ3, which are parallel to each other with normal vector (123).

§13.4 [EXER] Exercises

Exercise 13.1. Draw 2D level curves for some values for the following functions:

Exercise 13.2 (*). Give an example of a polynomial function 𝑓(𝑥,𝑦) for which the level curve for the value 100 consists of exactly seven points.
  1. 14 This is a lot like how we drew planes in a symmetric form earlier. In high school algebra, you drew 2D graphs of one-variable functions like 𝑦=2𝑥+5 or 𝑦=𝑥2+7. So it might have seemed a bit weird to you that we wrote planes instead like 2𝑥+5𝑦+3𝑧=7 rather than, say, 𝑧=7−2𝑥−5𝑦3. But this form turned out to be better, because it let us easily access the normal vector (which here is ⟨2,5,3⟩). The analogy carries over here.