L2 Norm in LaTeX (\| \theta \|_2)
- LaTeX command
\| \theta \|_2- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Euclidean (L2) norm of theta: the square root of the sum of its squared entries.
The L2 norm \|\theta\|_2 = \sqrt{\sum_i \theta_i^2} measures length, and its square appears as the ridge or weight-decay penalty \lambda\|\theta\|_2^2. Note the order of scripts: \|\theta\|_2^2 is the squared norm, and TeX stacks the subscript and superscript neatly. Many authors drop the subscript 2 when context is clear. For better delimiter spacing, use \lVert and \rVert instead of \|, and \left\| \right\| for tall contents like fractions. For matrices, \|A\|_2 usually means the spectral norm, not the entrywise one, which is the Frobenius norm.
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
L2 Norm: $\| \theta \|_2$
\[ \mathcal{L}(\theta) + \frac{\lambda}{2} \| \theta \|_2^2 \]
\end{document}Related symbols
- Frobenius Norm
\| \mathbf{W} \|_F - L1 Norm
\| \theta \|_1 - Product Over Samples
\prod_{i=1}^{N} - Sum Over Classes
\sum_{c=1}^{C} - Conditional Probability
p(y | x) - Probability Distribution
p(x)
Frequently asked questions
- How do I write L2 Norm in LaTeX?
- Type \| \theta \|_2 in math mode, for example $\mathcal{L}(\theta) + \frac{\lambda}{2} \| \theta \|_2^2$. It works in plain LaTeX without loading any package.
- Which package do I need for \| \theta \|_2?
- None. \| \theta \|_2 is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \| \theta \|_2 in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\| \theta \|_2$ in running text.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu peneliti dari 15+ universitas menulis makalah penelitian lebih cepat menggunakan AI
- Hasilkan diagram TikZ yang indah menggunakan AI
- Unggah gambar dan konversi ke LaTeX dengan mulus
- Dapatkan bantuan instan untuk menulis dan memformat makalah penelitian