Project 11: Vectors


Use available technologies to answer the questions. Compile the answer into a Google Document and then share it with the instructor. I've included an example problem for you to see what I'm looking for.

Analyze the Surface

Consider the function \( z = f(x,y) = (y+2)(y^2 - 1) - 2x(x+1)(x^2-4)-xy \)

  1. Graph the function and contour plot to get a sense of what's going on. This will be refined later in the process.
  2. Use the techniques from section 11.7 to find and analyze the critical points.
  3. Create a magnificent contour plot. Show enough contours to illustrate what is going on in the graph. Place a point and label the relative maximums, relative minimums, and saddle values.

To submit the assignment, click the Share button in Google Docs and change it so that anyone with the link can view the results. Then copy the share link and email it to the instructor at with an appropriate subject and the names of the people in the group. Only one person per group needs to submit the project.


Maxima Hints

Partial Derivatives

Label your original function and the partial derivatives so they are easier to use. For example, here is the basic setup of any problem (just the definition of Z changes).



You can iterate through a list and execute commands to each item in the list.

For example, to find the value of Z at the first critical point, you would need: subst(CP[1],Z);

To do that for the second critical point, you would need: subst(CP[2],Z);

You would repeat that for each critical point.

With iteration, you could do this:

for cp in CP do subst(cp,Z);

Unfortunately, that just says "done". You could modify it to use the print() command. Notice the $ at the end rather than the ;. That avoids it adding the "done" statement.

for cp in CP do print(subst(cp,Z))$

You could do the same thing with the substitutions into D to determine what type of feature you have at the critical point. In fact, print() will take more than one argument, so you could print the values of both Z, D, and Fxx at the same time if you wanted.

Contour Plots

You can make contour plots several ways in Maxima. Each of the following assume that you have labeled an expression Z, as in


Note that is a capital Z, not a lowercase z. You could have also used F.

Implicit Plots on a 2D Graph

Contour plots are 2d graphs, so this is probably the best method for understanding what's going on. It also gives you the most control over the graphs. It's not the easiest method, though.

An implicit plot is determined by creating a mesh or grid out of the domain. The ip_grid command will determine how many subintervals to use in the x and y direction. Larger numbers result in smoother curves, but take longer to generate. Smaller numbers result in choppier curves, but are quicker.

We use the makelist() command to generate a series of implicit plots. This way, we don't have to manually type in each level curve.

In this example, we will have blue level curves at z={-6, -4, -2, 0, 2, 4, 6, 8, 10} over the interval [-3,5]×[-2,6]. Then, because something interesting was going on, we added red level curves at z={1.2, 1.25, 1.32, 1.4} over the interval [-2,2]×[3,5]

     ip_grid = [100,100],
     color = blue,
     color = red,

Note, we didn't have to change the colors and we could have used the same domain for both parts. This was designed to illustrate how you could add extra detail to one section of the graph.

draw3d Command

You can use the draw3d() method and set "contour=map". Unfortunately, this adds a key for each line and you have to unset the GNUplot key to get rid of it.

This plot would generate a contour plot for Z=f(x,y) with contours starting at -6 and going to 8 with an increment of 0.5.

     user_preamble = "unset key;",
     xu_grid = 100, yv_grid = 100,
     xaxis = true, xaxis_type = solid, xaxis_width = 2, xtics = 0.5,
     yaxis = true, yaxis_type = solid, yaxis_width = 2, ytics = 0.5,
     zaxis = true, zaxis_type = solid, zaxis_width = 2,
     contour = map,
     contour_levels = [-6,0.5,8],

contour_plot Command

This command is built into Maxima and doesn't need the draw package loaded. That said, it is the least useful of the three methods.


The problem is that it only generates 3 contour levels and they are evenly spaced. In addition, it includes a legend off to the side of what the colors represent.

You can remove the legend and specify the number of contours using additional parameters. Unfortunately, you can't list specific contour levels, they're still evenly spaced.

     [legend, false],
     [gnuplot_preamble, "set cntrparam levels 12"]

Example Solution

Consider the function \( z = f(x,y) = y^3 ( y - 2 ) ( y + 2 ) - x ( x + 1 ) ( x + 3 ) + x^2 y \)

Initial Graphs

Surface Plot

Created using Microsoft Mathematics. Viewing window [-2,2]×[-2,2]×[-9,14]

Contour Plot

Created using Winplot. Viewing window [-2.5,4.5]×[-3.5,3.5].

