TITLE: If $f,g$ are continuous functions, then $fg$ is continuous?
QUESTION [8 upvotes]: Let $X$ be a topological space and let $f:X \to \mathbb{R}$ ,$g:X \to \mathbb{R}$ be continuous functions. Show that $fg$ is continuous.
My work:
To show $fg$ is continuous at $x$ for each $x \in X$, let $y=fg(x)$.
To show if $N_y$ is a neighborhood of $y$, then the pre-image of $y$ is a neighborhood of $x$.
I know that there exists $B_\epsilon(y) \in N_y$ so I want to show that $（fg）^{-1}(B_\epsilon(y)) \in N(x)$
Let $N_x=（fg）^{-1}(B_\epsilon(y))$, I want to find an open set in $N_x$.
Can anyone give me a hint of how to choose such open set or idea how to prove this ?

REPLY [7 votes]: Here is an alternative approach:
Claim 1. If $f: X\to\mathbb{R}$ and $g: X\to\mathbb{R}$ are continuous, then $f+g: X\to\mathbb{R}$ is continuous.
Proof. Given a point $x\in X$ and $\epsilon>0$, we want to show that there exists a neighbourhood $N_{x}$ of $x$ such that $(f+g)(N_{x})\subseteq B_{\epsilon}((f+g)(x))$. By continuity of $f$ and $g$, you can find a neighbourhoods $N'_{x}$ and $N''_{x}$ such that $f(N'_{x})\subseteq B_{\epsilon/2}(f(x))$ and $f(N''_{x})\subseteq B_{\epsilon/2}(g(x))$. Now let $N_{x} := N'_{x} \cap N''_{x}$. Then for each $z\in N_{x}$ we have $$|(f+g)(z)-(f+g)(x)| = |f(z)-f(x)+g(z)-g(x)|\leq |f(z)-f(x)|+|g(z)-g(x)| < \frac{\epsilon}{2}+\frac{\epsilon}{2}=\epsilon$$ so that $(f+g)(z)\in B_{\epsilon}((f+g)(x))$. So $f+g$ is continuous.
Claim 2. If $f:X\to\mathbb{R}$ is continuous, then $f^2: X\to\mathbb{R}$ is continuous.
Here $f^2$ is the function defined by $f^2(x):=(f(x))^2$. 
Proof. Given a point $x\in X$, let $\epsilon>0$. Let's assume $\epsilon<1$ for simplicity (this is okay to assume). By continuity of $f$, there exists a neighbourhood $N_{x}$ such that $f(N_{x})\subseteq B_{\epsilon}(f(x))$. Note that for every $z\in N_{x}$, we have $$|f(z)+f(x)|=|f(z)-f(x)+2 f(x)| \leq |f(z)-f(x)|+2|f(x)| \leq \epsilon+2|f(x)| < 1+2|f(x)| = C
$$
where $C$ was defined to be that constant $1+2|f(x)|$. Note that $C$ is independent of $z$, and only depends on $x$. Next, for every $z\in N_{x}$, we have
$$|f^2(z)-f^2(x)| = |f(z)-f(x)|\cdot |f(z)+f(x)| \leq \epsilon\cdot C$$ 
Thus, $f^2(N_{x})\subseteq B_{\epsilon}(f^2(x))$ and $f^2$ is continuous.
Claim 3. If $f:X\to\mathbb{R}$ and $g:X\to\mathbb{R}$ are continuous, then $f\cdot g: X\to\mathbb{R}$ is continuous.
Proof. Notice that
$$
f\cdot g = \frac{1}{2}\left[(f+g)^2 -f^2-g^2\right]
$$
Now apply claim $1$ to see $f+g$ is continuous. So by Claim 2, all three functions $f^2$, $g^2$ and $(f+g)^2$ are continuous. By Claim $1$ again, $f\cdot g$ is continuous (because it is a sum/difference of these functions).