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 機械学習・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 poweredAIでLaTeXを書く

最高のAI LaTeXエディタ、Overleaf代替

Octreeは15以上の大学の研究者がAIを使って論文をより速く書くのを支援

  • AIで美しいTikZダイアグラムを生成
  • 画像をアップロードしてシームレスにLaTeXに変換
  • 論文の執筆とフォーマットに即座にサポートを取得