MathGroup Archive 2003

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

Search the Archive

Re: simple vactor magitude question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43802] Re: simple vactor magitude question
  • From: Bill Rowe <readnewscix at mail.earthlink.net>
  • Date: Mon, 6 Oct 2003 02:07:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 10/4/03 at 2:05 AM, ZZNHTFKGIAIT at spammotel.com (Tom R.) wrote:

> This should do it: Apply[Plus, Table[p[[i]] i, {i, 0, Length[p] - 1}]]

This works after a fashion, but isn't a good idea. Array indices in Mathematica start with 1 not 0. So, p[[0]] doesn't exist. No error is generated in this case since 0 times any thing is 0. A method that would sum *all* of the elements of p would be

Sum[p[[n]]*n, {n,  Length@p}]

If I were to make a new list g = Most@Rest@p, i.e., discarding the first and last elements of p then

Sum[g[[n]], {n Length@g}]

will give the same result as your code above

To reply via email subtract one hundred and nine


  • Prev by Date: Re: Summation Problem w/ 5.0
  • Next by Date: Re: How can I submit the reference to a publication that used Mathematica?
  • Previous by thread: RE: simple vactor magitude question
  • Next by thread: Re: simple vactor magitude question