Level curves generated for integer values of z between -10 and 10.


The first partials are \( f_x = 2xy - 3x^2 + 4x + 3 \) and \( f_y = 5y^4 - 12y^2 + x^2 \).

Simultaneously setting them equal to 0 and solving gives eight critical points.












Saddle Point






Relative Minimum







Saddle Point






Relative Maximum







Saddle Point






Relative Maximum







Saddle Point






Relative Minimum



Analysis conducted with Maxima with fpprintprec:8$ but it could probably be smaller.

\( D = f_{xx} f_{yy} - f_{xy} f_{yx} = f_{xx} f{yy} - (f_{xy})^2 \)

After looking at the critical points, it appears they can be contained in a viewing window of [-0.9,2.6]×[-1.6,1.6]×[-7,9].

Improving the Graph

This section is mostly explanatory, it does not have to be include in the analysis, but it should be performed to improve the surface plot and contour plot.

Looking at the domain needed to cover the critical points and comparing it with the initial draft of the contour plot, it seems that a good window might be [-2,3]×[-2.5,2.5]. ¬†After playing with it, I tweaked it a little to get [-1.8,3.2],[-2.2,2.2].

Contour plot created using Winplot. Viewing window [-1.8,3.2],[-2.2,2.2]. Level curves generated for integer values of z between -7 and 9.4

Looking at the graph, we see that there are voids around (-0.5, 0) and (2.2,1).

When we look at the critical points, we realize there are unusual things going on in those regions.

There is a saddle point at (-0.514, 0.149, -0.852) and a relative minimum at (-0.560, -0.163, -0.911). Those z values are close to each other and both between the contour levels at z=-1 and z=0. Adding some additional level curves in the region may help identify what's going on. In particular, adding some level curves near a saddle value may really help out.

In the above graph, blue level curves have been added at z= {-0.91109, -0.899072, -0.887054, -0.875036, -0.863018, -0.851} and green level curves at z = {7.44, 7.56, 7.68, 7.8}.

You'll notice, however, that this adds level curves in places where we didn't need them. That is a limitation of using Winplot. It graphs whatever is in the visible window and you can't specify an implicit plot only be graphed in a certain portion of the window. You can use Maxima to get around this, but the curves may seem disconnected where your window ends.

Generated using Maxima's draw package. The added contour levels are in green, but in the final version, they will all be the same color.

Maxima Code for Contour Plot

The set_draw_defaults() isn't necessary, it could be placed into the draw2d() command. The information placed into the defaults applies to all graphs, so if you generate some 3d graphs as well, you can avoid having to retype (or copy/paste) that information.

     dimensions = [800,704],
     xrange = [-1.8,3.2],
     yrange = [-2.2,2.2],
     zrange = [-7,9],
     grid = true
     xtics = 0.5, ytics = 0.5,
     ip_grid = [100,100],
     color = blue,
     makelist(implicit(Z=k,x,-1.8,3.2,y,-2.2,2.2), k,-6,8,1),
     ip_grid = [50,50],
     color = dark_green,
          k,[-0.25,-0.5, -0.75, -0.85,-0.88,-0.91])

Final Graphs

Surface Plot

Created using Microsoft Mathematics. Viewing window [-1.8,3.2]×[-2.2,2.2]×[-7,9]

Maxima can also be used to generate the graph. You don't really need both, though.

    colorbox = false,
    xu_grid = 40,
     yv_grid = 40,
     xyplane = 0,
     xaxis = true, xaxis_type = solid, xaxis_width = 2,
     yaxis = true, yaxis_type = solid, yaxis_width = 2,
     zaxis = true, zaxis_type = solid, zaxis_width = 2,
     enhanced3d = true,
     view = [60, 106],

Contour Plot

Generated using Maxima. Domain [-1.8,3.2]×[-2.2,2.2].

Critical points correspond to table of values in Analysis section.

Here is the Maxima code used to generate this graph (along with the defaults listed previously). This assumes that the solution to the solve() command to find the critical points has been labeled CP. Since those values are of the form [x=123, y=456], we need to take the right hand side of the expression to get just the number.

     /* Copy previous work */
     color = red,
     point_type = filled_circle,
     point_size = 1,

The ASCII code for the letter "A" is 65, so we add the position of the item in the list, which starts with 1, to 64 to convert them into letters. Then we offset it 0.1 to the right of the dot so it doesn't overwrite the dot.