L2 Norm in LaTeX (\| \theta \|_2)

∥θ∥2\| \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.

L(θ)+λ2∥θ∥22\mathcal{L}(\theta) + \frac{\lambda}{2} \| \theta \|_2^2
\documentclass{article}
\begin{document}
L2 Norm: $\| \theta \|_2$

\[ \mathcal{L}(\theta) + \frac{\lambda}{2} \| \theta \|_2^2 \]
\end{document}

Related symbols

All التعلم الآلي والذكاء الاصطناعي →

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.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث