Tutorials › Topology (Undergraduate) › Weighted Euclidean Metrics

Metric Spaces and Open Balls · Tutorial 40 of 799

Weighted Euclidean Metrics

Learn how positive coordinate weights define a Euclidean-type metric, how to verify its axioms, and how to compare distances obtained from different weights.

Beginner 10 min read

What You'll Learn

  • Define weighted Euclidean distance on \(\mathbb{R}^n\) using positive coordinate weights
  • Verify nonnegativity, identity of indiscernibles, symmetry, and the triangle inequality
  • Compute weighted distances exactly and check them using scaled coordinates
  • Compare weighted distance with ordinary Euclidean distance using the smallest and largest weights
  • Determine how changing one or more weights affects distances
  • Identify why zero or negative weights do not give the required metric

Euclidean Distance with Coordinate Weights

Ordinary Euclidean distance assigns the same role to every coordinate: a change of one unit in the first coordinate contributes just as much as a change of one unit in the second. In some problems, coordinates need not have equal influence. A weighted Euclidean metric incorporates that difference by assigning a positive weight to each coordinate. The points remain the same; it is the rule for measuring their separation that changes.

Throughout, \(n\in\mathbb{N}\), and \(\mathbb{R}^n\) has its usual coordinates and Euclidean distance. Fix positive real numbers \(w_1,\dots,w_n\), called the coordinate weights. For \(x=(x_1,\dots,x_n)\) and \(y=(y_1,\dots,y_n)\), define their weighted distance as follows.

Definition: The weighted Euclidean distance determined by \(w_1,\dots,w_n>0\) is \(d_w(x,y)=\sqrt{\sum_{i=1}^n w_i(x_i-y_i)^2}\). The underlying set is \(\mathbb{R}^n\); changing the weights changes the distance function, not the points in the set.

The weights are coefficients inside the square root. A larger weight makes a fixed change in that coordinate contribute more to the squared distance. Positivity of every weight is essential: it ensures that no nonzero coordinate difference can be ignored.

Why This Formula Is a Metric

Theorem: For \(w_1,\dots,w_n>0\), the function \(d_w\) is a metric on \(\mathbb{R}^n\).

Proof. Define \(D_w:\mathbb{R}^n\to\mathbb{R}^n\) by \(D_w(x_1,\dots,x_n)=(\sqrt{w_1}x_1,\dots,\sqrt{w_n}x_n)\). For all \(x,y\in\mathbb{R}^n\), the ordinary Euclidean distance satisfies \(d_w(x,y)=\|D_w(x)-D_w(y)\|\), because the square of the right-hand side is \(\sum_{i=1}^n(\sqrt{w_i}x_i-\sqrt{w_i}y_i)^2=\sum_{i=1}^n w_i(x_i-y_i)^2\). We verify the metric axioms.

Each term \(w_i(x_i-y_i)^2\) is nonnegative, so \(d_w(x,y)\ge0\). If \(x=y\), every coordinate difference is zero and \(d_w(x,y)=0\). Conversely, if \(d_w(x,y)=0\), then \(\sum_{i=1}^n w_i(x_i-y_i)^2=0\). Every summand is nonnegative, so each must be zero. Since \(w_i>0\), this implies \((x_i-y_i)^2=0\) and hence \(x_i=y_i\) for every \(i\); therefore \(x=y\). Symmetry follows from \((x_i-y_i)^2=(y_i-x_i)^2\) for each coordinate.

For the triangle inequality, let \(x,y,z\in\mathbb{R}^n\). The map \(D_w\) gives \(D_w(x)-D_w(z)=(D_w(x)-D_w(y))+(D_w(y)-D_w(z))\). Applying the triangle inequality for ordinary Euclidean distance to these vectors gives \(\|D_w(x)-D_w(z)\|\le\|D_w(x)-D_w(y)\|+\|D_w(y)-D_w(z)\|\). Replacing each Euclidean distance by its equal weighted-distance expression yields \(d_w(x,z)\le d_w(x,y)+d_w(y,z)\). All four metric axioms hold, so \(d_w\) is a metric. \(\square\)

