Functions with alternating derivatives 
*

*The function $a(x) = e^x$ has the property that $a'(x) = a(x).$

*The function $b(x) = e^{-x}$ has the property that $b'(x) = -b(x).$

*The function $b(x) = e^{-x}$ has the property that $b''(x) = b(x).$

*The functions $c(x)$ and $d(x); c(x)=\cosh(x), d(x) = \sinh(x)$ are distinct functions with the property that $c(x)'=d(x), d(x)'=c(x).$

*Furthermore, $c''(x) = c(x),$ and $d''(x) = d(x)$, but $c'(x) \neq -c(x),$ and $d'(x) \neq -d(x).$ Rather $c \to d \to c$ by differentiation, and $d \neq -c.$
Question: are there distinct functions $f(x), g(x), h(x)$ such that $f \to g \to h \to f$ by differentiation, but $f \neq g, f \neq -g,$ etc? To generalize, what about sets of distinct functions of arbitrary length, $j_{1}(x) \to j_{2}(x) \to ... \to j_{N}(x) \to j_{1}(x)$ by differentiation, with again $j_i \neq \pm j_j$ for any $i, j?$
Assume here that the domain $x \in \mathbb{R}$ and the range $\in \mathbb{R}$ as well.
 A: For the first question, you can take for instance
$$f(x)=\mathrm{Re}\left(e^{\frac{-1+i\sqrt3}2x}\right)=e^{-\frac x2}\cos\frac{x\sqrt3}2.$$
For the generalization, let $\omega=e^{i2\pi/n}$ and take
$$f(x)=\mathrm{Re}\left(e^{\omega x}\right)+e^x=e^{x\cos\frac{2\pi}n}\cos\left(x\sin\frac{2\pi}n\right)+e^x.$$
(The "$+e^x$" may be dropped if $n$ is odd, but was proposed by Fishbane in the comments if $n$ is even, to prevent $f$ and its derivatives to be opposite to their ($n/2$)-th derivative.)
A: Without contradicting Anne Bauval’s answer I’d like to present an alternative approach which explains why solutions of this kind work and provides a more general form. It also makes that pesky $e^x$ term natural.
As before, $\omega$ is a primitive $n$th root of unity. For a change I will make $n=5$.
Let $$f(x)=e^{1x}+e^{\omega x}+e^{\omega ^2x}+e^{\omega ^3x}+e^{\omega ^4x}$$
$f(x)$ is real because $\omega$ and $\omega^4$ are complex conjugates, whence $e^{\omega}$ and $e^{\omega^4}$ are complex conjugates.
It follows that
$$f’(x)=e^{1x}+\omega e^{\omega x}+\omega^2e^{\omega ^2x}+\omega^3e^{\omega ^3x}+\omega^4e^{\omega ^4x}$$
$$f’’(x)=e^{1x}+\omega^2 e^{\omega^ x}+\omega^4e^{\omega ^2x}+\omega^6e^{\omega ^3x}+\omega^8e^{\omega ^4x}$$
$$f’’’(x)=e^{1x}+\omega^3 e^{\omega x}+\omega^6e^{\omega ^2x}+\omega^9e^{\omega ^3x}+\omega^{12}e^{\omega ^4x}$$
and
$$f^{(\mathrm v)}(x)=e^{1x}+\omega^5 e^{\omega x}+\omega^{10}e^{\omega ^2x}+\omega^{15}e^{\omega ^3x}+\omega^{20}e^{\omega ^4x}$$
and we are back where we started - which is exactly what was asked for.
For $n=1$, $f(x)=e^x$.
For $n=2$, $f(x)=2\cosh x $.
For $n=4$, $f(x)=2(\cosh x+\cos x)$.
——
It is possible to multiply each of terms in the formula for $f(x)$ by a constant, as long as care is taken to ensure that terms which are complex conjugates remain complex conjugates.
