Longest derivative "loop"? If we keep differentiating $\sin x$ we eventually arrive back at $\sin x$:
$$
\begin{align}
y &= \sin x \\
\frac{dy}{dx} &= \cos x \\
\frac{d^2y}{dx^2} &= -\sin x \\
\frac{d^3y}{dx^3} &= -\cos x \\
\frac{d^4y}{dx^4} &= \sin x
\end{align}
$$
It has to be differentiated 4 times before it gets back to itself
I was wondering, what function has the longest chain of derivatives before it gets back to itself?
 A: You can get chains as long as you want: For given $n \in \mathbb{N}$ consider $f(x) = e^{e^{\frac{2\pi i}{n}}x}$. Then $f'(x) = e^{\frac{2\pi i}{n}} f(x)$, $f^{(k)}(x) = e^{\frac{2\pi ik}{n}}f(x) \neq f(x)$ and $f^{(n)}(x) = e^{2\pi i} f(x) = f(x)$.
A: I guess that you mean commonly used functions with names.  In which case, I do not know any.  
It is easy to construct functions with loops as long as you want.  To get a loop of length $n$, take the power series for $e^x$ and drop all of the terms whose exponent is not a multiple of $n$.  This will converge for all $x$ and have a derivative loop of length $n$.  
A: Consider the function $f(x)=e^{\zeta_n x}$ where $\zeta_n\in\mathbb C$ is a primitive $n$-th root of unity. This function has period $n$.
A: I don't think that there's an upper bound on this. You can reformulate this as $\frac{d^ny}{dx^n} = y$ which can be rearranged to give $\frac{d^ny}{dx^n} - y = 0$. To solve such a differential equation, solve the characteristic equation $\lambda^n - 1 = 0$, but note that smaller loops also satisfy this equation, but there is a solution that achieves a loop of size $n$. To see this, notice that $\lambda = 1$ always satisfies this and this corresponds to $e^x$. The other solutions are the $n$'th roots of unity. Take the smallest such root i.e. $e^\frac{2\pi i}{n}$ and raise it to the $x$'th power i.e. $f(x) = e^\frac{2\pi ix}{n}$. This solution will satisfy the equation.
A: If you want a realvalued function that can be expressed  in terms of elementary functions you can take the real part of Mikhail Katz' example:
Let $\alpha:={2\pi\over n}$, and put
$$f(x):={\rm Re}\bigl(e^{e^{i\alpha}\,x}\bigr)=e^{\cos\alpha\>x}\>\cos\bigl(\sin\alpha\>x\bigr)\ .$$
Note that the rule ${\displaystyle{d\over dx}e^{\lambda x}=\lambda e^{\lambda x}}$ is also valid for complex $\lambda$. It follows that
$$
{d^n\over dx^n}e^{\lambda x}=\lambda^n e^{\lambda x}\ .$$
When $\lambda=e^{i\alpha}$ then $\lambda^n=e^{i\cdot2\pi}=1$, hence $x\mapsto e^{\lambda x}$ "cycles" under $D$ with period $n$, and so does its real part.
