MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: sum with lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40605] Re: [mg40591] Re: sum with lists
  • From: Dr Bob <majort at cox-internet.com>
  • Date: Fri, 11 Apr 2003 02:00:08 -0400 (EDT)
  • References: <200304100743.DAA24367@smc.vnet.net>
  • Reply-to: majort at cox-internet.com
  • Sender: owner-wri-mathgroup at wolfram.com

You have a missing bracket, and you didn't define n.  If I fix those 
problems, here's what happens:

d = {{x0, y0, z0}, {x1, y1, z1},
    {x2, y2, z1},  {xn, yn, zn}};
Tr[Take[d, Floor[Length@d/2]].{1, 0, 1}]

x0 + x1 + z0 + z1

and that's not what Nathan asked for.

This works, and it's sort of related to what you tried:

Tr[Times @@@ (Take[d, Floor[Length@d/2]].{1, 0, 1})]

or

Tr[Take[d, Floor[Length@d/2]].{1, 0, 1} /. Plus -> Times]

Bobby

On Thu, 10 Apr 2003 03:43:56 -0400 (EDT), Bill Rowe 
<listuser at earthlink.net> wrote:

> On 4/9/03 at 8:26 PM, nmoore at physics.umn.edu (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}]
>
> A simple way to do this would be
>
> Tr[Take[d, Floor[n/2].{1,0,1}]
>
>



-- 
majort at cox-internet.com
Bobby R. Treat



  • Prev by Date: Re: Integration problem
  • Next by Date: Re: sum with lists
  • Previous by thread: Re: sum with lists
  • Next by thread: Re: sum with lists