# Which parentheses are implied by $\prod$?

Which is correct? $$\prod_a ab = \left[ \prod_a a\right]b$$ or $$\prod_a ab = \prod_a \left[ ab \right]$$

I'd say the latter, but with $\sum$ we have $$\sum_a a + b = \left [ \sum_a a \right ] + b$$ Do they work differently, or did I guess wrong? Also, are these things defined somewhere (or at least documented)? Wikipedia and Mathworld let me down on this one.

-
It's ambiguous. (Your other example with $\sum$ is also ambiguous.) If you see this in a paper you'll have to figure it out from context. –  Qiaochu Yuan Aug 22 '12 at 18:42
In general the notation on the right hand side ;-). In other words, avoid ambiguous notation and use parenthesis. –  user20266 Aug 22 '12 at 18:42
I have never seen the first interpretation used (except when multiplying two indexed products together, sometimes parentheses are omitted), but I often see the second one. In my opinion the summation one is even more ambiguous because both possible interpretations are used occasionally. In any case, as Qiaochu says, context is king. –  anon Aug 22 '12 at 18:44
Usually one would write $b+\Sigma$ or $b\prod$ for those instances. –  JSchlather Aug 22 '12 at 18:44
@Qiaochu, I don't think it's that ambiguous! Have you ever seen anyone use $\prod ab$ to mean $(\prod a)b$? Anyway, my feeling is that $\sum a+b$ and $\prod a+b$ may be potentially ambiguous but $\sum ab$ and $\prod ab$ are not. –  Rahul Aug 22 '12 at 18:45

If $b$ is does not depend on the index of summation, $$\sum_a(ab)=\left(\sum_aa\right)b=b\sum_aa\;,$$ so there’s no ambiguity. If $b$ does depend on the index of summation, either $\sum\limits_aab$ is to be understood as $\sum\limits_a(ab)$, or the writer made a bad mistake.

The expression $\sum\limits_aa+b$, however, is potentially ambiguous and should not be used; write $\sum\limits_a(a+b)$ if that’s the desired interpretation, and $\left(\sum\limits_aa\right)+b$ or, better, $b+\sum\limits_aa$ if that’s the desired interpretation. When reading, you have to use your head and pay attention to the context. E.g., something like $\sum\limits_{k=1}^na_k+b_k$ is surely intended to be read as $\sum\limits_{k=1}^n(a_k+b_k)$, though it’s a horribly sloppy way of writing it. $\sum\limits_{k=1}^na_k+b$, on the other hand, probably means $b+\sum\limits_{k=1}^na_k$, but if you see it being evaluated as $$\sum\limits_{k=1}^na_k+b=A(n)+nb\;,$$ it probably meant $\sum\limits_{k=1}^n(a_k+b)$, and the $nb$ is the result of summing those $n$ $b$ terms.

-
What is the difference between the second and fourth term in the first equation you wrote down? (In other words, why did you repeat it?) –  user20266 Aug 22 '12 at 19:04
@Thomas: I meant to relocate it from second to third position in the string and apparently forgot to erase the original copy. Thanks; fixed. –  Brian M. Scott Aug 22 '12 at 19:10
There is no potential ambiguity in $\sum_xab$, whatever $a,b$ might be: multiplication has higher precedence than addition even when the latter is represented as $\sum$. There are literally millions of examples of this you can find on this site and everywhere, just think of the binomial formula $(x+y)^n=\sum_k\binom nkx^ky^{n-k}$; it would be ridiculous to ask for parentheses in the RHS. However, the question was about $\prod$ and multiplication, or $\sum$ and addition. –  Marc van Leeuwen Sep 13 '13 at 10:21
@Marc: If you read carefully, you’ll see that the last sentence of the first paragraph is in complete agreement with your view of how the expression should be interpreted. However, I think that you’re pointing to the wrong reason: the fact that in the second case the expression makes no sense if $b$ is interpreted as being outside the sum is far more fundamental than any convention regarding the order of operations. I’ve no idea why none of us caught the $\prod\to\sum$ change; it’s been over a year. –  Brian M. Scott Sep 13 '13 at 10:33
I see what you mean; I probably misinterpreted what you wrote as suggesting that leaving out parentheses in $\sum ab$ could in some cases be a bad mistake. But what you say is not really very logical either: in $\sum_ia_ib_i$ it either means what you think it does, or the author makes a bad mistake. Doubly bad indeed: he might have meant $(\sum_ia_i)b_i$, ignoring that (1) this is not the proper parsing and (2) it is meaningless. –  Marc van Leeuwen Sep 13 '13 at 13:08

This is an important question, and it is a shame that there is no agreed-upon answer. One thing that is clear, is that a multiplication on its right binds more strongly than the $\sum$ operator, always. On the left there is no choice, and $\sum$ acts first in cases like $2\sum_ia_i$. No parentheses are needed either in cases like $$\prod_{i\in I}\sum_{j\in J}a_{i,j} = \sum_{f:I\to J}\prod_{i\in I}a_{i,f(i)},$$ in whose left hand side the summation is applied before multiplication, not because of precedence rules but because the order of the operators used leaves no room for another interpretation.

