# is there a function f from the reals to the reals which is not continuous,but has a continous square?

Apr 17, 2017

$f \left(x\right) = \left\{\begin{matrix}- 1 & x < 0 \\ 1 & x \ge 0\end{matrix}\right.$

#### Explanation:

Consider the following function

$f \left(x\right) = \left\{\begin{matrix}- 1 & x < 0 \\ 1 & x \ge 0\end{matrix}\right.$

This has a discontinuity when $x = 0$

However ${f}^{2}$ is continuous:

${f}^{2} \left(x\right) = \left\{\begin{matrix}{\left(- 1\right)}^{2} & x < 0 \\ {1}^{2} & x \ge 0\end{matrix}\right. = 1$

Apr 17, 2017

Yes, because $\sqrt{{y}^{2}} = \left\mid y \right\mid$ which is not always $y$.

#### Explanation:

$f \left(x\right) = \left\{\begin{matrix}x & \text{if" & x != 5 \\ -5 & "if} & x = 5\end{matrix}\right.$

$f$ is not continuous at $5$, but

${\left(f \left(x\right)\right)}^{2} = {x}^{2}$ is continuous for all $x$.

Apr 17, 2017

There's more!

#### Explanation:

In fact, there is a family of functions $f$ which are never continuous in any point, and their square is continuous: they are called the Dirichlet functions: fix $n > 0$ an integer, then:

$f \left(x\right) = {x}^{n}$ if $x$ is rational, $- {x}^{n}$ if $x$ is irrational.

Are the required functions. Their square is always ${x}^{2 n}$, which is continuous, but $f$ is never continuous.