# Prove a specific piecewise function is continuous.

Let $$f(x)$$ be a continuous function on $$\Bbb X \subset \Bbb R$$. Let $$a, b \in\Bbb R$$ and $$a < b$$. Prove that the following function is also continuous on $$\Bbb X$$: $$f(a, b, x) = \begin{cases} f(x),\ \text{if a \le f(x) \le b} \\ a,\ \text{if f(x) < a}\\ b,\ \text{if f(x) > b} \end{cases}$$

Intuitively the function above is defined in a way to "cut" the upper and lower parts of $$f(x)$$. So my idea was to define a new function in terms of $$\min$$ and $$\max$$ functions. I've started by defining a couple of helper functions. Let: $$g(x) = \min\{b; f(x)\}\\ h(x) = \max\{a; f(x)\}$$

Here is a visualization in desmos I've been playing with. Using $$g(x)$$ and $$h(x)$$ we might redefine $$f(x)$$ as: $$f(x) = \max\left\{\min\{g(x); h(x)\}; a\right\}$$

Consider min and max functions in the following form: \begin{align*} \max\{x, y\} = {1\over 2}(x + y) + {1\over 2}|x-y|\tag1\\ \min\{x, y\} = {1\over 2}(x + y) - {1\over 2}|x-y|\tag2 \end{align*}

Using the above definition it follows that both min and max are continuous in case $$x$$ and $$y$$ are continuous by composition of continuous functions. Since $$c_1(x) = b$$ is a constant function and $$c_2(x) = a$$ is also a constant function, then they are both continuous. $$f(x)$$ is also continuous by initial conditions.

Using these facts we obtain: $$g(x)$$ and $$h(x)$$ are continuous by composition of continuous functions is continuous.

At this point, I'm not sure whether I need to express $$f(x)$$ in terms of $$(1)$$ and $$(2)$$. I mean we could rewrite $$f(x)$$ as: $$f(x) = {1\over 2}(\min\{g(x); h(x)\} + a) + {1\over 2}|\min\{g(x); h(x)\} - a| = \cdots$$

And we could continue the same way until we get a huge expression in terms of $$(1)$$ and $$(2)$$ without mentioning min and max. So eventually we would again obtain a composition of continuous functions which is also continuous. But that is redundant, isn's that?

I'm interested whether the approach above is even correct? If not, what would be a way to show $$f(a,b,x)$$ is continuous? Also, could we find a more simple approach?

Thank you!

• I like this approach. I think it is the best one, in fact. – Kavi Rama Murthy Jul 26 '19 at 10:18

For clarity define $$g(x) \equiv f(a,b,x)$$. Recall that $$g(x)$$ is continuous if and only if $$g^{-1}(S)$$ is open whenever $$S$$ is open. So let $$S$$ be any open subset of $$[a,b]$$ (the codomain of $$g$$). Now $$g^{-1}(S) = f^{-1}(S)$$ by construction. Moreover $$f$$ is continuous so $$f^{-1}(S)$$ is open. Result follows.