Real Analysis – How to Construct Continuous Real Functions Mapping One Interval to Another

continuityfunctional-analysisreal-analysis

So I am doing an introductory course on theory of real functions and am having hard time thinking of examples.

I know various theorems and can tell whether or not a continuous function with specific details exists. However, I would want to know how do experts come up with examples so quickly?

Consider this question:

Does there exist a continuous function $f:\mathbb R\to\mathbb R$ such that $f((0,1))=[0,1]?$

Initially, I was under the impression that pre-image of a closed set must be closed and thus, no such function exists. Later, I realized that it is not at all necessary to have $(0,1)= f^{-1}([0,1])$, rather it's possible that $(0,1)\subset f^{-1}([0,1])$.

For the sake of clarity of notation: $f^{-1}([0,1])=\{x\in\mathbb R \text{ such that } f(x)\in[0,1]\}\tag*{}$

I am kind of sure that such a function (as described in the question) exists, however, I can't think of examples in my mind.

I did the same question a while back with different intervals. Continuous $f:\mathbb R\to\mathbb R$ such that $f((-1,1))=[-1,1]$. I didn't have to think much and I came up with $f(x)=\sin(\pi x)$ which works.

If I translate and scale everything, I think I have $g((-1,1))=[-1,1]$ for:
$$\displaystyle g(x)=\frac{\sin(\pi(2x-1))+1}{2}$$

I hope this example is correct. Is there any simpler example (like ones which I can quickly produce in a exam setting…)?


Update:

User localshop suggested that we can partition the interval $(0,1)$ and construct an isolated (half-period of) a triangle wave.

$$h(x)=\begin{cases}0 &\text{if $x\leq 0.25$}\\ 4x-1&\text{if $0.25\leq x\leq 0.5$}\\ -4x+3&\text{if $0.5\leq x\leq 0.75$}\\ 0 &\text{if $x\geq 0.75$}\end{cases}$$

Thanks to Desmos. Here's what the graphs looks like in the region $(0,1)\times [0,1]$:

enter image description here

[$h(x)$ in green and $g(x)$ in blue]

Best Answer

If you do a precalculus analysis of the graph of the function $g(x)=x^3-3x$ you'll see that $$g(-\sqrt{3},+\sqrt{3}) = [-2,+2] $$ Now just linearly scale and shift the $x$ and $y$ axes to adjust the domain and range: $$f(x) = a + b g(cx + d) $$ Letting $c = 2 \sqrt{3}$ and $d=-\sqrt{3}$, the function $cx+d$ takes $(0,1)$ to $(-\sqrt{3},\sqrt{3})$.

Then $g$ takes $(-\sqrt{3},+\sqrt{3})$ to $[-2,+2]$

And finally, letting $a=\frac{1}{2}$ and $b=\frac{1}{4}$, the function $a+by$ takes the interval $[-2,2]$ to the interval $[0,1]$.

Related Question