All guides

Sum and product in LaTeX

Updated:

A sum is written with \sum and a product with \prod. In display math the limits go above and below the symbol; in a line of text they sit beside it so the line spacing stays even.

\sum_{i=1}^{n} x_i
∑i=1nxi\sum_{i=1}^{n} x_i

The subscript is the lower limit and the superscript the upper one. In display math they go below and above the sign, in running text beside it.

Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free

Arithmetic mean

\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i
xˉ=1n∑i=1nxi\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i

You will find this in every lab report: \bar{x} draws the bar over the variable, and the 1/n fraction goes in front of the sum, not inside it.

Product

n! = \prod_{k=1}^{n} k
n!=∏k=1nkn! = \prod_{k=1}^{n} k

\prod behaves like \sum: the same limits and the same size of sign. A factorial is simply an exclamation mark after the number.

Infinite series

\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
∑n=1∞1n2=π26\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}

The upper limit can be \infty. In display math the fraction after the sum keeps its full size, so the series reads like a calculus textbook.

Several conditions under the sign

\sum_{\substack{i=1 \\ i \neq j}}^{n} a_{ij}
∑i=1i≠jnaij\sum_{\substack{i=1 \\ i \neq j}}^{n} a_{ij}

\substack from amsmath stacks several conditions one under another. It is handy for sums that exclude a term, such as over every i other than j.

Limits above and below in a sentence

$\displaystyle\sum_{i=1}^{n} x_i$
∑i=1nxi\displaystyle\sum_{i=1}^{n} x_i

\displaystyle forces the full-size sign with limits above and below even inside a sentence. \sum\limits on its own moves the limits without enlarging the sign.

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free