Accumulate on Inactive lists
[for S7 combinator growth]

Jose, Dec 3, 2020

Original expression

block[n_]=Inactive[Join][38{0,0,0,12,-17}
n
2
+{0,1,0,-135,189},Inactive[Table][0,{i,n}],38{0,1,0,0,1,-1,0,0,0,4}
n
2
+{12,-13,0,6,-7,1,0,1,0,-27},Inactive[Table][0,{i,n+2}],228{0,1,0,0,1,-1}
n
2
+2{6,-20,0,3,-17,14}]
Join[{0,1,0,-135+57
3+n
2
,189-323
1+n
2
},Table[0,{i,n}],{12,-13+19
1+n
2
,0,6,-7+19
1+n
2
,1-19
1+n
2
,0,1,0,-27+19
3+n
2
},Table[0,{i,2+n}],{12,-40+57
2+n
2
,0,6,-34+57
2+n
2
,28-57
2+n
2
}]
nmax=200;
blocks0=Flatten@Activate[Table[block[n],{n,nmax}]];
blocks1=Accumulate[blocks0];
blocks2=Accumulate[blocks1];
len=Length[blocks0]
44800
ListLogPlot[blocks0]
ListLogPlot[blocks1]
ListLogPlot[blocks2]

Manipulation of inactive lists

Idea

We will work on lists, Inactive[Table][body, {i, n}] and Inactive[Join][...].
We are interested in the operations Length, Total and Accumulate.

Length

length[list_List]:=Length[list];​​length[Inactive[Table][body_,{k_,n_}]]:=n;​​length[Inactive[Join][lists___]]:=Total[length/@{lists}];

Total

total[list_List]:=Total[total/@list];​​total[Inactive[Table][body_,it_]]:=Sum[body,it];​​total[Inactive[Join][lists___]]:=Total[total/@{lists}];​​total[x_]:=x;
mean[expr_]:=total[expr]/length[expr]

Accumulate

accumulate[list_]:=accumulate[0,list];​​accumulate[n_,Inactive[Join][lists__]]:=accumulateFold[n,lists]
accumulateFold[seed_]:=Inactive[Join][];​​accumulateFold[seed_,list_List,rest___]:=With[{a=Simplify[seed+Accumulate[list]]},Join[Inactive[Join][a],accumulateFold[Last[a],rest]]];​​(*accumulateFold[seed_,Inactive[Table][0,{k_,n_}],rest___]:=Join[Inactive[Join][Inactive[Table][seed,{k,n}]],accumulateFold[seed,rest]];*)​​accumulateFold[seed_,Inactive[Table][body_,{k_,n_}],rest___]:=Join[Inactive[Join][Inactive[Table][Simplify[seed+Sum[body,{K,k}]],{k,n}]],accumulateFold[seed+Sum[body,{K,n}],rest]]

First integration

accumulate[block[n]]
Join[{0,1,1,-134+57
3+n
2
,55-95
1+n
2
},Table[55-95
1+n
2
,{i,n}],{67-95
1+n
2
,54-19
3+n
2
,54-19
3+n
2
,60-19
3+n
2
,53-57
1+n
2
,54-19
3+n
2
,54-19
3+n
2
,55-19
3+n
2
,55-19
3+n
2
,28},Table[28,{i,2+n}],{40,57
2+n
2
,57
2+n
2
,6+57
2+n
2
,-28+57
3+n
2
,57
2+n
2
}]
Add all last elements:
sum1[n_]=Sum[57
2+i
2
,{i,1,n}]
456(-1+
n
2
)
Shifted blocks:
acblock[n_]=accumulate[sum1[n-1],block[n]]
Join[{228(-2+
n
2
),-455+57
2+n
2
,-455+57
2+n
2
,-590+171
2+n
2
,-401+19
1+n
2
},Table[-401+19
1+n
2
,{i,n}],{-389+19
1+n
2
,-402+19
2+n
2
,-402+19
2+n
2
,4(-99+19
n
2
),-403+57
1+n
2
,-402+19
2+n
2
,-402+19
2+n
2
,-401+19
2+n
2
,-401+19
2+n
2
,4(-107+57
n
2
)},Table[4(-107+57
n
2
),{i,2+n}],{4(-104+57
n
2
),456(-1+
n
2
),456(-1+
n
2
),-450+57
3+n
2
,4(-121+171
n
2
),456(-1+
n
2
)}]
Check:
Activate[Join@@Table[acblock[n],{n,1,nmax}]]===blocks1
True

Second integration

