Finf f such that $F \circ F$ is a primitive of f Find all primitivable functions $f:\mathbb{R} \to \mathbb{R}$ that admits a primitive $F:\mathbb{R} \to \mathbb{R}$ for which $F\circ F$ is a primitive of $f$.
From $(F \circ F)'=f$ we get that $f(x)(f(F(x))-1)=0, \forall x \in \mathbb{R}$. (1)
We can also write that $F\circ F=F+c$, where c is a real constant. (2)
If there is an a such that $f(a) \neq 0$, then $f(F(a))=1$.
In (1) we put x=F(a), and so $f(F(F(a)))=1.$
Generally, $f((\underbrace{F\circ F\circ F \circ ... \circ F}_{\text{n times }})(a))=1$, or $f(F^n(a))=1$, for all $n\in \mathbb{N}$.
From (2) we get that $F^n(x)=F(x)+(n-1)c, \forall x\in \mathbb{R}$.
So $f(F(a)+(n-1)c)=1, \forall n \in \mathbb{N}$. 
Now, I'm stuck.
 A: As already noticed, there must exist a $C\in\mathbb R$ such that $F(F(x))=F(x)+C$ holds for all $x\in\mathbb R$. Therefore, for all $y\in A:=\operatorname{Im}(F)\neq\emptyset$, we have $$F(y)=y+C.\tag{$\ast$}$$ Since $F$ is differentiable, it must be continuous, so $A$ is an interval. Let $a_1=\inf A$ and $a_2=\sup A$.
There are three cases to treat.
Case 1: $C>0$. In this case, by $(\ast)$, for each $y\in A$, we have $y+C\in A$. This implies that $a_2=\infty$. If $a_1=-\infty$, the solution is uniquely determined by $(\ast)$, i.e. $$F(y)=y+C$$ holds for all $y\in\mathbb R$. If $a_1$ is finite, $(\ast)$ must only hold for $y\in[a_1,\infty)$. In fact, this is also the only constraint: if $G:(-\infty,a_1]\to\mathbb R$ is an arbitrary differentiable function such that $G(a_1)=a_1+C$, $G^{L}(a_1)=1$ (here I'm using $G^L$ to denote the left derivative of $G$) and $\inf G\geq a_1$, then $$F(y)=\begin{cases}y+C;&y\geq a_1,\\G(y);&y\leq a_1,&\end{cases}\tag{1}$$ solves the problem (to be a little nitpicky, we should add the condition that $\inf G=a_1$, but this doesn't really matter, since a solution not satisfying this property is still obtained for a different $a_1$).
Case 2: $C<0$. This case is treated similarly. By $(\ast)$ we have $a_1=-\infty$. If $a_2=\infty$, the unique solution is $$F(y)=y+C,\qquad y\in\mathbb R.$$ If $a_2$ is finite, $$F(y)=\begin{cases}y+C;&y\leq a_2,\\G(y);&y\geq a_2,&\end{cases}\tag{2}$$ where $G$ is an arbitrary differentiable function with $G(a_2)=a_2+C$, $G^R(a_2)=1$ (where $G^R$ is the right derivative of $G$) and $\sup G\leq a_2$, solves the problem.
Case 3: $C=0$. This case is a little different. First of all, it may happen that $A=\{D\}$ is a single point; then $$F(y)=D,\qquad y\in\mathbb R,$$ is the constant function. If $A$ contains more than one point, we will show that $A=\mathbb R$ must hold.
We argue by contradiction. First suppose that $a_2<\infty$. Then there is an $\epsilon>0$ such that $F(y)=y$ for all $y\in(a_2-\epsilon,a_2]$. Therefore $F^L(a_2)=1$. Since $F$ is in fact differentiable at $a_2$ by our assumptions, this means that $F'(a_2)=1$. But then $F$ is increasing in $a_2$, so there must exist an $y>a_2$ such that $F(y)>F(a_2)=a_2$. This contradicts the fact that $a_2=\sup A$. So, indeed $a_2=\infty$.
A completely analogous argument shows that $a_1=-\infty$: suppose that $a_1>-\infty$, note that $F^R(a_1)=1$, so $F'(a_1)=1$ and $F$ is increasing in $a_1$, yielding another contradiction.
So the only remaining option is that $A=\mathbb R$. In this case, $(\ast)$ yields $$F(y)=y,\qquad y\in\mathbb R.$$
Conclusion: the functions $F$ that solve the problem are exactly the constant functions, the functions of the form $F(x)=x+C$, for $C\in\mathbb R$, the functions of the form $(1)$ for arbitrary $a_1\in\mathbb R$, arbitrary $C>0$ and arbitrary $G$ satisfying the constraints $G(a_1)=a_1+C$, $G^L(a_1)=1$ and $\inf G\geq a_1$, and the functions of the form $(2)$ for arbitrary $a_2\in\mathbb R$, $C<0$ and arbitrary $G$ satisfying the constraints $G(a_1)=a_1+C$, $G^R(a_1)=1$ and $\sup G\geq a_2$. (To obtain the answer in terms of $f$, simply differentiate these functions.)
