![]() | 1 | initial version |
Do you mean this :
sage: reset()
sage: Z=var("z",n=9)
sage: u=vector(Z[:3]) ; u
(z0, z1, z2)
sage: v=vector(Z[3:6]) ; v
(z3, z4, z5)
sage: w=vector(Z[6:]) ; w
(z6, z7, z8)
sage: (u.dot_product(w))*v - (u.dot_product(v))*w
((z0*z6 + z1*z7 + z2*z8)*z3 - (z0*z3 + z1*z4 + z2*z5)*z6, (z0*z6 + z1*z7 + z2*z8)*z4 - (z0*z3 + z1*z4 + z2*z5)*z7, (z0*z6 + z1*z7 + z2*z8)*z5 - (z0*z3 + z1*z4 + z2*z5)*z8)
$$\left({\left(z_{0} z_{6} + z_{1} z_{7} + z_{2} z_{8}\right)} z_{3} - {\left(z_{0} z_{3} + z_{1} z_{4} + z_{2} z_{5}\right)} z_{6},\,{\left(z_{0} z_{6} + z_{1} z_{7} + z_{2} z_{8}\right)} z_{4} - {\left(z_{0} z_{3} + z_{1} z_{4} + z_{2} z_{5}\right)} z_{7},\,{\left(z_{0} z_{6} + z_{1} z_{7} + z_{2} z_{8}\right)} z_{5} - {\left(z_{0} z_{3} + z_{1} z_{4} + z_{2} z_{5}\right)} z_{8}\right)$$
Note that you have to use the dot_product
method, the .
alone denoting the use of a method or component of its left "operand) ; similarly, Sage does not allow "implicit multiplication" and forces you to use *
. Lfe is hard...
@slelievre's suggestions for function implementation are good ; they might be refined (type checking, error reporting, etc...).
HTH,