Graph and Contour Plots of Functions of Two Variables

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

Visualizing the graph of a function of two variables is a useful device to help understand how a function behaves. For a function of two variables , the graph is a surface in 3D space.


If is a smooth function, its graph will be a smooth surface, and so will be the contour plot, where lines of constant altitude of the graph are drawn. Moreover, the surface lives only over the domain of the corresponding function (e.g., for a logarithmic function). This Demonstration shows some of these features for typical functions of two variables: a polynomial, , a composition of a trigonometric and a logarithmic function with a polynomial, and , respectively, and a rational function, . Observe that the first three functions (but not the rational function) are continuous and smooth on their corresponding domains for all possible choices of the constants. The behavior of the rational function is highly dependent on the constants of the numerator, and so is the smoothness of the corresponding graph.


Contributed by: Ana Moura Santos and João Pedro Pargana (March 2011)
Open content licensed under CC BY-NC-SA



The graph of a function of two variables helps to understand the continuity of the function defined on a domain of . Polynomials of two variables are good examples of everywhere-continuous functions. Here we give an example of the polynomial defined on . In this case the graph consists of a nondegenerate or degenerate quadratic surface. For , , or it is a second-degree polynomial. For , , and it is a plane in 3D. Looking at the corresponding contour plots (a 2D projection of the 3D graphs), gives a better feeling of the behavior of the function.

We know that a composition of two continuous functions is itself a continuous function. Thus a composition of a trigonometric function with a polynomial, in our example , defined on the same domain , is continuous on . In general, the composition of a logarithmic function with a polynomial is not well defined when the argument of the logarithm is negative. Here, is not always well defined on ; try to find out for which values of the constants this happens! Once the function is restricted to a new domain, we have continuity.

In the case of a rational function like , the point is a critical one. One can include this point in the domain of the function and study the limit of the function at . Then, if the limit at this point exists, we have a removable discontinuity. If not, the discontinuity at is not removable. Experiment with different constants and observe that the graph near the point is highly dependent on the coefficients of the numerator. For some choice of the constants, for example and , we have a limit at the origin (but a small "peak" there); on the other hand, for , , and , the graph near the origin is not smooth at all and in the contour plot, different contour lines join together there.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.