On the derivative of a function that is its own inverse

We can first use Binomial Theorem. The first term can be integrated separately, and the remaining terms can be paired as follows. \begin{eqnarray} \mathcal I &=& \int_0^1 (x-f(x))^{2n} dx =\\ &=&\frac1{2n+1}+\sum_{k=1}^{n}\left\{{2n \choose k}(-1)^k\int_0^1x^{2n-k}[f(x)]^{k}dx+\right.\\ & &-\left.{2n\choose 2n-k+1}(-1)^{k}\int_0^1x^{k-1}[f(x)]^{2n-k+1}dx\right\} \end{eqnarray} Now let us perform the change of variable $x \to f(x)$ and then integration by parts to further elaborate the second term in the above sum, thus getting \begin{eqnarray} \mathcal I &=&\frac1{2n+1}+\sum_{k=1}^{n}\left\{{2n \choose k}(-1)^k\int_0^1x^{2n-k}[f(x)]^{k}dx+\right.\\ & &+\left.{2n\choose 2n-k+1}(-1)^{k}\int_0^1x^{2n-k+1}[f(x)]^{k-1}f'(x)dx\right\}=\\ &=&\frac1{2n+1}+\sum_{k=1}^{n}\left\{{2n \choose k}(-1)^k\int_0^1x^{2n-k}[f(x)]^{k}dx+\right.\\ & &-\left.{2n\choose 2n-k+1}(-1)^{k}\frac{2n-k+1}{k}\int_0^1x^{2n-k}[f(x)]^{k}dx\right\}=\\ &=&\boxed{\frac1{2n+1}}. \end{eqnarray}


EDIT - "Slicker" solution

Change of variable $x \to f(x)$ yields \begin{eqnarray} \mathcal I &=& -\int_{0}^1(x-f(x))^{2n}f'(x)dx=\\ &=&\int_0^1(x-f(x))^{2n}(1-f'(x)-1)dx=\\ &=&\frac1{2n+1}\left[(x-f(x))^{2n+1}\right]_0^1 -\mathcal I=\\ &=&\frac2{2n+1}-\mathcal I. \end{eqnarray} Hence the result $$\boxed{\mathcal I = \frac1{2n+1}}.$$