Dear Alasdair,

(redirecting to axiom-math, where usage questions belong)

"Alasdair McAndrew" <[EMAIL PROTECTED]> writes:

> Given two lists,for example:
> 
> 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 prefer

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 see

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



_______________________________________________
Axiom-math mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-math

Reply via email to