Tutorials › Linear Algebra › Distances From Inner Product Norms

Inner Products and Norms · Tutorial 618 of 1000

Distances From Inner Product Norms

Use the norm of a difference to define distance, compute it in several inner product spaces, and prove its basic properties.

Intermediate 9 min read

What You'll Learn

  • Define distance between vectors using an inner-product-induced norm
  • Expand squared distances using the inner product
  • Compute distances in Euclidean and weighted coordinate spaces
  • Find Frobenius distances between matrices
  • Calculate integral distances between continuous functions on a valid interval
  • Verify the metric properties and distinguish distance from a difference of norms

From Norm to Distance

A norm measures the size of one vector, while a distance compares two vectors. The connection is direct: subtract one vector from the other, then measure the resulting vector with the norm. This definition works in coordinate spaces, matrix spaces, and function spaces, provided the norm comes from an inner product. The calculation may look different in each setting, but the same principle applies.

Let \(V\) be a vector space over \(\mathbb{F}\), where \(\mathbb{F}=\mathbb{R}\) or \(\mathbb{C}\), equipped with an inner product and its induced norm \(\|\mathbf{x}\|=\sqrt{\langle\mathbf{x},\mathbf{x}\rangle}\). The norm is nonnegative, equals zero only for the zero vector, is absolutely homogeneous, and satisfies the triangle inequality. These properties were established for inner-product-induced norms earlier in the material on norms.

Definition: The distance between \(\mathbf{x},\mathbf{y}\in V\) is \(d(\mathbf{x},\mathbf{y})=\|\mathbf{x}-\mathbf{y}\|\). In particular, \(d(\mathbf{x},\mathbf{0})=\|\mathbf{x}\|\). Thus, distance is a norm applied to the difference, not a difference of two norms.

Subtraction matters: \(\mathbf{x}-\mathbf{y}\) is the vector that points from \(\mathbf{y}\) to \(\mathbf{x}\), and its norm is nonnegative regardless of which vector comes first. In coordinate examples, the vectors are columns. In other spaces, the same definition uses the subtraction operation and norm appropriate to that space.

Basic Properties of Inner-Product Distance

A distance function on \(V\) is a metric if it is nonnegative, is zero exactly when its inputs are equal, is symmetric, and satisfies the triangle inequality. The norm properties give all four facts for the distance just defined.

Theorem: For an inner product space \(V\), \(d(\mathbf{x},\mathbf{y})=\|\mathbf{x}-\mathbf{y}\|\) is a metric. In addition, for all \(\mathbf{x},\mathbf{y},\mathbf{z}\in V\) and all \(c\in\mathbb{F}\), \(d(\mathbf{x}+\mathbf{z},\mathbf{y}+\mathbf{z})=d(\mathbf{x},\mathbf{y})\) and \(d(c\mathbf{x},c\mathbf{y})=|c|d(\mathbf{x},\mathbf{y})\).

Proof. Since norms are nonnegative, \(d(\mathbf{x},\mathbf{y})=\|\mathbf{x}-\mathbf{y}\|\geq 0\). By the definiteness of the norm, \(d(\mathbf{x},\mathbf{y})=0\) exactly when \(\mathbf{x}-\mathbf{y}=\mathbf{0}\), which is equivalent to \(\mathbf{x}=\mathbf{y}\). Also, \(\mathbf{y}-\mathbf{x}=-(\mathbf{x}-\mathbf{y})\), so absolute homogeneity of the norm gives \(d(\mathbf{y},\mathbf{x})=\|-(\mathbf{x}-\mathbf{y})\|=d(\mathbf{x},\mathbf{y})\). For the triangle inequality, write \(\mathbf{x}-\mathbf{z}=(\mathbf{x}-\mathbf{y})+(\mathbf{y}-\mathbf{z})\). Then the norm triangle inequality gives \(d(\mathbf{x},\mathbf{z})\leq d(\mathbf{x},\mathbf{y})+d(\mathbf{y},\mathbf{z})\). For translation, \((\mathbf{x}+\mathbf{z})-(\mathbf{y}+\mathbf{z})=\mathbf{x}-\mathbf{y}\), so the distances are equal. For scaling, \(c\mathbf{x}-c\mathbf{y}=c(\mathbf{x}-\mathbf{y})\), and absolute homogeneity gives \(d(c\mathbf{x},c\mathbf{y})=|c|\|\mathbf{x}-\mathbf{y}\|=|c|d(\mathbf{x},\mathbf{y})\). These arguments also apply when \(c=0\), since both sides are then zero. \(\square\)

The translation property says that moving both vectors by the same vector leaves their separation unchanged. Scaling both vectors by \(c\) scales the distance by \(|c|\). If \(c=0\), the two scaled vectors coincide, so their distance is zero, as the formula states.

Squared Distance and the Inner Product

Sometimes it is convenient to compute the square of a distance first. With the course convention that a complex inner product is linear in its first slot and conjugate-linear in its second, expanding the inner product gives the following identity.