This proof uses the ordinary Euclidean metric and its triangle inequality. It also shows why the weights must be positive: \(D_w\) scales each coordinate by a positive number, so distinct points remain distinct after scaling.

Calculating and Comparing Weighted Distances

Worked Example: Two Coordinates with Unequal Weights

On \(\mathbb{R}^2\), take weights \(w_1=4\) and \(w_2=1\). Find the weighted distance between \(p=(1,-1)\) and \(q=(4,3)\), and check it by scaling the coordinates.

The coordinate differences are \(4-1=3\) and \(3-(-1)=4\). Substitution into the definition gives \(d_w(p,q)=\sqrt{4(3)^2+1(4)^2}=\sqrt{4\cdot9+1\cdot16}=\sqrt{36+16}=\sqrt{52}=2\sqrt{13}\).

For the check, the scaling map is \(D_w(a,b)=(2a,b)\), since \(\sqrt{4}=2\) and \(\sqrt{1}=1\). Thus \(D_w(p)=(2,-1)\) and \(D_w(q)=(8,3)\). Their difference is \((6,4)\), whose Euclidean length is \(\sqrt{6^2+4^2}=\sqrt{36+16}=\sqrt{52}=2\sqrt{13}\), agreeing with the direct calculation.

The ordinary Euclidean distance between the same points is \(\sqrt{3^2+4^2}=\sqrt{9+16}=5\). The first-coordinate change is given four times the weight in the squared-distance formula, so the weighted distance is larger here.

Worked Example: Changing Which Coordinate Matters More

Compare two metrics on \(\mathbb{R}^2\): \(d_{(1,9)}\), with weights \((1,9)\), and \(d_{(9,1)}\), with weights \((9,1)\). Use the same points \(p=(0,0)\) and \(q=(2,1)\) for both calculations.

The coordinate differences are \(2-0=2\) and \(1-0=1\). With weights \((1,9)\), \(d_{(1,9)}(p,q)=\sqrt{1(2)^2+9(1)^2}=\sqrt{1\cdot4+9\cdot1}=\sqrt{4+9}=\sqrt{13}\).

With weights \((9,1)\), \(d_{(9,1)}(p,q)=\sqrt{9(2)^2+1(1)^2}=\sqrt{9\cdot4+1\cdot1}=\sqrt{36+1}=\sqrt{37}\). The underlying points and their coordinate differences are unchanged. The second metric gives more weight to the first-coordinate difference, which is \(2\), so it produces the larger distance. As a check, \(\sqrt{37}>\sqrt{13}\) because \(37>13\).

The effect of changing weights can be stated precisely. Because \(n\) is finite and each weight is positive, there is a smallest weight \(m=\min\{w_1,\dots,w_n\}>0\) and a largest weight \(M=\max\{w_1,\dots,w_n\}\).

Proposition: For all \(x,y\in\mathbb{R}^n\), \(\sqrt{m}\,\|x-y\|\le d_w(x,y)\le\sqrt{M}\,\|x-y\|\), where \(\|x-y\|\) is ordinary Euclidean distance.

Proof. For every coordinate \(i\), the definitions of \(m\) and \(M\) give \(m\le w_i\le M\). Since \((x_i-y_i)^2\ge0\), multiplication preserves these inequalities: \(m(x_i-y_i)^2\le w_i(x_i-y_i)^2\le M(x_i-y_i)^2\). Summing over \(i=1,\dots,n\) gives \(m\sum_{i=1}^n(x_i-y_i)^2\le\sum_{i=1}^n w_i(x_i-y_i)^2\le M\sum_{i=1}^n(x_i-y_i)^2\). All three quantities are nonnegative, so taking square roots preserves the inequalities. The left and right sums are the squares of \(\sqrt{m}\|x-y\|\) and \(\sqrt{M}\|x-y\|\), and the middle sum is \(d_w(x,y)^2\). This proves the stated bounds. \(\square\)

Worked Example: Checking the Weight Bounds

Take weights \((1/4,4,9)\) on \(\mathbb{R}^3\), and compare the weighted and ordinary distances from \(p=(0,0,0)\) to \(q=(2,-1,1)\).

