# Disjoint Union of Metric Spaces is a Metric Space

Let $(X_1,d_1), (X_2,d_2)$ be metric spaces and $X_1\cap X_2=\emptyset$. Define $d_3$ on $X_1\cup X_2$ by $d_3(x_1,x_2)=1$ when $x_1\in X_1 ,x_2\in X_2,$ and $d_3(x,y)=d_1(x,y)$ when $x,y\in X_1,$ and $d_3(x,y)=d_2(x,y)$ when $x,y\in X_2.$ Prove that $d_3$ is a metric on $X_1 \cup X_2$.

We must show $d_3(x,z) \leq d_3(x,y) + d_3(y,z)$ $\forall x,y,z \in X_1 \cup X_2$. Any help would be much appreciated.

EDIT: I should clarify that we should assume $d_1$ and $d_2$ are metrics that produce real numbers less than 1.

• What happens in the triangle inequality if $x, z\in X_1$ and $y\in X_2$? Sep 29 '17 at 18:11
• Well, have you tried just writing out all the cases based on which of $X_1$ and $X_2$ your points are in? Sep 29 '17 at 20:04
• I suppose that's the best way to go about this. Thank you, Eric. Sep 29 '17 at 20:15

The inequality is valid when either $x,y,z\in X_1$ or $x,y,z\in X_2$. So we need to prove it when one point is in $X_1$ and two are in $X_2$ (the same applies when two points are in $X_1$ and one in $X_2$).
Suppose $x,z\in X_1$ and $y\in X_2$. Then $$d_3(x,z)\le 1<d_3(x,y)+d_3(y,z)=2$$ Suppose $x,y\in X_1$ and $z\in X_2$. Then $$d_3(x,z)=1\le d_3(x,y)+d_3(y,z)=d_1(x,y)+1$$ Suppose $y,z\in X_1$ and $x\in X_2$. Then $$d_3(x,z)=1\le d_3(x,y)+d_3(y,z)=1+d_1(y,z)$$