Project 11: Vectors

Instructions

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 james@richland.edu with an appropriate subject and the names of the people in the group. Only one person per group needs to submit the project.

Notes

• If you use Winplot, choose File / Bitmap to Clipboard to copy a graph into the Google Doc. If you choose Btn, you can tell it that the right button should add text and then you can add labels.
• If you use Maxima, you can click on the copy icon in the top left corner of the window and then paste it into Google Docs. You can also programmatically add features to graphs, which is nice if you hate retyping things or using a mouse.
• If you use Microsoft Mathematics, there is an option to Save Graph as Picture. You can then upload (or drag and drop) that picture into Google Docs. There isn't an option to crop the graph, so you may get a lot of whitespace unless you pull the graph into a graphic editor crop it first. You can't add labels. For a 2D graph, you can do a slider, but not a family of curves, and the slider method doesn't accurately graph the level curve anyway.
• If you use CalcPlot3D, then you can use Ctrl-C to copy the graph and paste it into the Google Docs. You may wish to change the background color and zoom-in first. This program is probably the easiest to create contour plots and add levels as needed. It even adds labels on the contours. However, adding points and labels is not easy and possibly even buggy.

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).

Z:x^3+y^2+3*x*y$Fx:diff(Z,x)$
Fy:diff(Z,y)$Fxx:diff(Fx,x)$
Fxy:diff(Fx,y)$Fyy:diff(Fy,y)$
Fyx:diff(Fy,x)$D:Fxx*Fyy-Fxy*Fyx$

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 Z:x^3+y^2+3*x*y$

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]

draw2d(
ip_grid = [100,100],
color = blue,
makelist(implicit(Z=k,x,-3,5,y,-2,6),k,-6,10,2),
color = red,
makelist(implicit(Z=k,x,-2,2,y,3,5),k,[1.2,1.25,1.32,1.4])

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.

contour_plot(Z,[x,-3,5],[y,-2,6]);

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.

contour_plot(
Z,[x,-3,5],[y,-2,6]
[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.

Analysis

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.

Pt

x

y

z

Feature

D

fxx

A

-0.513761

0.149001

-0.851605

-26.960588

B

-0.560188

-0.162611

-0.911093

Relative Minimum

25.598426

7.0359076

C

1.6210724

-0.493705

5.0136165

-73.904681

D

2.2732056

0.749947

7.8332393

Relative Maximum

57.166773

-8.1393391

E

2.5577173

1.2501158

7.4412662

-106.40665

F

1.1767975

-1.5094498

8.5008157

Relative Maximum

192.39678

-6.0796846

G

-0.855211

-1.528862

4.3458245

-214.15801

H

-0.366299

1.5455634

-6.5226814

Relative Minimum

340.79653

9.2889226

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. load("draw")$
Z:y^3*(y-2)*(y+2)-x*(x+1)*(x-3)+x^2*y$set_draw_defaults( dimensions = [800,704], xrange = [-1.8,3.2], yrange = [-2.2,2.2], zrange = [-7,9], grid = true )$

draw2d(
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,
makelist(implicit(Z=k,x,1.5,3.2,y,0.3,2.0),
k,[7.44,7.6,7.8,7.83]),
makelist(implicit(Z=k,x,-1.5,1.25,y,-0.75,2),
k,[-0.25,-0.5, -0.75, -0.85,-0.88,-0.91])

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.

CP:solve([Fx,Fy],[x,y]);
draw2d(
/* Copy previous work */
color = red,
point_type = filled_circle,
point_size = 1,
points(makelist([rhs(cp[1]),rhs(cp[2])],cp,CP)),
makelist(
label([ascii(64+k),rhs(CP[k][1])+0.1,rhs(CP[k][2])]),
k,1,length(CP)
)
)\$ 

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.