# Proof verification. Study continuity of $f\circ g$ and $g\circ f$ if $f(x) = 1-|x-1|$ and $g(x) = x$ for $x\in\Bbb Q$, $g(x)=2-x$ for $x\in\Bbb I$

Given two functions: \begin{align} f(x) &= 1 - |x-1|\\ g(x) &= \begin{cases} x,\ \text {if x\in \Bbb Q}\\ 2-x,\ \text {if x\in \Bbb R\setminus\Bbb Q} \end{cases} \end{align} Study continuity of the following compositions: \begin{align*} (f\circ g)(x)\tag 1\\ (g\circ f)(x)\tag 2 \end{align*}

$$\Box$$ I've started with case $$(1)$$. Both $$f(x)$$ and $$g(x)$$ are well defined in $$\Bbb R$$. So we might consider their composition: $$(f\circ g)(x) = \begin{cases} 1-|x-1|,\ \text{if x\in\Bbb Q}\\ 1-|2-x-1|,\ \text{if x\in\Bbb R\setminus\Bbb Q} \end{cases}$$ Or simply: $$(f\circ g)(x) = 1-|x-1|,\ \forall x\in \Bbb R$$

By composition of continuous functions $$1-|x-1|$$ is continuous.

Conclusion: $$(f\circ g)(x)$$ is continuous in $$\Bbb R$$ $$\blacksquare$$.

$$\Box$$ Consider case $$(2)$$. Again both function are well defined in $$\Bbb R$$, so we migh consider their composition: $$(g\circ f)(x) = \begin{cases} 1-|x-1|,\ \text{if x\in\Bbb Q}\\ 2 - (1-|x-1|),\ \text{if x\in\Bbb R\setminus\Bbb Q} \end{cases}$$

Or simplifying: $$(g\circ f)(x) = \begin{cases} 1 - |x-1|,\ \text{if x\in\Bbb Q}\\ 1 + |x-1|),\ \text{if x\in\Bbb R\setminus\Bbb Q} \end{cases}$$

1) It feels natural to consider a point $$x_0 = 1$$ since it will render the absolute value to $$0$$, by which: $$(g\circ f)(x_0) = 1$$

Take any sequence $$(x_n)_{n\in\Bbb N}$$ of rational or irrational numbers such that: $$\lim_{n\to\infty}x_n = 1$$

For a sequence of rationals: $$\lim_{n\to\infty}(g\circ f)(x_n) = \lim_{n\to\infty}(1-|x_n - 1|) = 1 = (g\circ f)(1)$$

The same is true for any sequence of irrational numbers.

2) Now consider some point $$x_0 \ne 1$$. Suppose $$x_0$$ is irrational. Take any sequence $$(x_n)_{n\in\Bbb N}$$ such that $$\forall n\in\Bbb N: x_n \in \Bbb Q$$ and: $$\lim_{n\to\infty}x_n = x_0$$

For any sequence $$(x_n)_{n\in\Bbb N}$$ and $$\forall n\in\Bbb N: x_n \in\Bbb Q$$: \begin{align} \lim_{n\to\infty}(g\circ f)(x_n) &= \lim_{n\to\infty}(1 - |x_n - 1|) \\ &= 1 - |x_0 - 1| < 1 \end{align}

But since $$x_0$$ is irrational: $$(g\circ f)(x_0) = 1 + |x_0 - 1| > 1$$

Which means: $$\lim_{n\to\infty} (g\circ f)(x_n) \ne (g\circ f)(x_0)$$

3) Suppose $$x_0$$ is rational and $$x_0 \ne 1$$, take any sequence $$(x_n)_{n\in\Bbb N}$$ and $$\forall n\in \Bbb N: x_n \in\Bbb R\setminus \Bbb Q$$: $$\lim_{n\to\infty}x_n = x_0$$ Since $$x_0$$ is rational we have: $$(g\circ f)(x_0) = 1 - |x_0 - 1| < 1$$ But: \begin{align} \lim_{n\to\infty}(g\circ f)(x_n) &= \lim_{n\to\infty}(1 + |x_n - 1|) \\ &= 1 + |x_0 - 1| > 1 \end{align} So: $$\lim_{n\to\infty}(g\circ f)(x_n) \ne (g\circ f)(x_0)$$ And that completes the proof.

Conclusion: $$(g\circ f)(x)$$ in continuous at $$x = 1$$ and $$(g\circ f)(x)$$ is discontinuous $$\forall x \in \Bbb R\setminus \{1\}$$ $$\blacksquare$$.

I'm still a bit lost while studying such bizarre functions and not fully sure in the correctness of my reasoning behind the proof. I would like to ask for verification of the above.

Thank you!

