As a minimal example, define a function like
s[1,2,3]; this is a function of three arguments in this case, but I'd like to apply this general idea to functions like
s[3,4,5,6,7] which don't necessarily start at 1.
From an identity from theory, I need to re-express this as as sum of 2-argument functions that cycle over all of the possible combinations of the original function, but don't duplicate. Explicitly, this would be the same as writing
or in the longer more general case (and to illustrate my point)
s[3,4,5,6,7] = f[3,4]+f[3,5]+f[3,6]+f[3,7]+f[4,5]+f[4,6]+f[4,7]+f[5,6]+f[5,7]+f[6,7]
I was previously using the definition with simple replacement rules for each of the these chains, with general cases of
s[i_,j_,k_] and such similar rules. However, this isn't optimal in larger problems, where I have many thousands of these results, and leads to remarkably long evaluation times.
To see my functional but slow solution, I have attached a partial screenshot here, but naturally, I think there must be a better method. I was considering using
Partitions, as in this SE post or BlankSpaces, but I struggle to implement more complex uses of these. Any guidance or other ideas would be gratefully appreciated. Also, a title suggestion would be great as well!