Application Center - Maplesoft

App Preview:

Dot and Cross Product

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Sec12.1CrossDotProd.mws

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];

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

32

vector([-3, 6, -3])

v1*conjugate(w1)+v2*conjugate(w2)+v3*conjugate(w3)

vector([v2*w3-v3*w2, v3*w1-v1*w3, v1*w2-v2*w1])

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

32

vector([-3, 6, -3])

v1*conjugate(w1)+v2*conjugate(w2)+v3*conjugate(w3)

vector([v2*w3-v3*w2, v3*w1-v1*w3, v1*w2-v2*w1])

>