Identity: For \(\mathbf{x},\mathbf{y}\) in an inner product space over \(\mathbb{F}\), \(\|\mathbf{x}-\mathbf{y}\|^2=\|\mathbf{x}\|^2+\|\mathbf{y}\|^2-2\operatorname{Re}\langle\mathbf{x},\mathbf{y}\rangle\). For a real inner product space, \(\operatorname{Re}\langle\mathbf{x},\mathbf{y}\rangle=\langle\mathbf{x},\mathbf{y}\rangle\).

Proof. By the definition of the induced norm and additivity in each slot, \(\|\mathbf{x}-\mathbf{y}\|^2=\langle\mathbf{x}-\mathbf{y},\mathbf{x}-\mathbf{y}\rangle=\langle\mathbf{x},\mathbf{x}\rangle-\langle\mathbf{x},\mathbf{y}\rangle-\langle\mathbf{y},\mathbf{x}\rangle+\langle\mathbf{y},\mathbf{y}\rangle\). The diagonal terms are \(\|\mathbf{x}\|^2\) and \(\|\mathbf{y}\|^2\). Conjugate symmetry gives \(\langle\mathbf{y},\mathbf{x}\rangle=\overline{\langle\mathbf{x},\mathbf{y}\rangle}\), so the two cross terms sum to \(2\operatorname{Re}\langle\mathbf{x},\mathbf{y}\rangle\). Substituting yields the identity. \(\square\)

In real coordinate spaces, it is often simplest to subtract the vectors first and sum the squares of the resulting entries. The identity can instead be useful when the inner products and norms of the original vectors are already known. In either approach, the squared distance must be nonnegative, and the distance itself is the nonnegative square root.

Euclidean and Weighted Coordinate Distances

Worked Example: Euclidean Distance in \(\mathbb{R}^3\)

Find the distance between \(\mathbf{u}=(1,-2,2)^{\top}\) and \(\mathbf{v}=(4,0,-1)^{\top}\) using the standard inner product on \(\mathbb{R}^3\), \(\langle\mathbf{x},\mathbf{y}\rangle=\mathbf{x}^{\top}\mathbf{y}\).

Subtract the columns coordinate by coordinate:

$$ \mathbf{u}-\mathbf{v} = \begin{bmatrix}1\\-2\\2\end{bmatrix} - \begin{bmatrix}4\\0\\-1\end{bmatrix} = \begin{bmatrix}-3\\-2\\3\end{bmatrix}. $$

The induced Euclidean norm gives

$$ d(\mathbf{u},\mathbf{v}) =\|\mathbf{u}-\mathbf{v}\| =\sqrt{(-3)^2+(-2)^2+3^2} =\sqrt{9+4+9} =\sqrt{22}. $$

Check: The squared norm of the difference is \((-3)^2+(-2)^2+3^2=22\), so squaring the proposed distance \(\sqrt{22}\) returns \(22\), as required.

A weighted inner product assigns different positive weights to different coordinates. For example, with positive real numbers \(w_1,\dots,w_n\), the formula \(\langle\mathbf{x},\mathbf{y}\rangle_w=\sum_{i=1}^n w_i x_i y_i\) defines an inner product on \(\mathbb{R}^n\). Its induced squared distance is \(\sum_{i=1}^n w_i(x_i-y_i)^2\). Positivity of every weight matters: if a weight were zero, a nonzero vector supported only in that coordinate would have norm zero.

Worked Example: A Weighted Distance

On \(\mathbb{R}^3\), use weights \(1,2,3\). Find the distance between \(\mathbf{x}=(1,0,2)^{\top}\) and \(\mathbf{y}=(0,2,1)^{\top}\). The weighted squared norm of \((z_1,z_2,z_3)^{\top}\) is \(z_1^2+2z_2^2+3z_3^2\).

The difference is \(\mathbf{x}-\mathbf{y}=(1,-2,1)^{\top}\), so

$$ d(\mathbf{x},\mathbf{y})^2 =1(1)^2+2(-2)^2+3(1)^2 =1+8+3 =12. $$

Therefore \(d(\mathbf{x},\mathbf{y})=\sqrt{12}=2\sqrt{3}\). Check: \((2\sqrt{3})^2=12\), which agrees with the weighted sum of squared coordinate differences. The middle coordinate contributes \(8\), rather than \(4\), because its weight is \(2\).

Distances Between Matrices

For real \(m\times n\) matrices, the Frobenius inner product is the sum of the products of corresponding entries: \(\langle\mathbf{X},\mathbf{Y}\rangle_F=\sum_{i=1}^m\sum_{j=1}^n x_{ij}y_{ij}\). Its induced norm is the Frobenius norm, \(\|\mathbf{X}\|_F=\sqrt{\sum_{i,j}x_{ij}^2}\). Consequently, the Frobenius distance is the square root of the sum of the squared entrywise differences. The matrices must have the same dimensions so that their difference is defined.

