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 Machine Learning at AI →

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 poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers