Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 39 · Getting Started

Functions of Several Variables

Learn domain, range and graphs of functions of two and three variables, with worked examples and Python code that plots surfaces.

A function of two variables assigns to each ordered pair (x, y) in its domain exactly one real number f(x, y). In this lesson you learn how to find the domain and range, how to read a formula, and how to draw the surface that is the graph. Domains matter more than they did in one variable, because the domain is now a region of the plane, and its shape can be interesting.

Domain and range

The domain is the set of input points where the formula makes sense. The range is the set of output values the function actually takes.

Worked example 1: f(x, y) = √(9 - x² - y²). The square root needs 9 - x² - y² ≥ 0, so x² + y² ≤ 9. The domain is the closed disk of radius 3 centered at the origin. The output is between 0 (on the circle) and 3 (at the center), so the range is [0, 3].

Worked example 2: g(x, y) = ln(x - y). We need x - y > 0, that is y < x. The domain is the open half-plane below the line y = x. The range is all real numbers.

Worked example 3: h(x, y) = 1 / (x y). We cannot divide by zero, so x ≠ 0 and y ≠ 0. The domain is the plane without the two coordinate axes.

Python Test whether a point is in the domain

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Graphs: surfaces

The graph of f is the set of points (x, y, z) with z = f(x, y). To sketch one, think of a landscape: the point (x, y) is where you stand on a map, and f(x, y) is the altitude. Some common surfaces:

Function Surface
z = x² + y² Paraboloid (a bowl)
z = √(x² + y²) Cone
z = x² - y² Hyperbolic paraboloid (a saddle)
z = 2x + 3y + 1 Plane
z = √(9 - x² - y²) Upper half of a sphere of radius 3
Python Plot three surfaces

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A computer draws a surface by evaluating f on a grid (numpy.meshgrid) and joining neighbouring points with small patches. A finer grid gives a smoother picture but takes more time.

Functions of three variables

For w = f(x, y, z) the domain is a region of space. For example, f(x, y, z) = 1 / (x² + y² + z² - 1) is defined everywhere except on the unit sphere x² + y² + z² = 1. The graph lives in four dimensions, so we cannot draw it, but we can study its level surfaces f(x, y, z) = c (next lessons).

Composite and combined functions

You can build new functions from old ones. If u(t) is a function of one variable and f(x, y) a function of two, then u(f(x, y)) is a function of two variables. For instance e^(-(x²+y²)) combines the exponential with the paraboloid and gives a bell-shaped hill centered at the origin.

Python A bell-shaped hill and its cross-sections

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Slicing a surface with a vertical plane (such as y = 1) gives an ordinary one-variable function. This is the idea behind partial derivatives, which you will meet soon.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What is the domain of f(x, y) = √(4 - x² - y²)?

    The radicand must be nonnegative, so x² + y² ≤ 4, a disk of radius 2.
  2. 2. What is the domain of g(x, y) = ln(x + y)?

    The logarithm needs a strictly positive argument, so x + y > 0, a half-plane.
  3. 3. The graph of z = x² - y² is called

    It curves up along the x axis and down along the y axis, so it is a hyperbolic paraboloid, or saddle.
  4. 4. What do you get when you slice the surface z = f(x, y) with the plane y = 1?

    Fixing y leaves a curve whose height depends only on x.

Summary

  • The domain of f(x, y) is a region of the plane; the range is the set of values it takes.
  • The graph z = f(x, y) is a surface; numpy.meshgrid and plot_surface draw it.
  • Vertical slices (fixing one variable) give one-variable functions.
  • Functions of three variables have domains in space and are studied through level surfaces.

Next: Level Curves and Level Surfaces