Sum Over Classes in LaTeX (\sum_{c=1}^{C})

∑c=1C\sum_{c=1}^{C}
LaTeX command
\sum_{c=1}^{C}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Summation over classes c from 1 to C, as used in multi-class losses and probability normalization.

Sums over classes appear in the categorical cross-entropy, -\sum_{c=1}^{C} y_c \log \hat{y}_c, and in the softmax denominator. In display math the limits go above and below the large sigma; inline they sit to the right in smaller type, which saves line height. Force the display placement inline with \sum\limits, or the reverse with \nolimits. Using C for the number of classes and c for the index is a common convention; just do not reuse C for a cost or constant in the same equation. The symbol \Sigma is a Greek letter and should not replace \sum.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

L=−∑c=1Cyclog⁡y^c\mathcal{L} = -\sum_{c=1}^{C} y_c \log \hat{y}_c
\documentclass{article}
\begin{document}
Sum Over Classes: $\sum_{c=1}^{C}$

\[ \mathcal{L} = -\sum_{c=1}^{C} y_c \log \hat{y}_c \]
\end{document}

Related symbols

All Pembelajaran Mesin & AI →

Frequently asked questions

How do I write Sum Over Classes in LaTeX?
Type \sum_{c=1}^{C} in math mode, for example $\mathcal{L} = -\sum_{c=1}^{C} y_c \log \hat{y}_c$. It works in plain LaTeX without loading any package.
Which package do I need for \sum_{c=1}^{C}?
None. \sum_{c=1}^{C} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \sum_{c=1}^{C} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\sum_{c=1}^{C}$ in running text.
Math poweredTulis LaTeX menggunakan AI

Editor LaTeX AI Terbaik, Alternatif Overleaf

Octree membantu penyelidik dari 15+ universiti menulis kertas penyelidikan dengan lebih cepat menggunakan AI

  • Jana diagram TikZ yang cantik menggunakan AI
  • Muat naik imej dan tukar ke LaTeX dengan lancar
  • Dapatkan bantuan segera untuk menulis dan memformat kertas penyelidikan