I am trying to create a list where each element of the list is calculated using the sum of all previous elements of the list and also uses the $N$th element of another list. The initial value of the list is a known quantity. $k1$ is simply a constant value. $k2$ is a known list of $N$ elements.
$\quad \quad Q_N=\sum_{i=0}^{N-1}{k1(Q_i/k2_N)},\,N>0$ $\quad \quad Q_0=k0$
I'm not quite sure how to code this. I think the Nest
function is somewhat close to what I want, but I need to keep plugging in the sum of all previous values, not just the previous value.
Any help would be greatly appreciated.
Edit: As I keep digging, FoldList
seems like it might be useful, but I just can't seem to crack this problem.
Edit 2: It may be relevant that $N$ is going to be rather large. The context is a numeric solution to the time evolution of a system. So I want to have smaller time-steps, which leads to a large number of elements.
Accumulate
? reference.wolfram.com/language/ref/Accumulate.html $\endgroup$ – Chen Stats Yu Jan 9 '15 at 14:23Q[N]
or allQ[i]
for0 ≤ i ≤ N
? $\endgroup$ – Martin Ender Jan 9 '15 at 15:38FoldList
which seemed to be the way to do it no longer works. $\endgroup$ – FJRA Jan 9 '15 at 15:58