Maple Lab 0 (Spring 2007 Math 251 Sections 05-07) 

Background Worksheet. 

 

Remember that even though this lab will not count towards your final grade, you must turn it in! 

 

It's a good idea to start every sheet with the restart command. Maple remembers everything that 

you do, so the restart command gives you a fresh start without having to shutdown and restart  

the program itself! 

> restart; 1
 

 

A Quick Note for Typing in Maple: 

To create new text groups such as this use the button labeled "T" above. To create a new execution group  

(the lines with maple commands which start with ">") you can use the button labeled "[>" or the keyboard  

shortcut "Ctrl+J". To insert a group before the cursor use "Ctrl+K".  

 

To delete a line of input or Maple output you can use the keyboard shortcut "Ctrl+Delete". To begin 

another line in an execution group use "Shift+Enter". Remember that "Enter" alone will just execute 

the command you've typed. 

 

 

Sometimes the commands we want to use are built into Maple. Other times we must load up a  

special package of commands to get the job done. To add commands we use the command  

"with(...);" 

> with(plots); 1
 

Warning, the name changecoords has been redefined 

[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
 

To find out what all of these commands do we can ask Maple using "?". 

> help(
 

> implicitplot3d(x^2+y^2+z^2 = 9, x = -4 .. 4, y = -4 .. 4, z = -4 .. 4); 1
 

Plot 

This sphere is kind of rough. We can use the help to find a plot option to smooth it out.  

 

It looks like numpoints is a good way to go. 

> implicitplot3d(x^2+y^2+z^2 = 9, x = -4 .. 4, y = -4 .. 4, z = -4 .. 4, numpoints = 5000); 1
implicitplot3d(x^2+y^2+z^2 = 9, x = -4 .. 4, y = -4 .. 4, z = -4 .. 4, numpoints = 5000); 1
 

Plot 

Let's play with vectors. We will include the vector calculus package and use rectangular (cartesian) coordinates. 

> with(VectorCalculus); 1; SetCoordinates('cartesian'[x, y, z]); 1
 

Warning, the assigned names `<,>` and `<|>` now have a global binding 

Warning, these protected names have been redefined and unprotected: `*`, `+`, `-`, `.`, D, Vector, diff, int, limit, series 

[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
 

cartesian[x, y, z] 

Let's define two vectors. Call them "a" and "b". 

> a := `<,>`(1, 2, 3); 1; b := `<,>`(4, 5, 6); 1
 

(Typesetting:-mprintslash)([a := Vector[column]([[1], [2], [3]], [ 

(Typesetting:-mprintslash)([b := Vector[column]([[4], [5], [6]], [ 

We compute the "dot product" using a period between these two vectors. 

> Typesetting:-delayDotProduct(a, b); 1
 

32 

You can compute the "cross product" of these two vectors using "&x". Let's call this cross product "c". 

> c := `&x`(a, b); 1
 

(Typesetting:-mprintslash)([c := Vector[column]([[-3], [6], [-3]], [ 

Now let's plot the vectors a and b and their cross product c along with the parallelogram spanned by the vectors a and b. 

Recall that the area of this parallelogram is equal to the length of cross product vector. 

> A := arrow(a, shape = arrow, color = blue); 1; B := arrow(b, shape = arrow, color = green); 1; C := arrow(c, shape = arrow, color = red); 1; parallelogramAB := polygonplot3d([`<,>`(0, 0, 0), a, a+b, b...
A := arrow(a, shape = arrow, color = blue); 1; B := arrow(b, shape = arrow, color = green); 1; C := arrow(c, shape = arrow, color = red); 1; parallelogramAB := polygonplot3d([`<,>`(0, 0, 0), a, a+b, b...
A := arrow(a, shape = arrow, color = blue); 1; B := arrow(b, shape = arrow, color = green); 1; C := arrow(c, shape = arrow, color = red); 1; parallelogramAB := polygonplot3d([`<,>`(0, 0, 0), a, a+b, b...
A := arrow(a, shape = arrow, color = blue); 1; B := arrow(b, shape = arrow, color = green); 1; C := arrow(c, shape = arrow, color = red); 1; parallelogramAB := polygonplot3d([`<,>`(0, 0, 0), a, a+b, b...
A := arrow(a, shape = arrow, color = blue); 1; B := arrow(b, shape = arrow, color = green); 1; C := arrow(c, shape = arrow, color = red); 1; parallelogramAB := polygonplot3d([`<,>`(0, 0, 0), a, a+b, b...
 

A := INTERFACE_PLOT3D(CURVES([[0., 0., 0.], [1.000000000, 2.000000000, 3.000000000]], [[.7329179608, 1.465835921, 2.511803399], [1.000000000, 2.000000000, 3.000000000], [.8670820394, 1.734164079, 2.28... 

B := INTERFACE_PLOT3D(CURVES([[0., 0., 0.], [4.000000000, 5.000000000, 6.000000000]], [[3.012591486, 3.765739357, 5.120156212], [4.000000000, 5.000000000, 6.000000000], [3.387408514, 4.234260643, 4.47... 

C := INTERFACE_PLOT3D(CURVES([[0., 0., -0.], [-3.000000000, 6.000000000, -3.000000000]], [[-2.332917961, 4.665835921, -2.735410197], [-3.000000000, 6.000000000, -3.000000000], [-2.467082039, 4.9341640... 

parallelogramAB := INTERFACE_PLOT3D(POLYGONS([[0., 0., 0.], [1., 2., 3.], [5., 7., 9.], [4., 5., 6.]]), COLOUR(RGB, .75294118, .75294118, .75294118)) 

Plot 

Let's create a vector length function. Recall that ":=" assigns the expression to the right to the name on the left. 

Also, "x -> y" means that "x" maps to "y". 

> myLength := proc (v) options operator, arrow; sqrt(Typesetting:-delayDotProduct(v, v)) end proc; 1
 

(Typesetting:-mprintslash)([myLength := proc (v) options operator, arrow; sqrt((Typesetting:-delayDotProduct)(v, v)) end proc], [proc (v) options operator, arrow; sqrt((Typesetting:-delayDotProduct)(v... 

> myLength(`<,>`(1, 2, 3)); 1
 

14^(1/2) 

You can see it is not hard to create your own functions.  

 

Actually in this case it is unnecessary. We can just use the "Norm" function to compute lengths. 

> Norm(`<,>`(1, 2, 3)); 1
 

14^(1/2) 

Let's plot part of a line. First, let's define a vector function which describes our line and then use the plot command. 

Our line will pass through the point (1,2,3) and be parallel to the vector <4,5,6>. 

 

Notice that last time we defined a function it spit out a bunch of junk we really didn't want to see. So this time 

we'll end our function definition with a colon ":" instead of a semi-colon ";". This will suppress the output. 

> r := proc (t) options operator, arrow; `<,>`(1, 2, 3)+`<,>`(4, 5, 6)*t end proc; -1
 

> spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); 1
spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); 1
 

Plot 

Notice all of the options I've added to the "spacecurve" command. What do they do? 

 

Now let plot the plane whose normal vector is <4,5,6> and which passes through the point (1,2,3). 

This plane's equation is "4(x-1)+5(y-2)+6(z-3)=0" 

> eqn := `+`(4*x-4, 5*y-10, 6*z-18) = 0; 1
 

(Typesetting:-mprintslash)([eqn := 4*x-32+5*y+6*z = 0], [4*x-32+5*y+6*z = 0]) 

There are a number of different ways to do this. Let's check out a few. 

 

First, solve for z and use plot3d. The "solve" command will help us out. 

> zequals := solve(eqn, z); 1
 

(Typesetting:-mprintslash)([zequals := -2/3*x+16/3-5/6*y], [-2/3*x+16/3-5/6*y]) 

> plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = normal, labels = [x, y, z], scaling = constrained); 1
plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = normal, labels = [x, y, z], scaling = constrained); 1
 

Plot 

Or we could use implicit plot and leave the equation in its original form. 

> implicitplot3d(eqn, x = -4 .. 4, y = -4 .. 4, z = 0 .. 12, axes = normal, labels = [x, y, z], scaling = constrained); 1
implicitplot3d(eqn, x = -4 .. 4, y = -4 .. 4, z = 0 .. 12, axes = normal, labels = [x, y, z], scaling = constrained); 1
 

Plot 

Or we can "parametrize" the plane by letting x = s, y = t, and z = -4/6(s-1)-5/6(t-2)+3. 

 

> zOFst := subs({x = s, y = t}, zequals); 1
 

(Typesetting:-mprintslash)([zOFst := -2/3*s+16/3-5/6*t], [-2/3*s+16/3-5/6*t]) 

> plot3d([s, t, zOFst], s = -4 .. 4, t = -4 .. 4, axes = normal, labels = [x, y, z], scaling = constrained); 1
plot3d([s, t, zOFst], s = -4 .. 4, t = -4 .. 4, axes = normal, labels = [x, y, z], scaling = constrained); 1
 

Plot 

Let's say we want to plot several things together. For this, we use the "display3d" command. 

> lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
lineplot := spacecurve(r(t), t = -1 .. 1, axes = normal, color = black, thickness = 2, labels = [x, y, z], scaling = constrained); -1; planeplot := plot3d(zequals, x = -4 .. 4, y = -4 .. 4, axes = nor...
 

Plot