Can a cube of discontinuous function be continuous?

Can a cube (meaning $g(x) = f(x)^3 = f(x) \cdot f(x) \cdot f(x)$) of discontinuous function $f: D \to \mathbb{R}$ ($D$ is subset of $\mathbb{R}$) be continuous? I think it can't, since $x^3$ is injective, but I am not able to prove it or find a counterexample.


Solution 1:

Since $\phi : \mathbb{R} \to \mathbb{R}, \phi(x) = x^3$, is a homeomorphism, you see that $f$ is continuous iff $\phi \circ f$ is continuous.

Solution 2:

If a function $f(x)$ is continuous, then its cube root $g(x) = f(x)^{1/3}$ is also continuous.

So the contrapositive is also true, which is:

If a function $g(x)$ is not continuous, then its cube $f(x) = g(x)^3$ is not continuous either.

(Strictly speaking, the contrapositive is actually "if the cube root $f(x)^{1/3}$ of a function $f(x)$ is not continuous, then the function $f(x)$ is not continuous either". But this is equivalent.)