# Second Maple lab for Holmes Math 275 # # Our first example is to graph an ellipsoid > equ := x^2+2*y^2+3*z^2 = 10; 2 2 2 equ := x + 2 y + 3 z = 10 > A:=solve(equ,z); #this solution is a list 2 2 1/2 2 2 1/2 (-3 x - 6 y + 30) (-3 x - 6 y + 30) A := ----------------------, - ---------------------- 3 3 > B:=A[1]; C:= A[2]; 2 2 1/2 (-3 x - 6 y + 30) B := ---------------------- 3 2 2 1/2 (-3 x - 6 y + 30) C := - ---------------------- 3 > plot3d(B,x=-5..5,y=-5..5,axes=box,scaling=constrained); > plot3d(C,x=-5..5,y=-5..5,axes=box,scaling=constrained); > plot3d({B,C},x=-5..5,y=-5..5,axes=box,scaling=constrained); # I define a function which does this without all the typing > equationplot:=(equ,a,b,c,d)->plot3d({solve(equ,z)},x=a..b,y=c..d,axes= > box,scaling=constrained); equationplot := (equ, a, b, c, d) -> plot3d({solve(equ, z)}, x = a .. b, y = c .. d, axes = box, scaling = constrained) > equationplot(equ,-5,5,-5,5); # Unfortunately, this doesn't work well here because the part of the # surface between the two "branches" is too steep, # and not enough points get plotted. You can use the "numpoints" # parameter in the plot3d command to improve this somewhat: > plot3d({B,C},x=-5..5,y=-5..5,axes=box,scaling=constrained,numpoints=50 > 00); # There are some other approaches. > with(plots); Warning, the name changecoords has been redefined [animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, display, display3d, fieldplot, fieldplot3d, gradplot, gradplot3d, graphplot3d, implicitplot, implicitplot3d, inequal, interactive, listcontplot, listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d, polyhedra_supported, polyhedraplot, replot, rootlocus, semilogplot, setoptions, setoptions3d, spacecurve, sparsematrixplot, sphereplot, surfdata, textplot, textplot3d, tubeplot] > implicitplot3d(equ,x=-5..5,y=-5..5,z=-5..5,axes=box,scaling=constraine > d); # As you can see, the implicitplot command doesn't give very many points # on the graph. > implicitplot3d(equ,x=-5..5,y=-5..5,z=-5..5,axes=box,scaling=constraine > d,numpoints=10000); # This is better! Another elegant solution is to use spherical or # cylindrical coordinates. Spherical is best for this example. > equ; 2 2 2 x + 2 y + 3 z = 10 > x:=r*cos(theta)*sin(phi); y:=r*sin(theta)*sin(phi); z:=r*cos(phi); x := r cos(theta) sin(phi) y := r sin(theta) sin(phi) z := r cos(phi) > equ; 2 2 2 2 2 2 r cos(theta) sin(phi) + 2 r sin(theta) sin(phi) 2 2 + 3 r cos(phi) = 10 > F:=solve(equ,r); 10 F := -------------------------------------------------, 2 2 2 1/2 (30 + 10 sin(theta) sin(phi) - 20 sin(phi) ) 10 - ------------------------------------------------- 2 2 2 1/2 (30 + 10 sin(theta) sin(phi) - 20 sin(phi) ) > G:=F[1]; 10 G := ------------------------------------------------- 2 2 2 1/2 (30 + 10 sin(theta) sin(phi) - 20 sin(phi) ) > sphereplot(G,theta=0..2*Pi,phi=0..Pi,axes=box,scaling=constrained); # To me, this seems by far the best picture, and it is much less # computationally expensive than the implicit plot with 10000 points. > x:=evaln(x); y:=evaln(y); z:=evaln(z); equ; #this shows how to get > rid of the dependence of x,y,z on r,theta,phi. x := x y := y z := z 2 2 2 x + 2 y + 3 z = 10 # Your lab assignment: # # Exercise 1: plot one figure of each of the kinds described in section # 12.6. For each figure, try plotting it with my equationplot # command and with either cylindrical or spherical coordinates # (cylindrical coordinates are appropriate for many of the figures, # and there is a "cylinderplot" command which works just like # sphereplot, except that it uses cylindrical coordinates (which can # be set up and removed in the same way that I set up and removed # spherical coordinates above. # # To help visualize things in section 13.1, read the brief introduction # to parametric plotting below. There is a second exercise at the end. > plot3d([t,t^2,t^3],s=-2..2,t=-2..2,axes=box,scaling=constrained); > #Here is the twisted cubic in all its glory: try moving it around. > plot3d([cos(t),2*sin(t),t],s=-2..2,t=-10..10,axes=box,scaling=constrai > ned); #Here's an elliptical helix > # The command above has two parameters because it is actually for # plotting parametric _surfaces_: > plot3d([2*s-3*t,t-s,5*s+7*t],s=-2..2,t=-2..2,axes=box,scaling=constrai > ned); #notice that this gives a plane. # Exercise 2: Try to write down a parametric plot which will give the # same plane as the equation x+2y-2z=4. Hint: find # two vectors that lie in the plane and a point in the plane. > equationplot(x+2*y-2*z=4,-5,5,-5,5); >