B Introduction to Math Notation

B.1 Purpose

This Appendix provides a brief introduction to relevant notation constructs that arise often in optimization. In this appendix we will both briefly review some of these mathematical relationships that commonly arise in mathematical models as well as how these can be expressed using LaTeX in Rmarkdown. A major benefit of using the RMarkdown workflow is that it enables precise mathematical descriptions alongside the actual analysis.

B.2 Basic Summation Notation

In linear programming, we often need to add together a lot of numbers (or variables), such as: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 2 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50

Summation notation is a mathematical shorthand used to represent repeated addition of algebraic expressions involving one or more variables. The Greek capital letter sigma, \(\sum\), is the symbol used to show that we wish to make calculations using summation notation. Since summation notation includes at least one variable–let’s limit this initial examination to one variable only–the variable is displayed below the \(\sum\) symbol. The summation notation below tells us that we will be finding the summation of a variable expression involving \(x\).

\[\sum_{x}\]

The starting value of the variable may be given below \(\sum\) as well. In this case, the summation notation below tells us that the initial value of \(x\) will be equal to 1.

\[\sum_{x=1}\]

In some cases, we may also wish to designate an ending value of the variable, which we can include above the \(\sum\). The summation notation below also tells us that the final value of \(x\) will be equal to 5.

\[\sum_{x=1}^5\]

In all dealings with summation notation, variables will only take integer values, beginning and ending at any values provided within the summation notation. Note that some summations may use an “ending” value of \(\infty\), which would involve the summation of an infinite number of values.

Let’s look at a basic summation problem.

\[\sum_{x=1}^5 2x\]

The summation above means that we will take the \(x\) values, starting at \(x=1\), and multiply the value of \(x\) by 2. We will continue to do this for each integer value of \(x\) until we have reached our ending value of 5. Then we will sum all of our results (five of them, in this case) to produce one final value for the summation.

\[ \begin{split} \begin{aligned} \sum_{x=1}^5 2x & =2\cdot 1+2\cdot 2+2\cdot 3+2\cdot 4+2\cdot 5\\ & =2+4+6+8+10\\ & =30 \end{aligned} \end{split} \]

Summation can be calculated over a variety of algebraic expressions.Another, perhaps more challenging, example is shown below.

\[ \begin{split} \begin{aligned} &\sum_{x=0}^3 x^2-4x+1\\ & =(0^2-4\cdot 0+1)+(1^2-4\cdot 1+1)+(2^2-4\cdot 2+1)+(3^2-4\cdot 3+1)\\ & =1+(-2)+(-3)+(-2)\\ & =-6 \end{aligned} \end{split} \]

B.3 Using LaTeX in RMarkdown

LaTex is a common typesetting used to express mathematical notation. The summation notation symbols thus far in this text have been written using LaTeX. Inline LaTeX commands can be added by including a $ symbol on either side of the LaTeX command. To create entire LaTeX code chunks, include two $$ symbols before and after the chunk of LaTeX.

B.4 Inline Notation

Rmarkdown makes it easy to switch between regular and “inline LaTeX” by selecting whether you use a single or a double $ to wrap the math. Most of the above examples were written using the double $.

Inline tries to help fit the math in the normal height of a line of text. For example, notice how this equation doesn’t really disrupt the line spacing in a paragraph \(\sum_{x=0}^3 x^2-4x+1\). The most obvious difference is in the summation. If it is selected as in-line, the summation limits will be to the right of the summation symbol. If it is regular, the limits will be above and below the summation symbol. As an example, here is the same equation \[\sum_{x=0}^3 x^2-4x+1\\\] entered in the middle with regular text. Entering a regular summation in the paragraph causes problems.

Let’s try the opposite now by showing what an in-line summation looks like when entered on its own line.

\(\sum_{x=0}^3 x^2-4x+1\)

Again, in this case, the summation is not quite right. Given that vertical space is no longer at a premium, it is just harder to read than the regular summation.

The simple rule of thumb in Rmarkdown is to use a double-dollar sign for equations that are entered on their own line and a single dollar sign for symbols that are entered as text.

B.5 Sums

To display the \(\sum\) symbol in LaTex, use the command \sum_{lower}^{upper}. The lower and upper limits of summation after the \sum are both optional. The upper and sometimes the lower are omitted when the interpretation would be unambiguous. The summation expression can be added using the command:
\[\sum_{lower}^{upper}\]

Sum limits can be written to appear above and below the operator using the same notation as for superscript and subscript.

\[ \sum\limits_{t=0}^{n}\dfrac{CF_t}{(1+r)^t} \]

B.6 Delimiters

Delimiters, like parentheses or braces, can automatically re-size to match what they are surrounding. This is done by using \left and \right before the particular parentheses or brace being used. This is a well formatted example:

\[\left( \sum_{i=1}^{n}{i} \right)^2 = \left( \frac{n(n-1)}{2}\right)^2 = \frac{n^2(n-1)^2}{4}\]

