# Sum and Product Loops

It’s something of a truism that mathematical symbolism is difficult. There are some situations, though, where the symbolism is not just difficult, but also annoying and ridiculous. It likely saved a lot of time when people were still mostly writing ideas out by hand, so back then even the annoying and ridiculous could not be righteously pointed at and mocked, but nowadays it is almost certainly more difficult to set some statements in LaTeX than it is to type them—and, if the text is intended to teach students, more difficult to unpack the former than it is to understand the latter.

Examples of symbols that are justly symbolized, even today, are $$\mathtt{\sum}$$ and $$\mathtt{\prod}$$, representing a sum and a product, respectively. More specifically, these symbols represent loops—an addition loop or a multiplication loop.

So, for example, take this expression on the left side of the equals sign, which represents the loop sum on the right of the equals sign: $$\mathtt{\sum_{n=1}^{5}n=1+2+3+4+5}$$. The expression on the left just means (a) start a counter at 1, (b) count up to 5 by 1s, (c) let n = each number you count, then (d) add all the n’s one by one in a loop.

How about this one? $\mathtt{\sum_{n=0}^{4}2n=0+2+4+6+8}$

This one means (a) start a counter at 0, (b) count up to 4 by 1s, (c) let n = each number you count, then (d) add all the 2n’s one by one in a loop.

For products, we just swap out the symbol. Here is the corresponding product for the first loop: $$\mathtt{\prod_{n=1}^{5}n=1\times2\times3\times4\times5}$$. And here’s one for the second loop: $\mathtt{\prod_{n=0}^{4}2n=0\times2\times4\times6\times8}$

Loops and Linear Algebra

You’ll often see the summation loop in linear algebra contexts, because it is an equivalent way to write a dot product, for example. The sum $$\mathtt{\sum_{n=0}^{4}2n=0+2+4+6+8}$$ above can be written as shown below, which looks like more work to write—and is—but when we’re dealing mostly with variables, the savings in writing effort is more evident. $\quad\,\,\,\begin{bmatrix}\mathtt{2}\\\mathtt{2}\\\mathtt{2}\\\mathtt{2}\\\mathtt{2}\end{bmatrix}\cdot \begin{bmatrix}\mathtt{0}\\\mathtt{1}\\\mathtt{2}\\\mathtt{3}\\\mathtt{4}\end{bmatrix}\mathtt{=2\cdot0+2\cdot1+2\cdot2\ldots}$

The loop sum $$\mathtt{\sum_{i}a_{i}x_{i}+b}$$, where $$\mathtt{i}$$ is an index pointing to a component of vector $$\mathtt{a}$$ and vector $$\mathtt{x}$$, can be written more simply as $$\mathtt{a\cdot x+b}$$, as long as the context is clear that $$\mathtt{a}$$ and $$\mathtt{x}$$ are vectors.