accumulate[acblock[n]]
Join[{228(-2+
n
2
),-911+57
3+n
2
,-1366+171
2+n
2
,-1956+171
3+n
2
,-2357+703
1+n
2
},Table[-2357+703
1+n
2
+(-401+19
1+n
2
)i,{i,n}],{-2746+361
2+n
2
+(-401+19
1+n
2
)n,-3148+95
4+n
2
+(-401+19
1+n
2
)n,-3550+399
2+n
2
+(-401+19
1+n
2
)n,-3946+209
3+n
2
+(-401+19
1+n
2
)n,-4349+893
1+n
2
+(-401+19
1+n
2
)n,-4751+931
1+n
2
+(-401+19
1+n
2
)n,-5153+969
1+n
2
+(-401+19
1+n
2
)n,-5554+1007
1+n
2
-401n+19
1+n
2
n,-5955+1045
1+n
2
+(-401+19
1+n
2
)n,-6383+1159
1+n
2
+(-401+19
1+n
2
)n},Table[-6383+1159
1+n
2
+4(-107+57
n
2
)i+(-401+19
1+n
2
)n,{i,2+n}],{-7655+1501
1+n
2
+(-829+133
1+n
2
)n,-8111+1729
1+n
2
+(-829+133
1+n
2
)n,-8567+1957
1+n
2
+(-829+133
1+n
2
)n,-9017+2185
1+n
2
+(-829+133
1+n
2
)n,-9501+2527
1+n
2
+(-829+133
1+n
2
)n,-9957+2755
1+n
2
+(-829+133
1+n
2
)n}]
Add all last elements:
sum2[n_]=Sum[-9957+2755
1+i
2
+(-829+133
1+i
2
)i,{i,1,n}]
1
2
(-20976+1311
4+n
2
-20743n+133
3+n
2
n-829
2
n
)
Shifted blocks:
acacblock[n_]=accumulate[sum2[n-1],acblock[n]]
Join-987+2603
1+n
2
+-
19085
2
+133
1+n
2
n-
829
2
n
2
,
1
2
(4(-721+2717
n
2
)+(-19085+133
2+n
2
)n-829
2
n
),
1
2
(-3794+2831
2+n
2
+(-19085+133
2+n
2
)n-829
2
n
),
1
2
(-4974+3173
2+n
2
+(-19085+133
2+n
2
)n-829
2
n
),
1
2
(-5776+399
5+n
2
+(-19085+133
2+n
2
)n-829
2
n
),Table
1
2
(-5776+399
5+n
2
+(-802+19
2+n
2
)i+(-19085+133
2+n
2
)n-829
2
n
),{i,n},
1
2
(-6554+3211
2+n
2
+(-19887+19
5+n
2
)n-829
2
n
),
1
2
(-7358+3249
2+n
2
+(-19887+19
5+n
2
)n-829
2
n
),
1
2
(-8162+3287
2+n
2
+(-19887+19
5+n
2
)n-829
2
n
),
1
2
(-8954+3325
2+n
2
+(-19887+19
5+n
2
)n-829
2
n
),
1
2
(-9760+1691
3+n
2
-19887n+19
5+n
2
n-829
2
n
),-5282+855
3+n
2
+-
19887
2
+19
4+n
2
n-
829
2
n
2
,28(-203+247
n
2
)+-
19887
2
+19
4+n
2
n-
829
2
n
2
,-6085+437
4+n
2
+-
19887
2
+19
4+n
2
n-
829
2
n
2
,-6486+1767
2+n
2
+-
19887
2
+19
4+n
2
n-
829
2
n
2
,-6914+57
7+n
2
+-
19887
2
+19
4+n
2
n-
829
2
n
2
,Table-6914+57
7+n
2
+4(-107+57
n
2
)i+-
19887
2
+19
4+n
2
n-
829
2
n
2
,{i,2+n},-8186+1995
2+n
2
+-
20743
2
+133
2+n
2
n-
829
2
n
2
,-8642+2109
2+n
2
+-
20743
2
+133
2+n
2
n-
829
2
n
2
,-9098+2223
2+n
2
+-
20743
2
+133
2+n
2
n-
829
2
n
2
,-9548+2337
2+n
2
-
20743n
2
+133
2+n
2
n-
829
2
n
2
,
1
2
(20064(-1+
n
2
)+(-20743+133
3+n
2
)n-829
2
n
),
1
2
(20976(-1+
n
2
)+(-20743+133
3+n
2
)n-829
2
n
)
Check:
All blocks behave in similar ways...

Main result

Given that the result is oscillatory, there are several options we can follow

Asymptotics

Let us take the last element of the twice-accumulated block n (it would probably be better to compute the average of the block):
Those correspond to positions
Therefore what we want is
The agreement is quite good:
There is a residual oscillatory term in all cases. The mean seems more centered:
Finally:
Compare to Stephen’s result, which does not seem correct:
OSZAR »