For a vector \(\mathbf{x} = [x_1, x_2, ..., x_n]^T\) in \(\mathbb{R}^n\), the L₂ norm, denoted \(||\mathbf{x}||_2\) or often just \(||\mathbf{x}||\) (when the context is clear), is defined as:
$$ ||\mathbf{x}||2 = \sqrt{\sum $$}^n x_i^2} = \sqrt{x_1^2 + x_2^2 + \dots + x_n^2
It is a specific case of the Lₚ norm family where \(p=2\).
\(||\mathbf{x}||_2\) represents the straight-line distance from the origin \(\mathbf{0}=(0, ..., 0)\) to the point defined by the vector \(\mathbf{x}\) in Euclidean space.
The Euclidean distance between two vectors \(\mathbf{x}\) and \(\mathbf{y}\) is given by \(||\mathbf{x} - \mathbf{y}||_2\).
The set of all vectors with \(||\mathbf{x}||_2 = 1\) (the "unit ball") forms a circle in 2D, a sphere in 3D, and a hypersphere in higher dimensions.
(Visual Idea: An Excalidraw showing the L₂ unit circle vs the L₁ unit diamond).
The L₂ norm squared is equal to the dot product of the vector with itself:
$$ ||\mathbf{x}||_2^2 = x_1^2 + \dots + x_n^2 = \mathbf{x} \cdot \mathbf{x} = \mathbf{x}^T \mathbf{x} $$
Distance Calculation: The fundamental measure of distance in Euclidean geometry and many algorithms (e.g., k-Nearest Neighbors).
Ridge Regression (L2 Regularization): Adds a penalty term proportional to the squared L₂ norm of the model's weight vector (\(\lambda ||\mathbf{w}||_2^2\)) to the loss function. (Note: Using the squared L₂ norm \(||\mathbf{w}||_2^2 = \mathbf{w}^T\mathbf{w}\) is common for mathematical convenience in differentiation, but it has a similar effect to penalizing the L₂ norm itself).
Effect of L2 Regularization: Shrinks weights towards zero but rarely makes them exactly zero (unlike L1). Helps prevent overfitting by discouraging overly large weights. Solutions tend to be distributed within the L₂ "ball" (circle/sphere), generally not hitting axes.
Loss Functions (MSE): The Mean Squared Error (MSE) loss function is based on the squared L₂ norm of the error vector between predictions and actual values: \(MSE = \frac{1}{n} ||\mathbf{y}_{\text{pred}} - \mathbf{y}_{\text{actual}}||_2^2\).
Vector Magnitude: Standard way to measure the magnitude or length of vectors in physics and engineering.