Does there exist any relationship between non-constant $N$-Exhaustible function and differentiability? I was trying to solve this question. If $f ◦f$ is differentiable, then $f ◦f ◦f$ is differentiable. While trying to find the counterexample. I come across the Dirichlet function. $f(x) = \begin{cases} 1 & x \in \mathbb{Q},\\ 0 & x \not\in\mathbb{Q}\end{cases}$. $f ◦f=1$. I landed up on my own definition. I don't know someone might have created this definition before or not.

Definition:- A function $f:\mathbb R \to \mathbb R$ is $N$-Exhaustible, If  $\min_{n\in \mathbb N} \{\underbrace{f \circ f \circ ...f}_{\text{n-times}}=Constant\}=N$. 

According to my definition, Dirichlet function is $2$- Exhaustible. I tried to find $N$-Exhaustible function, where $N>2$. Does there exist any relationship between non-constant $N$-Exhaustible function and differentiability? till now, I got only non-differentiable $N$-Exhaustible functions.Will this definition useful in the future? How do I check whether this definition exists before or not? I have revised the definition. My previous definition was not complete. I hope, My new definition is clear. If not, please help me to correct me.
 A: My earlier example was an ad-hoc one that achieved the goal by just having a parameter that one can tweak to make $f$ get closer to (but not touching) the line defined by "$x=y$". One can easily prove that this creates a contractive map that eventually becomes zero because it falls into the interval $[0,1]$.
$
\def\lfrac#1#2{{\large\frac{#1}{#2}}}
$
Here is another nilpotent example where the parameter can be increased without bound to increase the order of exhaustibility:

Take any positive natural $c$. Let $h$ be the function on the reals such that $h(x) = 0$ for every real $x \le 1$ and $h(x) = \exp(\lfrac1{1-x})·(1-\exp(\lfrac{1-x}{c}))·c)$. Then $h$ is $n$-exhaustible for some natural $n$ in the range $[\log_2(c+2)-1,c+1]$.

Here in rainbow order are the first 7 iterates of $h$:

I devised it as follows. The first factor is as usual, there only to make all right-hand derivatives of $h$ at $1$ equal to $0$, so that $h$ is infinitely differentiable. The second factor is obtained by simply scaling $( x \mapsto 1-\exp(-x) )$ by a factor of $c$ and then translating it towards the right. This map was chosen precisely to have an upper bound, and the translation ensures finite order exhaustibility.
I shall sketch the proof of the behaviour. $h$ is increasing, and $(1-\exp(\lfrac{1-x}{c}))·c$ $\le \min(c,x-1)$ for every real $x > 1$, and so $h^{c+1}(x) \le h^c(c) \le 0$. Thus $h$ is $n$-exhaustible for some $n \le c+1$. Now take $x \in [2,c]$. Then $\exp(\lfrac1{1-x})$ $\ge 1+\lfrac1{1-x}$ $= \lfrac{x-2}{x-1}$, and $(1-\exp(\lfrac{1-x}{c}))·c$ $= \Big( 1-\lfrac1{\exp(\lfrac{1-x}{c})} \Big)·c$ $\ge \Big( 1-\lfrac1{1+\lfrac{x-1}{c}} \Big)·c$ $= \lfrac{x-1}{x+c-1}·c$, and so $h(x) \ge \lfrac{x-2}{x+c-1}·c \ge \lfrac12x-1$, where the last inequality is by concavity of that hyperbola through $(2,0)$ and $(c+1,\lfrac{c-1}{2})$. Thus $h(x)+2 \ge \lfrac12(x+2)$ and hence $h^k(x)+2 \ge \lfrac1{2^k}(x+2)$ for every natural $k$ as long as $h^i(x) \in [2,c]$ for each $i \in [1..k-1]$. This holds if $x = c$ and $k \le \log_2(c+2)-1$. Thus $h$ is $n$-exhaustible for some $n \ge \log_2(c+2)-1$.
A: I shall construct a few examples to show one way it can be done.
$
\def\rr{\mathbb{R}}
\def\lfrac#1#2{{\large\frac{#1}{#2}}}
$
Let $f$ be the function on reals such that $f(x) = 0$ for every real $x \le 0$ and $f(x) = -\exp(\lfrac1x)$ for every real $x > 0$. Then $f$ is infinitely differentiable and $2$-exhaustible.
Using the same idea it is easy to get higher-order exhaustibility. Let $g$ be the function on reals such that $g(x) = 0$ for every real $x \le 1$ and $g(x) = -28(x-1)(x-2)·\exp(\lfrac1{x-1})$ for every real $x > 1$. Then $g$ is infinitely differentiable and $3$-exhaustible.
Try changing the $28$ in the definition of $g$ to get $4$-exhaustibility and beyond!
