Q: Suppose $X$ is a metric space and $A,B\subset X$; given continuous maps $f\colon A\to\Bbb R$ and $g\colon B\to\Bbb R$ which agree (ie, are equal) on $A\cap B$, prove that the piecewise union $h$ of $f$ and $g$ defined by $h(x)=f(x)$ when $x\in A$ and $h(x)=g(x)$ when $x\in B$ is continuous on $A\cup B$
Attempt:
Since $h\equiv f$ on $(A\cup B)\setminus B$ and $h\equiv g$ on $(A\cup B)\setminus A$, by continuity of $f$ and $g$, we conclude continuity of $h$ on $A\triangle B$. It remains to show continuity on $A\cap B$
Since $f(x)=g(x)$ on $A\cap B$, we can see $h$ as the restriction of $f$ (or $g$) on $A\cap B$ and we conclude since the restriction of a continuous map is continuous.
I feel like this proof might seem informal (read: not too rigorous). Is there any improvement I can make in the proof? Thanks!
You either need to assume $A$ and $B$ are both open or both closed. Then it is a standard glueing lemma. For other $A$ and $B$ things can go wrong.