For illustration purposes, let’s at the code for the right hand side.
\left( \frac{n(n-1)}{2}\right)^2 = \frac{n^2(n-1)^2}{4}

If we had not used the \left and \right the original equation would have looked like this.

\[( \sum_{i=1}^{n}{i} )^2 = ( \frac{n(n-1)}{2})^2 = \frac{n^2(n-1)^2}{4}\]

B.7 Summary of Mathematical Notations

Below are some common mathematical functions that are often used.

Commonly Used Optimization Modeling Notations.
Math LaTeX Purpose
\[x = y\] x = y Equality
\[x < y\] x < y Strict less than
\[x > y\] x > y Strict greater than
\[x \le y\] x \le y Strict less than
\[x \ge y\] x \ge y Strict greater than
\[x \ne y\] x \ne y Not equal
\[x^n\] x^{n} Superscript or exponentiation
\[x^{\text{Max Demand}}\] x^{\text{Max Demand}} Superscript
\[x_i\] x_i Subscript
\[x_{i,j,k}\] x_\{i,j,k\} Subscript
\[\overline{x}\] \overline{x} Bar
\[\hat{x}\] \hat{x} Hat
\[\tilde{x}\] \tilde{x} Tilde
\[\frac{a}{b}\] \frac{a}{b} Fraction or Ratio
\[1 + 2+\cdots + 10\] 1 + 2 + \cdots + 10 Ellipsis
\[|A|\] |A| Absolute Value
\[x \in A\] x \in A x is in set A
\[x \subset B\] x \subset B x is a proper subset of B
\[x \subseteq B\] x \subseteq B x is a subset of B
\[A \cup B\] A \cup B Union of sets A and B
\[{1, 2, 3}\] \{1, 2, 3\} Set with members 1, 2, and 3
\[\int_{a}^{b} f(x) \; dx\] \int_{a}^{b} f(x) \; dx Integral
\[\sum_{x = a}^{b} f(x)\] \sum_{x = a}^{b} f(x) Summation
\[\lambda\] \lambda Greek letter or symbol
\[3 \cdot x\] 3 \cdot x Use dot for multiplication

Of course there are many more mathematical terms, Greek letters, and more but this table can serve as a common quick reference for things that may come up in frequently in optimization modeling.

B.8 Sequences and Summation Notation

Often, especially in the context of optimization, summation notation is used to find the sum of a sequence of terms. The summation below represents a summing of the first five values of of a sequence of the variable \(x\). The location of the values within the sequence are given by an index value, \(i\) in this case.

\[\sum_{i=1}^5 x_i=x_1+x_2+x_3+x_4+x_5\]

Coefficient values may also be included in a summation, as shown below.

\[\sum_{i=1}^5 \left(10-i\right)x_i=9x_1+8x_2+7x_3+6x_4+5x_5\] A common mistake is to use an asterisk, *, to indicate multiplication in LaTeX.

\[\sum_{i=1}^5 \left(10-i\right)x_i=9*x_1+8*x_2+7*x_3+6*x_4+5*x_5\]

While the * is used for multiplication in R, it both takes more space and and is not considered formal mathematical notation. In LaTeX you should instead use \\cdot in place of the asterisk. In other words, \(\cdot\) in place of \(*\). The result is the following:

\[\sum_{i=1}^5 \left(10-i\right)x_i=9\cdot x_1+8\cdot x_2+7\cdot x_3+6\cdot x_4+5\cdot x_5\]

When it is clearly implied by the expression as in the above example where we are multiplying a number and a variable, the \\cdot is optional (\(9x\) vs. \(9\cdot x\)). On the other hand, it is much more important when a number is not involved (\(Ax\) vs. \(A\cdot x\)).

B.9 Applications of Summation

Sequence applications of summation notation can be very practical in that we can extract real-world data values given in an array or a matrix.

For example, let’s imagine that the itemized cost for the production of a product from start to finish is that which is given in the table below.

# Load library
library(kableExtra,quietly = TRUE)

# Create data table
M1 <- matrix(c(11,12,13,14,15), ncol=1)
rownames(M1)<-list("Design", "Materials", 
                   "Production", "Packaging", 
                   "Distribution")
colnames (M1) <- list("Product 1")
kbl (M1, booktabs=T,
       caption="Production Costs for Product 1")
TABLE B.1: Production Costs for Product 1
Product 1
Design 11
Materials 12
Production 13
Packaging 14
Distribution 15

We might wish to determine the total cost to produce the product from start to finish. We can extract the data from our cost matrix and use summation to find the total cost.

\[ \begin{split} \begin{aligned} &\sum_{i=1}^5x_i\\ &=x_1+x_2+x_3+x_4+x_5\\ &=11+12+13+14+15\\ &=65 \end{aligned} \end{split} \]

Let’s say we now have additional products being produced.

