Simple vectorial sum not evaluating in Maple?

263 Views Asked by At

I'm having a stupid trouble with this trivial code in Maple. The output is, well, ... stupid ! I'm asking Maple to do a vectorial sum and substraction of 5 cross products, and what I get is silly : a sum of vectors, but it doesn't give the total vector ! What the hell !?

with(linalg):
with(DEtools):

ly := 9.4607*10^15:
M0 := 1.99*10^30:

M1 := 2.20*M0:
M2 := 2.00*M0:
M3 := 1.50*M0:
M4 := 3.00*M0:

r1 := [-3, 3, 0]*ly:
r2 := [0, -2, 0]*ly:
r3 := [1, 2, 0]*ly:
r4 := [6, 4, 0]*ly:

v1 := [25, 15, 0]*10^3:
v2 := [20, -20, 0]*10^3:
v3 := [-5, -25, 0]*10^3:
v4 := [15, 0, 0]*10^3:

Mtot := M1 + M2 + M3 + M4:

rcm := (M1*r1 + M2*r2 + M3*r3 + M4*r4)/Mtot:
vcm := (M1*v1 + M2*v2 + M3*v3 + M4*v4)/Mtot:

Ltot := crossprod(r1, M1*v1) + crossprod(r2, M2*v2) + crossprod(r3, M3*v3) + crossprod(r4, M4*v4) - crossprod(rcm, Mtot*vcm);

I'm not a strong user of Maple, so I may have done a simple mistake somewhere, but I really don't see what and where. So what is wrong with this Maple code ?

2

There are 2 best solutions below

1
On

Unless you are using a very old version of Maple, you should load the LinearAlgebra package instead of linalg. Then, you need to form Vectors using angle <> brackets instead of square [] brackets which give you a Lists.

Once you have Vectors, you can form cross products with the &x operator. e.g.

with(LinearAlgebra):
r1 := <-3, 3, 0>*ly;
v1 := <25, 15, 0>*10^3;
r1 &x (M1*v1);

(note that you do need parenthesis around the second operand of the cross product - due to its precedence relative to *)

8
On

I finally found that adding a simple command does the trick :

evalm(Ltot);

Simple and neat !