TITLE: how to find $\int_{0}^{1}h_n(x)dx?$
QUESTION [7 upvotes]: I would appreciate if somebody could help me with the following problem: 
$$h(x)=\begin{cases}
2x&\left(0\leq x\leq \frac{1}{3}\right)\\
\frac{1}{2}x+\frac{1}{2} &\left(\frac{1}{3}<x\leq 1\right)
\end{cases}$$
let   $h_2(x)=h(h(x)), h_3(x)=h_2(h(x)),\cdots, h_{n+1}(x)=h_n(h(x))$
find $\int_{0}^{1}h_n(x)dx ?$

REPLY [15 votes]: Playing around with the patterns of this recursion, I get the following:
$$h_n(x) = \begin{cases}\\ 2^n x, & 0 < x < \frac{1}{3 \cdot 2^{n-1}}\\2^{n-2 m} x + \left (1-\frac{1}{2^m}\right ),&\frac{1}{3 \cdot 2^{n-m}}<x<\frac{1}{3 \cdot 2^{n-m-1}} \\ \frac{1}{2^n} x +\left (1-\frac{1}{2^n}\right ),&\frac{1}{3}<x<1 \end{cases}$$
where $m \in \{1,2,\ldots,n-1\}$.  You can verify this is true by induction, using $h_{n+1}(x) = h(h_n(x))$.  (I leave this to the reader and OP.)
Once you have this definition set, doing the integral is a matter of careful bookkeeping:
$$\begin{align}\int_0^1 dx \: h_n(x) = \int_0^{1/(3 \cdot 2^{n-1})} dx \: 2^n x + \sum_{m=1}^{n-1} \int_{1/(3 \cdot 2^{n-m})}^{1/(3 \cdot 2^{n-m-1})} dx \left [(2^{n-2 m} x + \left (1-\frac{1}{2^m}\right )\right ]\\ + \int_{1/3}^1 dx \: \left [\frac{1}{2^n} x +\left (1-\frac{1}{2^n}\right )\right ] \\\end{align}$$
I again leave the algebra to the reader and OP; the result is
$$\int_0^1 dx \: h_n(x) = 1 - \frac{n+3}{6 \cdot 2^n} $$
You can verify that this result agrees with the $n=1$ case.
ADDENDUM
Here is a plot of the first few cases for $h_n$: