Author 
Comment/Response 
Xiaolu

02/21/08 7:37pm
Hi,
I am using Mathematica for a recursive algorithm to compute a variable, say, x_i. The algorithm only needs the previous N x's to compute the next x_i. Now I tried to get an x_m, where m is quite large.
I wrote two different Mathematica programs for this problem. In the first one, I saved all the x_i, i=1,...,m, in a 1 x m table. In the second, I only keep the most recent N x_i. So the table size is 1 x N, which is much smaller. To do this, for each i>N, I use "Drop" to get rid of the first element, and "Append" to add a new element. (I also tried to move the 2 to N element to 1 to N1, and add a new one at the end.)
The second way is supposed to require less memory and faster.
What surprised me is that the second way takes much long time, and the memory runs out very fast, and the first way works just well.
I guess there is something very inefficient in what I did. Could anyone help me out? Thanks!
Xiaolu
URL: , 
