Dot and Cross Product
A fast Maple note
Worksheet by Mike May, S.J.- maymk@slu.edu
We have been looking at dot products and cross products in class. It seems worthwhile to point out the syntax for doing them with Maple.
(You can then use Maple as another way to check your work.)
First we define a bunch of vectors:
> restart;
> a := [1, 2, 3]; b := [4, 5, 6]; v := [v1, v2, v3]; w := [w1, w2, w3];
The commands for dot product and cross product are part of the linear algebra package. The syntax is:
linalg[dotprod](vector1, vector2);
linalg[crossprod](vector1, vector2);
> linalg[dotprod](a, b); linalg[crossprod](a, b); linalg[dotprod](v, w); linalg[crossprod](v, w);
An alternative syntax is to use the "with(linalg):" command to load the linear algebra package, then use the short form of the command. This way the package only needs to be loaded once in a Maple session.
> with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
> dotprod(a, b); crossprod(a, b); dotprod(v, w); crossprod(v, w);;
>