Martin Rubey
2007-05-23 13:50:39 UTC
Dear Alasdair,
(redirecting to axiom-math, where usage questions belong)
reduce(+, [ez*ew for ez in z for ew in w])
or, if you are really thinking of the standard inner product
dot(z, w)
http://wiki.axiom-developer.org/IndexedVariables
Short explanation: unlike Mma or Maple, in axiom evaluation is extremely
simple: first the arguments are evaluated, then the function. So, in your
case, first axiom tries to evaluate
z.i*w.i
and
i=1..6
but there is no operation elt (which the dot is syntactig sugar for) that takes
a list and a symbol -- try to type z.i into the interpreter! To make things
clearer, note that there *is* an operation "=" that takes a symbol and a
segment.
Hope that helps,
Martin
(redirecting to axiom-math, where usage questions belong)
z:=[1,2,3,4,5,6]
w:=[1,0,0,1,1,1]
it seems that the sum of the pairwise product is obtained by
reduce(+,[z.i*w.i for i in 1..6])3B
yes. Or, if you preferw:=[1,0,0,1,1,1]
it seems that the sum of the pairwise product is obtained by
reduce(+,[z.i*w.i for i in 1..6])3B
reduce(+, [ez*ew for ez in z for ew in w])
or, if you are really thinking of the standard inner product
dot(z, w)
which is all very well. But why doesn't
sum(z.i*w.i,i=1..6)
work? I mean, sum(i^2,i=1..6) is fine.
For a (very long) explanation seesum(z.i*w.i,i=1..6)
work? I mean, sum(i^2,i=1..6) is fine.
http://wiki.axiom-developer.org/IndexedVariables
Short explanation: unlike Mma or Maple, in axiom evaluation is extremely
simple: first the arguments are evaluated, then the function. So, in your
case, first axiom tries to evaluate
z.i*w.i
and
i=1..6
but there is no operation elt (which the dot is syntactig sugar for) that takes
a list and a symbol -- try to type z.i into the interpreter! To make things
clearer, note that there *is* an operation "=" that takes a symbol and a
segment.
Hope that helps,
Martin