Sum of products of a set of combinations.

I have a function/algorithm that calculates the sum of the products of unique, order important, combination of a set of parameters. The set size is $n$, and the number of parameters used in the combination is $n-1$.

These are examples for $n=1$ to $4$

$n = 1, c(n) = 1$

$n = 2, c(n) = x_1 + x_2$

$n = 3, c(n) = x_1\cdot x_2 + x_1\cdot x_3 + x_2\cdot x_3$

$n = 4, c(n) = x_1\cdot x_2\cdot x_3 + x_1\cdot x_2\cdot x_4 + x_1\cdot x_3\cdot x_4 + x_2\cdot x_3\cdot x_4$

Does anyone know a nice way to write this, mathematically, or could someone point me in the right direction please?

This is the algorithm:

  Function CalcC(L,kIn,mIn) Result (numerator)
! Calculates numerator
Implicit None ! Force declaration of all variables
! Vars In
Real(kind=DoubleReal), Dimension(:) :: L
Integer(kind=StandardInteger) :: kIn, mIn
Real(kind=DoubleReal) :: numerator
! Vars Private
Integer(kind=StandardInteger) :: i, j, k, m, n
Integer(kind=StandardInteger), Dimension(1:(mIn-kIn)) :: combinationSet
Logical :: loopCombinations
Real(kind=DoubleReal) :: tempVal
! init
n = mIn-kIn+1  ! Set size
m = n-1
If(n.eq.1)Then
numerator = 1.0D0
Else
numerator = 0.0D0
! Set up starting combination
Do i=1,m
combinationSet(i) = i
End Do
! Loop through all combinations (order important)
loopCombinations = .true.
k = 0
Do while(loopCombinations)
k = k + 1
If(k.gt.1)Then
j = m
Do i=1,m
loopCombinations = .false.
If(combinationSet(j).lt.(n+1-i))Then
combinationSet(j) = combinationSet(j) + 1
loopCombinations = .true.
Exit
End If
j = j - 1
End Do
End If
If(loopCombinations)Then
tempVal = 1.0D0
Do i=1,m
tempVal = tempVal * L(combinationSet(i)+kIn-1)
End Do
numerator = numerator + tempVal
End If
End Do
End If
End Function CalcC


let the numbers be sampled from a set $S$. I will first create a set $M$ that has the $n - 1$ tuple-multliplied values which will then be summed up into a result set $R$.

$$M = \left \{ \prod_{k = 1}^{n - 1} s_{i_k} : i_k < i_{k + 1}, i_k \in [1, n] \right \}$$

We setup the numbers $i_k$ such that $i_k \in [1, n]$, and every $i_k < i_{k + 1}$. That way, we get to pick $(n - 1)$ elements out of $S$, in such a way that we are picking all partitions uniquely.

And then the number $r$ as

$$r = \sum_{m \in M}m$$

which is the sum of all the multiplied elements.

• Thanks for the answer. I've used $\sum_{i=1,n} \left( \prod_{j=1,n;i \neq j} x_i \right)$ for my case. I should have seen it :) May 5 '16 at 14:44