# Load Data Table 2
M2<-matrix(c(11,12,13,14,15,21,22,23,24,25,31,32,33,34,35), ncol=3)
rownames(M2)<-list("Design", "Materials", "Production", 
                   "Packaging", "Distribution")
colnames(M2)<-list("Product 1", "Product 2", "Product 3")
kbl(M2, booktabs=T, caption=
         "Itemized Production Costs for Three Products")
TABLE B.2: Itemized Production Costs for Three Products
Product 1 Product 2 Product 3
Design 11 21 31
Materials 12 22 32
Production 13 23 33
Packaging 14 24 34
Distribution 15 25 35

We might wish to determine the cost to produce each of the three products from start to finish. We could show this with the following summation notation.

\[\sum_{i=1}^{5}x_{i,j}\ \; \forall\ j \]

This notation indicates that we are summing the cost values in the \(i\) rows for each product in column \(j\). Note that the symbol \(\forall\) shown in the summation above translates to the phrase “for all.” The summation expression above can be interpreted as “the sum of all values of \(x_{i,j}\), starting with an initial value of \(i=1\), \(for\ all\) values of \(j\).” The expression will result in \(j\) summations.

\[ \begin{split} \begin{aligned} &\sum_{i=1}^5x_{i,j}\ \; \forall \ j\\ &=x_{1,1}+x_{2,1}+x_{3,1}+x_{4,1}+x_{5,1}\\ &=11+12+13+14+15\\ &=65 &\text{Cost for Product 1}\\ \\ AND\\ \\ &=x_{1,2}+x_{2,2}+x_{3,2}+x_{4,2}+x_{5,2}\\ &=21+22+23+24+25\\ &=115 &\text{Cost for Product 2}\\ \\ AND\\ \\ &=x_{1,3}+x_{2,3}+x_{3,3}+x_{4,3}+x_{5,3}\\ &=31+32+33+34+35\\ &=165 &\text{Cost for Product 3} \end{aligned} \end{split} \]

We can see that the summation expression resulted in three summation values since \(j\), can take on values of 1, 2, or 3. These summation values are 65, 115, and 165, representing the total cost from start to finish to produce Product 1, Product 2, and Product 3 respectively.

B.10 Double Summation

For some projects or models, we may need to add one summation into another. This procedure is called “double summation.” Consider the following double summation expression: \sum_{i=1}^3\sum_{j=1}^4 (i+j)

\[\sum_{i=1}^3\sum_{j=1}^4 (i+j)\]

Note that the expression contains two \(\sum\) symbols, indicating a double summation. The double summation would expand as shown below.

\[ \begin{split} \begin{aligned} \sum_{i=1}^3\sum_{j=1}^4 (i+j)\\ &=(1+1)+(2+1)+(3+1)\\ &+(1+2)+(2+2)+(3+2)\\ &+(1+3)+(2+3)+(3+3)\\ &+(1+4)+(2+4)+(3+4) \end{aligned} \end{split} \]

B.11 Applications of Double Summation

Consider a transportation application using double summation in which we want to ship a given amount of product \(X\) from location \(i\) to location \(j\), denoted \(X_{i,j}\). The summation notation for this application is shown below.

\[\sum_{i=1}^n\sum_{j=1}^m X_{i,j}\]

Expanding on the previous summation, we may also want to include shipping costs \(C\) from location \(i\) to location \(j\), denoted \(C_{i,j}\). Combining the amount of product with the related shipping costs would result in the double summation expression shown below.

\[\sum_{i=1}^n\sum_{j=1}^m C_{i,j}X_{i,j}\]

B.12 Exercises

Exercise B.1 (Expand-Summation1) Write all terms and calculate the summation for the following:

\[ \begin{split} \begin{aligned} A. && \sum_{x=1}^4 x+3\\ \\ B. && \sum_{x=0}^5 8x-1\\ \end{aligned} \end{split} \]

Exercise B.2 (Expand-Summation2) Write as a sum of all terms in the sequence.

\[ \begin{split} \begin{aligned} \sum_{x=1}^6 (2i)x \end{aligned} \end{split} \]

Exercise B.3 (Evaluate-Summation1) Write a summation to represent the total cost associated with producing three items of Product 1. Use the values from the first table in the Appendix to evaluate your summation expression.

Exercise B.4 (Evaluate-Summation2) Write all terms and calculate the summation for each exercise.

\[ \begin{split} \begin{aligned} A. && \sum_{i=1}^3\sum_{j=1}^4 (i \cdot j)\\ \\ B. && \sum_{i=1}^5\sum_{j=1}^2 (3\cdot i-j)\\ \end{aligned} \end{split} \]

Exercise B.5 (Employee-Summation) A company compensates its employees with an annual salary and an annual bonus.

A. Write an expression using summation notation to represent the total annual compensation \(i\) (including salary and bonus) for each job title \(j\).
B. Write a double summation expression to represent the total amount the company pays annually to compensate all its employees if each job title has \(n_j\) employees.

(Need possible sample expression for A. and B.)