next up previous
Next: About this document ... Up: lab_template1 Previous: lab_template1




The purpose of this lab is to acquaint you with some of the vector capabilities in Maple.


Many commands used in this lab come from the linalg package, which must be loaded before any of the commands can be used. The following is a list of the commands discussed in this lab. Note that these form only a small subset of the package which is designed primarily for linear algebra.
Used to define a vector.
Computes the dot product of two vectors.
Computes the cross product of two vectors.
Evaluates expressions involving vectors.
Computes the norm, or length of a vector. For reasons explained below, the use of this commmand is not recommended. A better alternative for our purposes is to use the square root of the dot product of a vector with itself.
The first set of examples below demonstrates how to compute linear combinations of vectors, dot products, lengths, and vector components for fixed vectors.
> with(linalg):
> a := [2, 13, -6];
> b := [5, -4, 17];
> a+b;
> 5*a-2*b;
> dotprod(a,b);
> crossprod(a,b);
> crossprod(b,a);
> dotprod(a,crossprod(a,b));
The next two commands show two different ways to compute the length of a vector. The first way uses the norm command. Note the $2$ as the second argument of the command. The $2$ has to be there, or else Maple uses a different norm than the one we want. The second way, using the fact that $\Vert u\Vert=\sqrt{u\cdot u}$, is prefered for the reasons given in the examples below dealing with arbitrary vectors.
> norm(a,2);
> sqrt(dotprod(a,a));
The final example for fixed vectors shows two methods for computing the vector projection or component of b in the direction a. Method one first computes the unit vector of a.
> a_unit := evalm(a/sqrt(dotprod(a,a)));
> comp_a1 := evalm(dotprod(b,a_unit)*a_unit);
The second method uses the formula for the component.
> comp_a2 := evalm(dotprod(b,a)/dotprod(a,a)*a);
In the next set of examples two arbitrary three-dimensional vectors, u and v, are defined and then these vectors are used to prove the vector identity

(u-v)\cdot (u-v) = u \cdot u + v \cdot v - 2u \cdot v

> u := [u1,u2,u3];
> v := [v1,v2,v3];
> norm(u,2);
> sqrt(dotprod(u,u));
The above two commands show the two ways of computing the length of an arbitrary vector. Note the absolute value signs appearing in the output of the norm command as well as the conjugate notation in the output of the sqrt command. These appear because Maple is allowing the components of u to be complex numbers. Therefore you need to tell the computer that you are dealing with real numbers. Absolute value signs cause problems in proving vector identities involving real vectors, so you probably are better off using the square root of the dot product of a vector with itself to compute the length.
> assume(u1,real,u2,real,u3,real,v1,real,v2,real,v3,real);
The next few commands show how to prove the identity given above. The strategy is to compute both sides of the equation and then compare them. If they are identical, then the equation holds. (Note: the tilda simply means that the computer refered to the assumption, so b1$\sim$=b1).
> eq1 := dotprod(evalm(u-v),evalm(u-v));
> expand(eq1);
> eq2 := dotprod(u,u)+dotprod(v,v)-2*dotprod(u,v);
> simplify(eq1-eq2);


  1. Given the vectors $a=[9,0,-2], b=[4,-4,4], and c=[\frac{-1}{2},3,0]$ compute the following:
    $7c-12(a\cdot c)b$
  2. Show that the following identity is true for any two vectors in three dimensions.

a \cdot (b \times c) = (a \times b) \cdot c

  3. Given the following triangle $\bigtriangleup ABC$ with the points $A = (3, 0, -1)$,$ B = (4, 2, 5)$, and $ C = (18, -2, 4)$
    Show that the triangle is a right triangle using the dot product.
    Find the area of the triangle using the cross product.

next up previous
Next: About this document ... Up: lab_template1 Previous: lab_template1
Jane E Bouchard