Composing two discontinuous functions into a continuous one

Please help me think of an example of two discontinuous functions on $\mathbb R$ whose composition gives a continuous function on $\mathbb R$.

-
let $f(X)=\frac{1}{x}$ and $g(X)=\frac{1}{1-x}$ then fog is continuous –  Maisam Hedyelloo Jan 19 '13 at 16:25

Hints for a general process of producing such functions:

1. The identity function $\mathrm{id}:\mathbb{R}\to\mathbb{R}$, defined by $\mathrm{id}(x)=x$, is continuous.

2. Think of two non-trivial functions on $\mathbb{R}$ that, when composed, give the identity.

3. Define $f$ and $g$ to be those functions, except only applied to some subset $S\subset\mathbb{R}$ (for example, the irrationals), defining them to be the identity on $\mathbb{R}\setminus S$.

As long as the functions in step 2 map $S$ to itself, this (usually) produces discontinuous functions with the desired properties.

Some examples:

• Choose the function "multiply by $-1$", apply it to any subset $S$ of $\mathbb{R}$ symmetric about the origin other than $\mathbb{R}$ itself.

• Choose the function "take reciprocals", apply it to any subset $S$ of $\mathbb{R}\setminus\{0\}$ which is closed under taking reciprocals.

-
Thank you very much! –  Ryan Jan 19 '13 at 16:36

$f(x)=\frac{1}{x}=g(x)$. You have $f(g(x))=\frac{1}{g(x)}=\frac{1}{\frac{1}{x}}=x$.

-
That's technically not a function on $\mathbb{R}$, since it's not defined at 0. Of course, for the purposes of the question, you can just define $f(0)=0$ and it's okay. –  Zev Chonoles Jan 19 '13 at 16:25
define it piecewise to be 0 at x=0 for both f and g –  mathemagician Jan 19 '13 at 16:26
Great example, gracias. –  Ryan Jan 19 '13 at 16:37