Re: sum with lists
- To: mathgroup at smc.vnet.net
- Subject: [mg40553] Re: sum with lists
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 10 Apr 2003 03:36:44 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <b70npo$9gd$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
d={{x0,y0,z0},{x1,y1,z1},{x2,y2,z1}, {xn,yn,zn}};
Plus @@ (#[[1]]*#[[3]] & /@ d)
for Sum[x[i]*z[i],{i,0,n}]
or
Plus @@ (#[[1]]*#[[3]] & /@ Take[d,n/2])
for Sum[x[i]*z[i],{i,0,n/2}]
Regards
Jens
Nathan Moore wrote:
>
> Another list question. Suppose that I have the list
> d={
> {x0,y0,z0},
> {x1,y1,z1},
> {x2,y2,z1},
> ...
> {xn,yn,zn}}
>
> and now I'd like to calculate the sum,
> Sum[x[i]*z[i],{i,0,n/2}]
>
> I tried
> Sum[d[[i, 1]]*d[[i, 3]], {i, 0, 10}]
> with little success
>
> thanks,
>
> Nathan Moore,
> University of Minnesota Physics