jason1996 wrote:

Question: Is this true for topological (not necessarily metric) spaces? If yes prove it, if not find a counterexample.

Hello jason1996,

well the answer to your question is yes

**under one condition**. $f$ must be defined on either

**closed** or

**open** subsets of the topological space. Try looking up for the

*final topology*.

A little bit general result is the following:

Let $X$ be a topological space and $A_1$ and $A_2$ be subspaces of $X$. Let $g_{i}:A_i\rightarrow Y$ be continous for $i=1,2$. If $g_1$ and $g_2$ coincide on $A_1\cap A_2$ and $A_1$ and $A_2$ are either both open or both closed, then the function $f:X\rightarrow Y$ defined by $f(x)=g_1(x)$ if $x \in A_1$ and $f(x)=g_2(x)$ otherwise is continuous.

Assume that $g_1$ and $g_2$ are given continuous functions that satisfy the hypothesis and $A_1$ and $A_2$ are both open (respectively closed). Let $U$ be an open set (respectively closed set) of $Y$. Then,

$$f^{-1}[U] = g_1^{-1}[U]\cup g_2^{-1}[U]$$ which is a binary union of open (respectively closed) sets in $X$, hence open (closed) by continuity of $g_i$ ($i=1,2$). Hence $f$ is continuous.