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_iThe 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_iYou 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\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}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}\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$\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
- Using the capital letter \Sigma instead of \sum: it looks similar but has the wrong size and no room for limits.
- A limit without braces: \sum_i=1^n gives the index i followed by an ordinary =1. The whole limit expression must be in { }.
- A sum inside plain parentheses: they stay short next to the tall sum sign. Use \left( and \right).
See also
Don't want to memorize commands?
Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.