Union of metric spaces Is the union of two metric spaces a metric space?
I tried it but could't define a suitable metric on intersection. Can somebody help me to understand it?
 A: Daniel Wainfleet's definition of $d_3$ needs the assumption that $2$ is an upper bound of $d_1$ and $d_2$, otherwise the function $d_3$ will not be a metric (except for the case when some of the sets $X_1$ and $X_2$ is empty). Indeed, suppose for instance that $d_1(x_1,x_1')>2$ for some $x_1,x_1'\in X_1$, and take some $x_2\in X_2$. Then $d_3(x_1,x_1')>d_3(x_1,x_2)+d_3(x_2,x_1')$.
The assumptions $X_1\cap X_2=\varnothing$, $X_1\ne\varnothing$, $X_2\ne\varnothing$ on the metric spaces $(X_1,d_1)$ and $(X_2,d_2)$ are sufficient for proceeding in the following way. We take some $a_1$ in $X_1$ and some $a_2$ in $X_2$, and we define $d:(X_1\cup X_2)^2\to\mathbb{R}$ by setting
$$d(x_1,x_2)=d(x_2,x_1)=\max(d_1(x_1,a_1),d_2(x_2,a_2),1)$$
when $x_1\in X_1$, $x_2\in X_2$, and $d(x,y)=d_i(x,y)$ when $x,y\in X_i$ ($i=1,2$). Then $d$ is always a metric. To show that $d(x,y)\le d(x,z)+d(z,y)$ for all $x,y,z\in X_1\cup X_2$, we consider separately two cases:
(i) $x$ and $y$ belong to one and same of the sets $X_1$ and $X_2$;
(ii) $x\in X_1$, $y\in X_2$ or $x\in X_2$, $y\in X_1$.
Suppose we have the case (i), and let for instance $x,y\in X_1$. The case $z\in X_1$ is trivial, therefore suppose $z\in X_2$. We have then to show that
$$d_1(x,y)\le\max(d_1(x,a_1),d_2(z,a_2),1)+\max(d_1(y,a_1),d_2(z,a_2),1).$$
and, of course, this inequality follows from the fact that
$$d_1(x,y)\le d_1(x,a_1)+d_1(y,a_1).$$
Suppose now we have the case (ii), and let for instance $x\in X_1$, $y\in X_2$, $z\in X_2$. We have then to show that
$$\max(d_1(x,a_1),d_2(y,a_2),1)\le\max(d_1(x,a_1),d_2(z,a_2),1)+d_2(z,y).$$
Clearly this inequality follows from the inequality
$$d_2(y,a_2)\le d_2(z,a_2)+d_2(z,y)$$
because $d_1(x,a_1)$ and $1$ obviously do not exceed the right-hand side.
A: (1). If $(X_1,d_1), (X_2,d_2)$ are metric spaces and $X_1\cap X_2=\emptyset$ we can define a metric $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.$ Then the subspace topologies on $X_1$ and $X_2,$ as subspaces of $X_1\cup X_2,$ co-incide with their topologies induced by $d_1$ and $d_2.$
(2). If $X_1\cap X_2 \ne \emptyset$ this may not be possible. Example: For $j\in \{1,2\}$ let $$X_j=(\mathbb Q\times \{0\})\cup ((\mathbb R \backslash \mathbb Q)\times \{j\}), $$ and let $d_j((x,u),(y,v))=|x-y|$ for $(x,u),(y,v)\in X_j.$ Note that each $X_j$ is an isometric copy of $\mathbb R.$
Suppose $T$ is a topology on $X_1\cup X_2$ such that the subspace topologies on $X_1$ and $X_2$ are generated by the metrics $d_1,d_2.$ 
Let $(q_n)_{n\in \mathbb N}$ be a  sequence in  $\mathbb Q$ with $\lim_{n\to \infty}|q_n-\sqrt 2|=0.$
Consider any $U_1, U_2\in T$  such that $(\sqrt 2,1)\in U_1$  and $ (\sqrt 2,2)\in U_2.$
For $j\in \{1,2\}$ the set $U_j\cap X_j$ is a nbhd of $(\sqrt 2,j)$ in the space $X_j,$ and  $\lim_{n\to \infty}d_j((\sqrt 2,j)(q_n,0))=\lim_{n\to \infty}|\sqrt 2 -q_n|=0.$
Therefore, for $j\in \{1,2\}$ the set $\{n\in \mathbb N: (q_n,0)\not \in U_j\cap X_j\}$ is finite, so $\{n\in \mathbb N:q_n \not \in U_j\}$ is finite. So $q_n\in U_1\cap U_2$ for all but finitely many $n\in \mathbb N.$
So it is not possible that $U_1\cap U_2=\emptyset.$ So the points $(\sqrt 2,1) ,(\sqrt 2,2)$ do not have disjoint nbhds in $X_1\cup X_2.$ So the topology $T$ on $X_1\cup X_2$ is not Haudorff, and cannot be generated by a metric. 
Remark: There does exist a non-Hausdorff topology $T$ on $X_1\cup X_2$ such that the subspace topologies on $X_1$ and $X_2$, as subspaces of $X_1\cup X_2,$ are generated by the metrics $d_1,d_2.$ 
A: This might be cheating, but you can equip any set $Z$ with the discrete metric
$$d: Z \times Z \to \mathbb{R}^+$$ 
which is defined by $d(x,y) =0$ if $x=y$ and $d(x,y) =1$ if $x \neq y$ and the set $Z$  will become a metric space.
A: Since you are explicitly considering overlapping underlying sets, you have to explicitly specify what you want for the intersection. The problem is that if you have arbitrary metrics, then for $x,y\in X_1\cap X_2$ you may have $d_1(x,y)\ne d_2(x,y)$.
Note that I'm consistently assuming non-empty intersection in this post. If the intersection is empty, the answer by Dimiter Skordev gives a viable metric.
Now one way to proceed is to demand that the metrics are compatible, that is to demand that for points in the intersection the two metrics actually agree. In that case, it is easy to build a common metric:
$$d(x,y) = \begin{cases}
d_1(x,y) & x,y\in X_1\\
d_2(x,y) & x,y\in X_2\\
\inf\limits_{a\in X_1\cap X_2} d_1(x,a)+d_2(a,y) & x\in X_1, y\in X_2\\
\inf\limits_{a\in X_1\cap X_2} d_2(x,a)+d_1(a,y) & x\in X_2, y\in X_1
\end{cases}$$
If the metrics are not compatible in that way, you have to specify what you want to preserve from the new metric. One possibility would be that the new metric should be upper-bounded by each of the given metrics. This can be ensured by the following construction:
Let's define a “hopping path” $H$ from $a$ to $b$ as finite sequence $(x_0,x_1,\ldots,x_n)$ with the following properties:


*

*$x_0=x$, $x_n=y$.

*$x_k$ and $x_{k+1}$ are both in $X_1$ or both in $X_2$.
Now we can define the “hop distance” $h$ between two subsequent points as follows (note that this is not yet the metric!):
$$h(x_k,x_{k+1}) = \begin{cases}
\min\{d_1(x_k,x_{k+1}),d_2(x_k,x_{k+1})\} & x_1,x_2\in X_1\cap X_2\\
d_1(x_k,x_{k+1}) & \text{one of the points is only in $X_1$}\\
d_2(x_k,x_{k+1} & \text{one of the points is only in $X_2$}
\end{cases}$$
We then define the “hopping length” of a hopping path as the sum of its hopping distances:
$$l(H) = \sum_{k=0}^{n-1} h(x_k,x_{k+1})$$
Now we can define the metric $d(a,b)$ as the infimum of the hopping lengths of all hopping paths from $a$ to $b$.
