MathGroup Archive 2003

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

Search the Archive

Re: simple vactor magitude question


n = 5;

p = Table[Random[], {n+1}];

Sum[p[[i+1]]*i, {i,0,n}]

6.32604

p.Range[0,Length[p]-1]

6.32604

i=0; Fold[(#1+#2*i++)&, 0, p]

6.32604


Bob Hanlon

In article <blj5e0$1dv$1 at smc.vnet.net>, Nathan Moore <nmoore at physics.umn.edu>
wrote:

<< Suppose I generate a 1-d vecctor of "N" numbers, p[i], and now I want to
find the sum of (the vector element * index).  I think the syntax should look
something like,

Sum[p[i]*i,{i,0,N}]

but this doesn't seem to be the correct syntax - any help would be
appreciated.


  • Prev by Date: matrix differentiation
  • Next by Date: Re: simple vactor magitude question
  • Previous by thread: Re: simple vactor magitude question
  • Next by thread: Re: simple vactor magitude question