Apply function fractional times

For example, one can apply $\cos x$ to number $a$ one time to get $\cos a$, two times $\cos \cos a$, three times $\cos \cos \cos a$, and so on. Is there a way to define fractional application for $\cos$? Or for any other function? Maybe exists general theory for that?

• won't you run into trouble trying to take square root of negative numbers? – abel Apr 25 '15 at 8:30
• It follows from this answer that the answer for $\cos$ is negative if you want the fractional composition to be continuous. Also related: one two three. – Dejan Govc Apr 26 '15 at 10:14

Obviously $f(x,n)$ defined as taking $g$ $n$ times of $x$ is a function $(\mathbb R,\mathbb N)\to\mathbb R$. Any extension of $f$ to $(\mathbb R, \mathbb Q)$, could be considered a way to apply $g$ a rational number of times, if you extend it to $\mathbb R^2$, you could consider it a definition of applying $g$ any (real) number of times.
Extending functions to a larger domain is often done, a very well-known example being the factorial function being extended from $\mathbb N$ to $\mathbb C$ by the gamma function. But considering it applying a function a rational/real/complex/... number of times isn't so common, there's rarely any thing to be gained from viewing it that way.
In the specific case of $\cos$, I don't recall ever seeing such an extension, but we could define one, by saying that for any non-natural number of applications the result is $0$. It's not interesting but now we have a way to apply $\cos$ any number of times we want.
• I agree that this point of view of extensions is a useful one, but since $n$-fold composition $f^n$ satisfies $f^m\circ f^n=f^{m+n}$ it would probably make sense to allow only extensions satisfying $f(f(x,n),m)=f(x,m+n)$ for all $m,n\in\mathbb Q$ (resp. $\mathbb R$). (Intuitively: "applying a function" $n$ times and then another $m$ times is the same as applying it $m+n$ times.) The existence of such extensions seems nontrivial. – Dejan Govc Apr 25 '15 at 9:41
• @DejanGovc is right, that would be a good requirement, but also make such extensions much harder to find. Note that my example construction for an extension of $\cos$ does not fulfil that, if we call the constructed function $h$, it is easy to see that $h(h(x, 0.5), 0.5)=h(0, 0.5)=0 \neq h(x,1)=\cos(x)$. – Henrik Apr 26 '15 at 9:16