The coordinate differences are \(2,-1,1\). The weighted distance is \(d_w(p,q)=\sqrt{(1/4)(2)^2+4(-1)^2+9(1)^2}=\sqrt{(1/4)\cdot4+4\cdot1+9\cdot1}=\sqrt{1+4+9}=\sqrt{14}\). The ordinary distance is \(\|p-q\|=\sqrt{2^2+(-1)^2+1^2}=\sqrt{4+1+1}=\sqrt{6}\).

Here \(m=1/4\) and \(M=9\), so the proposition gives \((1/2)\sqrt{6}\le\sqrt{14}\le3\sqrt{6}\). To check both inequalities without decimal approximations, all terms are nonnegative, so we can square them. The left comparison is \(6/4=3/2\le14\), and the right comparison is \(14\le9\cdot6=54\). Both hold.

The same coordinate calculation also gives a useful monotonicity rule. If two positive weight lists \(w_i\) and \(v_i\) satisfy \(w_i\le v_i\) for every \(i\), then \(d_w(x,y)\le d_v(x,y)\) for every pair \(x,y\): multiply each inequality by \((x_i-y_i)^2\), sum, and take nonnegative square roots. For a particular pair, increasing a weight has no effect if the two points agree in that coordinate. If they differ there, increasing that weight strictly increases the squared distance and therefore the distance.

Worked Example: Scaling All Weights

On \(\mathbb{R}^2\), start with weights \((2,3)\), and use points \(p=(0,0)\) and \(q=(1,2)\). Then \(d_{(2,3)}(p,q)=\sqrt{2(1-0)^2+3(2-0)^2}=\sqrt{2\cdot1+3\cdot4}=\sqrt{2+12}=\sqrt{14}\).

Now double both weights, giving \((4,6)\). The points have not changed, and \(d_{(4,6)}(p,q)=\sqrt{4(1)^2+6(2)^2}=\sqrt{4\cdot1+6\cdot4}=\sqrt{4+24}=\sqrt{28}=2\sqrt{7}\). Since \(2\sqrt{7}=\sqrt{4\cdot7}=\sqrt{28}=\sqrt{2}\sqrt{14}\), this agrees with the general calculation: multiplying every weight by a positive constant \(c\) multiplies every distance by \(\sqrt{c}\). Indeed, \(d_{cw}(x,y)=\sqrt{\sum_{i=1}^n cw_i(x_i-y_i)^2}=\sqrt{c}\,d_w(x,y)\). For this example \(c=2\), so the factor is \(\sqrt{2}\).

A Common Pitfall: Zero Weights

It is tempting to allow a coordinate weight to be zero and treat it as a metric weight. That fails the identity-of-indiscernibles axiom: distinct points can then have distance zero. For instance, the formula with weights \((1,0)\) gives, for \(p=(0,0)\) and \(q=(0,5)\), \(\sqrt{1(0-0)^2+0(5-0)^2}=\sqrt{0+0}=0\), although \(p\ne q\). Thus the formula is not a metric for these weights. A negative weight is also inadmissible: the expression under the square root can be negative for some pairs, so it need not define a real-valued distance. Require every coordinate weight to be strictly positive.

Weighted Euclidean metrics are useful when different coordinate changes should have different costs or scales. The definition gives a direct computation, the scaling map explains the triangle inequality, and the comparison bounds quantify how far the weighted distances can differ from ordinary Euclidean distances. In every case, the coordinates still describe the same points of \(\mathbb{R}^n\); only their measured separations have changed.

Check Your Understanding

For each question, use the definition with the stated weights and distinguish the distance rule from the underlying points.

  1. On \(\mathbb{R}^2\) with weights \((1,4)\), compute the distance between \((1,2)\) and \((4,6)\).
  2. For weights \((2,5)\), compare the weighted and ordinary distances between \((0,0)\) and \((1,1)\).
  3. Explain why the transformation \(D_w(x_1,\dots,x_n)=(\sqrt{w_1}x_1,\dots,\sqrt{w_n}x_n)\) is one-to-one when every weight is positive.
  4. If every weight is multiplied by \(9\), by what factor does every distance change? Justify the factor from the formula.
  5. Give two distinct points whose distance is zero under the formula with weights \((3,0)\), and identify the metric axiom that fails.