Let $a$ be a set of vectors such that $a = \{q^2, q^3, q^4\, ...\}$, where $q^k$ is a vector of length $2^k$, and of the form $q^k = \{q[1], q[2], ..., q[k]\}.$ I want to evaluate a sum like $\sum\limits_{k=2}^{N-1} \sum\limits_{h>k}^N \sum\limits_{i=1}^{n_k} q_{i}^k q_{i}^h$, where $n_k$ is the length of the vector $q^k$, and $N$ is the cardinality of $a$. This involves taking the product of components of vectors in seperate elements of the set. I made an attempt and got a nasty set of errors.
a = Array[q, 4]
b = Array[r, 8]
c = Array[s, 16]
z = {a, b, c}
OverlapV[v_] :=
Subscript[\[Lambda], overlap] Sum[With[{l = Length[v[[k]]]}, Sum[Sum[
v[[k]][[i]] v[[h]][[i]], {i, 1, l}, {h, i + 1, Length[v]}], {h,
i + 1, Length[v]}]], {k, 1, Length[[v[k]]] - 1}]
I managed to accomplish something similar for the term $\sum\limits_{k=2}^{N} \sum\limits_{i = 1}^{n_k - 1} \sum\limits_{j > i}^{n_k} q_{i}^k q_{j}^k$ after some help in a similar posted question with this code:
One[x_] := With[{l = Length[x]},
Sum[Sum[x[[i]] x[[j]], {i, 1, l}, {j, i + 1, l}], {i, 1, l - 1}]]
OneV[v_] :=
Subscript[\[Lambda], one] Sum[F[v[[k]]], {k, 1, Length[v]}]
which gives the output:
This is what I am trying to output for the first term. I am new to Mathematica, so I apologize if the code is messy or not idiomatic.
a, b, c
are smaller lists, e.g. of length2, 3, 4
. $\endgroup$One
is wrong, unless you really want to sum twice overi
; but the outer sum, where you have{i, 1, l - 1}
, sums over an already summed expression with no iterator left, so it basically mulitplies it byl-1
... $\endgroup$z
: you want to sum overk
from 2 to $N−1=3-1=2$, so basically you're just settingk=2
. Next, over $h>k=2$ up to $N=3$, so in fact $h=3$. So effectively you're summing over $i$ from 1 to $n_k=n_2=$Length@b
$=8$. The output isr[1] s[1] + r[2] s[2] + r[3] s[3] + r[4] s[4] + r[5] s[5] + r[6] s[6] + r[7] s[7] + r[8] s[8]
. $\endgroup$