Dot and Cross product A fast Maple note Worksheet by Mike May, S.J.- maymk@slu.edu Edited by Russell Blyth - blythrd@slu.edu We have been studying dot products and cross products. It seems worthwhile to point out the syntax for computing them in Maple. (You can then use Maple as another way to check your work.) First we define some vectors: restart; a := <1, 2, 3>; b := <4, 5, 6>; v := <v1, v2, v3>; w := <w1, w2, w3>; LSZJJ1ZlY3Rvckc2JCUqcHJvdGVjdGVkR0koX3N5c2xpYkc2IjYjSSdjb2x1bW5HRig2Iy9JJCVpZEdGKCImJSk9Jw== LSZJJ1ZlY3Rvckc2JCUqcHJvdGVjdGVkR0koX3N5c2xpYkc2IjYjSSdjb2x1bW5HRig2Iy9JJCVpZEdGKCImLz8n LSZJJ1ZlY3Rvckc2JCUqcHJvdGVjdGVkR0koX3N5c2xpYkc2IjYjSSdjb2x1bW5HRig2Iy9JJCVpZEdGKCIoJUcjSCU= LSZJJ1ZlY3Rvckc2JCUqcHJvdGVjdGVkR0koX3N5c2xpYkc2IjYjSSdjb2x1bW5HRig2Iy9JJCVpZEdGKCIoP1RJJQ== You can also create vectors with the Vector command, giving the size and a list of components. c := Vector(3,[4,5,6]); LSZJJ1ZlY3Rvckc2JCUqcHJvdGVjdGVkR0koX3N5c2xpYkc2IjYjSSdjb2x1bW5HRig2Iy9JJCVpZEdGKCImJTNq Once the vectors have been created, we can use standard syntax for arithmetic operations. "a+b, the sum of vectors" = a+b; "2v, a scalar multiple" = 2*v; "a+2*b+3*v+4*w, a linear combination" = a+2*b+3*v+4*w; L1E4YStiLH50aGV+c3Vtfm9mfnZlY3RvcnM2Ii0mSSdWZWN0b3JHNiQlKnByb3RlY3RlZEdJKF9zeXNsaWJHRiQ2I0knY29sdW1uR0YkNiMvSSQlaWRHRiQiKHM2VSU= L1E2MnYsfmF+c2NhbGFyfm11bHRpcGxlNiItJkknVmVjdG9yRzYkJSpwcm90ZWN0ZWRHSShfc3lzbGliR0YkNiNJJ2NvbHVtbkdGJDYjL0kkJWlkR0YkIigjXEBX L1FEYSsyKmIrMyp2KzQqdyx+YX5saW5lYXJ+Y29tYmluYXRpb242Ii0mSSdWZWN0b3JHNiQlKnByb3RlY3RlZEdJKF9zeXNsaWJHRiQ2I0knY29sdW1uR0YkNiMvSSQlaWRHRiQiKClHclk= The commands for dot product and cross product are included in the LinearAlgebra package. The syntax is: LinearAlgebra[DotProduct](vector1, vector2); LinearAlgebra[CrossProduct](vector1, vector2); LinearAlgebra[DotProduct](a, b); LinearAlgebra[CrossProduct](a, b); LinearAlgebra[DotProduct](v, w); LinearAlgebra[CrossProduct](v,w); An alternative syntax for the dot product is to put a dot (or period) between the two vectors. a.b; v.w; Another way to use these commands is to use the "with(LinearAlgebra):" command to load the LinearAlgebra package and then use the short form of the command. This way the package only needs to be loaded once in a Maple session. with(LinearAlgebra): DotProduct(a, b); CrossProduct(a, b); DotProduct(v, w); CrossProduct(v, w); Once the LinearAlgebra package has been loaded the cross product can also be called for with the &x operator. a &x b; v &x w;