Although some seem to disagree, it seems clear to me that between $\sum$ and "$+$" or binary "$-$" to its right, the summation binds stronger (and therefore ends at the mentioned operator). It is true that $\sum_ia_i+b$ might be written less confusingly as $b+\sum_ia_i$, but how about $\sum_ia_i+\sum_jb_j$, which certainly does not get less confusing by writing it as $\sum_jb_j+\sum_ia_i$? I think it is easy to find plenty of such examples in the literature, where two independent summations are added or subtracted without using parentheses; if the convention were either that such "$+$" or "$-$" binds stronger than summation, or that no precedence is defined at all, parentheses enclosing the first summation would be required (for the second there is no ambiguity). Note that the ambiguity at stake here is not just syntactic but semantic: including a second summation into the summand of the first one would add the terms of the second summation many more times than with separate summations, giving a different result. Based on the fact that people do add and subtract summations without parentheses, I think that there is agreement (even if unconscious to some) that an unparenthesised "$+$" or "$-$" does terminate a summation that is in progress.

For $\prod$ and multiplication the situation ought to be the same as for $\sum$ and addition, but I think there is less agreement about this. For one thing cases that reveal what people unconsciously think by what they do in practice are far more rare than for addition. Leafing through Concrete Mathematics which is replete with summations, I had a hard time finding any examples for products. However I found this one on page 490, in a list of "basic analogies": $$\sum_{k\in K}\left(a_k+b_k\right) = \sum_{k\in K}a_k+\sum_{k\in K}b_k \longleftrightarrow \prod_{k\in K}a_kb_k = \left(\prod_{k\in K}a_k\right)\left(\prod_{k\in K}b_k\right).$$ The second identity illustrates that these authors believe that the situation is contrary to the additive one: a multiplication does not terminate a product in progress (on the left), while multiplying two products requires additional parentheses (the second pair is just for aesthetic reasons). Actually the whole line (notably the placing of parentheses) shows beautifully how multiplicative notation is not analogous to additive notation.

Another example in the same book is $\sum_{k=1}^n(1+z/k)e^{-z/k}$ (page 535) without additional parentheses. Also the Jacobi triple product (actually a triply infinity product) gets written without additional parentheses: TAOCP Vol 4A page 396 has $\prod_{k=1}^\infty(1-u^kv^{k-1})(1-u^{k-1}v^k)(1-u^kv^k)$ rather than the more prudent $\prod_{k=1}^\infty\bigl((1-u^kv^{k-1})(1-u^{k-1}v^k)(1-u^kv^k)\bigr)$, or $\prod_{k=1}^\infty(1-u^kv^{k-1})\prod_{k=1}^\infty(1-u^{k-1}v^k)\prod_{k=1}^\infty(1-u^kv^k)$ which would use the opposite convention. And here is an interesting one where a first product encloses a second product, from [A. Borodin, Duke Math J. 140(3) (2007); proposition 5.1]; note how $n$ lives all the way to the end. $$\prod_{n\geq1}{1\over1-s^{nN}} \prod_{p\in\overline{1,N}:A[p]=1\atop q\in\overline{1,N}:B[q]=1} {1\over1-s^{(p-q)(N)+(n-1)N}}$$

But I am sure I have also seen examples of that opposite convention: multiplication of independent products without additional parentheses. A quick search revealed quite a few instances in Stanley's Enumerative Combinatorics$~2$, page 370, 458; note however that Stanley often, but not always, writes a dot for the multiplication, as in $\prod_x f(x)\cdot\prod_yg(y)$, which supposedly is there to suggest the proper parsing of the formula.

In conclusion, for products involving a multiplication differently people have different conventions, but surprisingly mathematicians seem to prefer to err on the side of writing too few parentheses rather than too many (computer programmers are quite the opposite).

Added Thinking of this a bit longer, I realise that there is a point of view that makes the above seem much more coherent:

The precedence of all large operators like $\sum$, $\prod$, $\int$ (and others like $\bigoplus$, $\coprod$ as well in cases where it would be relevant) with respect to binary operators to their right are all equal and situated in between the precedence of '$+$' and and $-$' on one hand and the precedence of multiplication (notated using juxtaposition) and '$/$' on the other hand.

The $\cdot$ operator used to separate products without the need of parentheses can be considered to be a syntactic variant of multiplication introduced with the explicit purpose of being of lower precedence than $\prod$ (but it would then also be lower than that of $\sum$, allowing to write $\sum_ia_i\cdot\sum_jb_j$ without parentheses, which is an interesting proposal).

-

Those expressions are inherently ambiguous In part this is a fault of the notation, since it lacks a delimiter that signifies the end of the sum. Contrast this to integrals, which have $\rm\ 'dx\,'\:$ delimiting the end of the integrand

$$\rm \int (f(x) + g(x))\ dx\quad vs.\quad \sum_k\ f(k) + g(k)$$

This is one reason why some authors write indefinite sums in an analogous form

$$\rm \sum\ (f(k) + g(k))\ \Delta k$$

Generally it is best to avoid use of such ambiguous expressions by inserting parentheses as need be to make clear the intended parsing.

-
The $dx$ does not help, $\int f(x) + g(x)dx$ without parentheses is still syntactically wrong, even though there is only one possible interpretation. –  Marc van Leeuwen Sep 13 '13 at 10:23

I think the common convention is $$\sum_a a+b = \left(\sum_a a\right) + b$$ but $$\prod_a ab = \prod_a (ab).$$ This is the first time that I realize that this is in some sense inconsistent.

-