Answer
See proof
Work Step by Step
We are given the function:
$f(x)=\begin{cases}
1,\text{ for }x \text{ rational}\\
-1,\text{ for }x \text{ irrational}
\end{cases}$
Determine $[f(x)]^2$:
$[f(x)]^2=\begin{cases}
1^2,\text{ for }x \text{ rational}\\
(-1)^2,\text{ for }x \text{ irrational}
\end{cases}$
$[f(x)]^2=\begin{cases}
1,\text{ for }x \text{ rational}\\
1,\text{ for }x \text{ irrational}
\end{cases}$
Let $x_0$ be a rational number. There are infinitely many irrational numbers to the left and to the right of $x_0$, so $f^(x)$ is continuous in $x_0$.
The function takes the same value for rational and irrational numbers.
Therefore $f^2(x)$ is continuous on $\mathbb{R}$.