• For case 2 and 3, your reasoning seems to be a little bit wrong. If $x_n>y_n$ then we only have that $\lim x_n \geqslant \lim y_n$. – Botond Jul 18 '19 at 17:17
• @Roman: To fix case $(2)$, use the setup of case $(3)$. You want the sequence $(x_n)$ to approach $x_0$. Also, for both case $(2)$ and case $(3)$, you want $x_0\ne 1$, but you only specified that for case $(2)$. Other than that, your proof looks good (+1). – quasi Jul 18 '19 at 17:27
• @roman:$\;$Also, for a more complete conclusion, I suggest:$\;(g\circ f)(x)$ is continuous at $x=1$ and discontinuous at $x=x_0$ for all $x_0\in\Bbb R{\,\setminus\,}\{1\}$. – quasi Jul 18 '19 at 17:48
• "Or simply: $$(f\circ g)(x) = \begin{cases} 1-|x-1|,\ \text{if x\in\Bbb Q}\\ 1-|1-x|,\ \text{if x\in\Bbb R\setminus\Bbb Q} \end{cases}$$" Even *more* simply $f\circ g(x) = 1-|1-x|$ (whether $x$ is rational or not.) – fleablood Jul 18 '19 at 18:19
• "So it follows that for every real number no matter whether it's rational or irrational the value of the function is the same." Well....no. $f(5) \ne f(6)$ and $f(5)\ne f(\sqrt 3)$ and $f(\sqrt 3) \ne f(\pi)$. so the value of the function is very different. You meant say the expression of the function is $f\circ g(x) = 1-|x-1|=1-|1-x|$ is the same for irrationals and rationals and doesnt need a conditional to express it. – fleablood Jul 18 '19 at 18:28

A quicker simpler way to note that $$h(x) = g(x)$$ (where $$g$$ is continuous everywher) if $$x$$ is rational but $$h(x) = f(x)$$(where $$f$$ is continuous everywhere) if $$x$$ is irrational, is continuous at $$x = a$$ if and only if $$f(a) = g(a)$$ is to consider the following.

As $$f,g$$ are continuous for any $$\epsilon > 0$$ there are $$\delta_1$$ and $$\delta_2$$ so that $$|x-a|< \delta_1$$ then $$|f(x) -f(a)| < \epsilon$$ and if $$|x-a|< \delta_2$$ then $$|g(x) -g(a)|< \epsilon$$.

If $$f(a) = g(a)$$ then then if $$|x - a| < \min(\delta_1, \delta_2)$$ then if $$x$$ is rational then $$|h(x) - h(a)| = |f(x) -f(a)| < \epsilon$$. If $$x$$ is irrational then $$|h(x) -h(a)| =|g(x) - g(a)| < \epsilon$$ and either way $$|h(x) - h(a)| < \epsilon$$. So $$h$$ is continuous at $$a$$.

But if $$f(a)\ne g(a)$$ then $$|f(a)-g(a)| = c > 0$$.

Lets assume $$h$$ is continuous at $$a$$. That would mean for the same $$\epsilon, \delta_1, \delta_2$$ above we would have a $$\delta_3$$ so that $$|x-a|<\delta_3 \implies |h(x) - h(a)| < \epsilon$$

Now for any interval, there exist a rational $$x$$ and an irrational $$y$$ so that $$|x-a|<\min(\delta_1, \delta_2,\delta_3)$$ and $$|y-a| < \min(\delta_1, \delta_2,\delta_3)$$.

But $$c = |f(a) -g(a)| =$$

$$|[f(a)-f(x)] + [f(x) - g(y)] +[g(y)-g(a)]| =$$

$$|[f(a)-f(x)] + [h(x) - h(y)] +[g(y)-g(a)]| \le$$

$$|f(a)-f(x)| + |h(x)-h(y)| + |g(y) - g(a)| <$$

$$\epsilon + |[h(x) -h(a)]+[h(a)-h(y)] + \epsilon \le$$

$$2\epsilon + |h(x)-h(a)| + |h(y)-h(a)|<$$

$$2\epsilon + \epsilon+\epsilon = 4\epsilon$$.

So $$\epsilon > \frac c4 > 0$$. Which contradicts that $$\epsilon$$ can be arbitrarily small.

So $$h$$ is not continuous at $$a$$ if $$f(a)\ne g(a)$$.

......

You correctly figured that $$f\circ g(x) = 1-|x-1|$$ which is continuous by, as you say, composition of continuous functions.

And you correctly figured that $$(g\circ f)(x) = \begin{cases} 1 - |x-1|,\ \text{if x\in\Bbb Q}\\ 1 + |x-1|),\ \text{if x\in\Bbb R\setminus\Bbb Q} \end{cases}$$

So this is continuous at points $$a$$ where $$1-|x-1| = 1 + |x-1|$$ and discontinuous everywhere else.

Now $$1-|x-1| = 1 + |x-1|\iff -|x-1|=|x-1|\iff x-1 = 0 \iff x = 1$$.

So $$g\circ f$$ is continuous at $$1$$ and discontinuous everywhere else.

• That's an interesting approach. Thank you! – roman Jul 19 '19 at 13:41