Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

algorithm for a sum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7648] algorithm for a sum
  • From: Xah Lee <xah at best.com>
  • Date: Tue, 24 Jun 1997 03:36:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I'm wondering if it is possible to to have a lower order algorithm for calculating the following sum. I have a non-negative integer sequence {f[1],f[2],...f[n]}. Suppose n=5,

li2=Array[f,{5}]

I want the following sequence of sums:

resultA = Table[1+Sum[Product[li2[[j]],{j,1,i}],{i,1,n}],{n,1,Length at li2}];
ColumnForm at resultA

For speed, I have implemented the above formula as follows:

resultA = Rest at FoldList[#1+#2&,1,Rest@(FoldList[#1*#2&,1,li2])]

Is there a closed form to this formula? But if you have different implementation that's interesting, please post it too. Thanks.

 Xah, xah at best.com, http://www.best.com/~xah/
 #1 author: http://www.physics.wisc.edu/~shalizi/Russell/




  • Prev by Date: Re: Intelligent handling of Infinity in Limits
  • Next by Date: problems with precision
  • Previous by thread: MMA 3.0.1 fixes Mac printing problems!
  • Next by thread: problems with precision