2
$\begingroup$

Apologies if this is not the right forum, I am happy to re-post somewhere more appropriate. I would like to know the mathematical notation for the following Mathematica expression:

 Apply[Plus, 
  Times @@@ 
   Subsets[Table[Subscript[\[Delta], i], {i, 1, J}], {J - j} ] ]

where J and j are positive integers, such that $J \ge j > 0$, and $\delta_i$ ($i=1,\ldots,J$) are positive constants. Unsurprisingly, the Mathematica "Copy as LaTex" functionality does not work for this type of code. Any suggestions would be greatly appreciated.

$\endgroup$
5
  • 2
    $\begingroup$ This is not a well-posed question. This is a piece of code describing an algorithm. It's not always productive to try to give mathematical notation for it. Can you clarify the question? Do you want to know what the code does? If you already know it, coming up with mathematical notation for it is off-topic here. If not, then break down the expression and ask about the specific part you don't understand and could not look up in the documentation. $\endgroup$
    – Szabolcs
    Jun 2 at 0:19
  • 1
    $\begingroup$ The code takes all possible subsets of $\delta_i$, mutliplies the elements within each, and adds up the results. Note that the empty subset is considered as well, for which the product is 1. $\endgroup$
    – Szabolcs
    Jun 2 at 0:21
  • $\begingroup$ I do now what the code does, I was simply looking for how to write this in proper mathematical notation. Please see the comment below by eyorble, which answers my question. $\endgroup$
    – emakalic
    Jun 2 at 2:18
  • $\begingroup$ Hi OP, welcome to mma.SE! If the answer(not comment) does indeed answer your question, it would be useful to accept the answer by giving it a green checkmark! $\endgroup$ Jun 2 at 14:20
  • $\begingroup$ Thanks CA Trevillian. Will do. $\endgroup$
    – emakalic
    Jun 3 at 4:22

1 Answer 1

6
$\begingroup$

The code provided appears to implement the following:

Let $\Delta$ be a set containing $\delta_1, ..., \delta_i, ..., \delta_J$. In the original code, this would refer to Table[Subscript[δ,i],{i,1,J}].

Let $S = \binom{\Delta}{J-j}$. This is the set of all distinct combinations of $J-j$ members of $\Delta$. This is based on this math.SE answer. In the original code, this would refer to Subsets[..., {J-j}].

The expression given is then: $\sum_{U \in S} \prod_{v \in U} v$. This is based on another math.SE answer. In the original code, this is the Apply[Plus,Times@@@ ...] part, though the translation into sums and products is perhaps not as clean as this might seem to make it.

A more direct implementation of this last step might look like:

Sum[Product[v, {v, u}], {u, Subsets[Table[Subscript[δ,i], {i, 1, J}], {J-j}]}]

Which is functionally identical but perhaps easier to reason about. For example, it should be relatively clear that Product[v, {v, u}] is equivalent to Times @@ u, and then instead of summing over the subsets all of the subsets can have Times applied at once with @@@ and Apply[Plus,...] can be used in place of Sum.

$\endgroup$
1
  • $\begingroup$ Thanks @eyorble - this is exactly what I was looking for. $\endgroup$
    – emakalic
    Jun 2 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.