Is this function continuous?

Let $Y=\oplus_{i \in N}Y_i$ and $Y_i$ is the metriable space $[0,1]$ for each $i \in N$. $x_n \in Y$ denotes that $x_n \in Y_n$ and $0\le x_n \le 1$. $d$ is the usual metric on $[0,1]$. We define a function $f$ from $Y^2$ to $[0,1]$ as following:

$f(x_n,y_m)=d(x_n,y_m)$, if $n=m$; otherwise, $f(x_n,y_m)=\frac{1}{n}+\frac{1}{m}$.

Is this function $f$ continuous? And how to prove it?

-
Which metric you defined on $Y$ and $Y^2$ –  Norbert Dec 22 '11 at 7:13
I guess that you are considering the usual topology on $\mathbb{R}$. But for $Y^{2}$ there are a lot of topology we could consider. So what topology in $Y^2$ you want to consider ? –  Leandro Dec 22 '11 at 7:17
The topology on $Y$ is generated by the sum of $Y_i$. The topology on $Y^2$ is the Tychonoff topology, i.e., the topology is generated by the Cartesian product of the space $Y$. –  Paul Dec 22 '11 at 8:11

Since Y is metrizable, you can also prove it via convergent sequences.

For notational convenience I’ll write $Y=\omega\times[0,1]$. A sequence $\left\langle\langle n_k,x_k\rangle:n\in\omega \right\rangle$ in $Y$ converges to $\langle n,x\rangle$ iff $\langle x_k:k\in\omega\rangle\to x$ in $[0,1]$ and $n_k=n$ for all sufficiently large $k$, so a sequence $$\Big\langle\big\langle\langle n_k,x_k\rangle,\langle m_k,y_k\rangle\big\rangle:k\in\omega\Big\rangle$$ converges to $\big\langle\langle n,x\rangle,\langle m,y\rangle\big\rangle$ in $Y^2$ iff $\langle x_k:k\in\omega\rangle\to x$ in $[0,1]$, $\langle y_k:k\in\omega\rangle\to y$ in $[0,1]$, and $n_k=n$ and $m_k=m$ for all sufficiently large $k$. If $n\ne m$, the sequence $$\Big\langle f\big(\langle n_k,x_k\rangle,\langle m_k,y_k\rangle\big):k\in\omega\Big\rangle$$ is eventually constant with value $\frac1n+\frac1m$, and if $n=m$ it’s eventually just the sequence of $|x_k-y_k|$, which certainly converges to $|x-y|$. Thus, $f$ preserves convergent sequences and is therefore continuous.

-
The connected components of $Y^2$ are of the form $Y_i \times Y_j$. All of these components are (closed and) open, so they form an open cover of $Y^2$. Since the restriction of $f$ to each component in the cover is continuous, $f$ itself is also continuous.
To prove this from first principles, consider what the preimage $U$ of an open subset $V$ of $[0,1]$ under $f$ must look like. (Specifically, consider the intersection of $U$ with each of the connected components mentioned above. You'll find that they're all open, meaning that $U$ is a union of open sets, and thus open.)
Indeed, the important thing is actually that, since $Y^2$ is locally connected, the connected components form an open cover. On a space with non-open connected components a different approach would be needed. –  Ilmari Karonen Dec 22 '11 at 9:29
@ Ilmari Karonen，do you mean that the function $f$ is continuous? It seems a little complex for me. –  Paul Dec 22 '11 at 9:56
@John: Yes, unless I've made some silly mistake, $f$ is continuous. You may want to tweak the definition of $f$ so that its values actually lie in $[0,1]$, though (or extend its codomain to all of $\mathbb R$, or at least to $[0, 1.5]$). –  Ilmari Karonen Dec 22 '11 at 11:00