Mathematica has a built-in command to generate plots of the level curves of a function f of two variables. The basic form of the command is
ContourPlot[F[x, y], {x, xmin, xmax}, {y, ymin, ymax}]
where F[x, y] is an expression in the variables x and y, which range over the respective intervals [xmin, xmax] and [ymin, ymax]. For the function f with formula f(x, y) = + , with x and y each varying between --4 and 4, executing the following command produces curves corresponding to equally-spaced values of z = f(x, y). (Recall to execute a command, position the cursor after the command and hit Enter at the lower right corner of the keyboard, or press the Shift and Enter keys together.)
(* Command to plot level curves of f (x, y) = x^2 + y^2 *)
ContourPlot[x^2 + y^2, {x, -4, 4}, {y, -4, 4}]
The default output plots 10 level curves in shaded gray scale, with lighter shades corresponding to larger values of z. The following more detailed command plots five level curves without shading. Try it!
(* Mathematica Routine to plot level curves of f (x, y) =
x^2 + y^2 in color, with built-in smoothing *)
ContourPlot[x^2 + y^2, {x, -4, 4}, {y, -4, 4},
Contours -> 5, ContourShading -> False]