Worked Example: Frobenius Distance

Let \(\mathbf{X}=\begin{bmatrix}1&0\\2&-1\end{bmatrix}\) and \(\mathbf{Y}=\begin{bmatrix}-1&2\\2&2\end{bmatrix}\). Find their Frobenius distance.

Subtract corresponding entries:

$$ \mathbf{X}-\mathbf{Y} = \begin{bmatrix}1-(-1)&0-2\\2-2&-1-2\end{bmatrix} = \begin{bmatrix}2&-2\\0&-3\end{bmatrix}. $$

Then

$$ d(\mathbf{X},\mathbf{Y}) =\|\mathbf{X}-\mathbf{Y}\|_F =\sqrt{2^2+(-2)^2+0^2+(-3)^2} =\sqrt{4+4+0+9} =\sqrt{17}. $$

Check: The squared Frobenius norm of the displayed difference matrix is \(4+4+0+9=17\), so the square of the stated distance is \(17\).

Distances Between Continuous Functions

For real-valued continuous functions on an interval \([a,b]\) with \(a<b\), the integral inner product is \(\langle f,g\rangle=\int_a^b f(t)g(t)\,dt\). The restriction \(a<b\) is essential here. It ensures that a continuous function with zero integral of its square must be identically zero on the interval, making this a positive-definite inner product. The induced distance is

$$ d(f,g)=\|f-g\| =\sqrt{\int_a^b (f(t)-g(t))^2\,dt}. $$

To see why definiteness holds, suppose a continuous function \(h\) is nonzero at some point of \([a,b]\). Continuity then ensures that \(|h|\) is bounded below by some positive number on a small interval around that point, using a one-sided interval if the point is an endpoint. Since \(a<b\), this interval can be chosen to have positive length. Thus \(\int_a^b h(t)^2\,dt>0\). So an integral of zero forces \(h=0\) everywhere on \([a,b]\).

Worked Example: Integral Distance

On the interval \([0,2]\), find the distance between \(f(t)=t\) and \(g(t)=1\) using the integral inner product.

Here \(f(t)-g(t)=t-1\), and the interval satisfies \(0<2\). Therefore

$$ d(f,g)^2 =\int_0^2 (t-1)^2\,dt =\int_0^2 (t^2-2t+1)\,dt =\left[\frac{t^3}{3}-t^2+t\right]_0^2 =\left(\frac{8}{3}-4+2\right)-0 =\frac{2}{3}. $$

Taking the nonnegative square root gives \(d(f,g)=\sqrt{\frac{2}{3}}\). Check: Substituting the functions into the defining formula gives \(\int_0^2(t-1)^2\,dt=\frac{2}{3}\), exactly the square of the stated distance.

Common Pitfall: Subtracting the Norms

A common error is to compute \(\big|\|\mathbf{x}\|-\|\mathbf{y}\|\big|\) and call it the distance. That quantity can be a lower bound for distance, but it is generally not the distance itself. For a concrete example in \(\mathbb{R}^2\), take \(\mathbf{x}=(3,0)^{\top}\) and \(\mathbf{y}=(0,4)^{\top}\). The incorrect calculation gives \(|3-4|=1\). The correct calculation is

$$ d(\mathbf{x},\mathbf{y}) =\left\|\begin{bmatrix}3\\0\end{bmatrix} -\begin{bmatrix}0\\4\end{bmatrix}\right\| =\left\|\begin{bmatrix}3\\-4\end{bmatrix}\right\| =\sqrt{3^2+(-4)^2} =5. $$

The correction is to subtract the vectors first and then take the norm. The two answers differ because the norm of the difference depends on the vectors themselves, not only on their separate lengths.

The same definition covers each setting in this tutorial: subtract the two objects in their space, use that space’s inner-product norm, and take the nonnegative result. In weighted coordinates, the weights affect the calculation; for matrices, each entry contributes; for functions, the squared difference is integrated over an interval with \(a<b\). In each case, equality of the two objects is exactly the condition for distance zero.

Check Your Understanding

For each question, apply the definition to the difference of the two objects and check the squared distance against the relevant norm formula.

  1. Find the Euclidean distance between \((2,1)^{\top}\) and \((-1,5)^{\top}\).
  2. With coordinate weights \(2\) and \(1\), find the distance between \((1,3)^{\top}\) and \((4,1)^{\top}\).
  3. Find the Frobenius distance between \(\begin{bmatrix}1&-1\end{bmatrix}\) and \(\begin{bmatrix}3&2\end{bmatrix}\).
  4. On \([0,1]\), find the integral distance between \(f(t)=t\) and \(g(t)=0\).
  5. Explain why \(\big|\|\mathbf{x}\|-\|\mathbf{y}\|\big|\) is not, in general, the definition of the distance between \(\mathbf{x}\) and \(\mathbf{y}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon