(Nice) functions whose Taylor-Maclaurin expansion have alternating signs after every two/three terms? Seeing some users wonder about closed form of series of real numbers with signs alternating after pairs/triples (eg, $1+2-3-4+5+6-7-8+\ldots$ and $1+2+3-4-5-6+7+\ldots$) I got curious whether

do there exist (sufficiently nice?) functions whose Taylor Maclaurin expansion $\ldots$ has signs alternating after every two/three or more terms?

I remembered that $f^{(n)}(\sin x)$ does change sign in our desired manner $${f^{(0)}(\sin x)=\sin x,f^{(1)}(\sin x)=\cos x,f^{(2)}(\sin x)=-\sin x,}$$ $${f^{(3)}(\sin x)=-\cos x,f^{(4)}(\sin x)=\sin x,\ldots}$$
so expanding about some small positive $h$
$$\sin x = \sin h + \dfrac{\cos h}{1!}(x-h) - \dfrac{\sin h}{2!}(x-h)^2 - \dfrac{\cos h}{3!}(x-h)^3 + \dfrac{\sin h}{4!}(x-h)^4 + \ldots $$
which is not as interesting a formula as formula of $\sin x$ about zero.
Thus my question :


do there exist (sufficiently nice?) functions whose Taylor Maclaurin expansion about zero has signs alternating after every two/three or more terms?


Here nice probably means some simple combination of known continuous functions e.g., trig, exponential, hyperbolic etc.
I'm not sure of its uses. Just curiosity. Thank you!
 A: This is possible, and here is a general way how you can do it. The result will be expressed via only the exponential function, even though the exponent may be a complex number. You may want to rephrase the result in terms of real numbers (using Euler's formula), in which case $\sin$ and $\cos$ may pop out.
Suppose you want the values of the higher derivatives to be $f^{(n)}(0)=a_n$ where $(a_n)_{n\ge 0}$ is an arbitrary real (or even complex) sequence, periodic with period $N$ (i.e. $a_{n+N}=a_n$ for all $n\ge 0$).
Let $\varepsilon$ be the primitive $N$th root of unity, i.e. $\varepsilon=e^{\frac{2\pi i}{N}}$. Look at the following matrix:
$$\begin{bmatrix}1&1&1&\cdots&1\\1&\varepsilon&\varepsilon^2&\cdots&\varepsilon^{N-1}\\1&\varepsilon^2&\varepsilon^4&\cdots&\varepsilon^{2(N-1)}\\\vdots&\vdots&\vdots&&\vdots\\1&\varepsilon^{N-1}&\varepsilon^{2(N-1)}&\cdots&\varepsilon^{(N-1)^2}\end{bmatrix}$$
This matrix is a regular matrix (its determinant is nonzero), because it is a Vandermonde matrix and $1, \varepsilon, \varepsilon^2, \ldots,\varepsilon^{N-1}$ are all different.
Thus, the columns of the matrix span $\mathbb C^N$ and so you can find $\alpha_0, \alpha_1,\ldots,\alpha_{N-1}$ such that $(a_0,a_1,\ldots,a_{N-1})^T=\sum_{k=0}^{N-1}\alpha_k\cdot(1,\varepsilon^k,\varepsilon^{2k},\ldots,\varepsilon^{k(N-1)})^T$.
Now, for a fixed $k=0,1,2,\ldots,N-1$, note that the function $f_k(x)=e^{\varepsilon^k x}$ has as an $n$th derivative $f_k^{(n)}(x)=\varepsilon^{nk}e^{\varepsilon^k x}$, so $f_k^{(n)}(0)=\varepsilon^{nk}$. In other words, in the Maclaurin series you will have the coefficients precisely equal to $1, \varepsilon^k,\varepsilon^{2k},\ldots$, which will be periodic with period $N$.
Now it is the matter of a simple check that the function $f$ built up as:
$$f(x)=\sum_{k=0}^{N-1}\alpha_k f_k(x)=\sum_{k=0}^{N-1}\alpha_k e^{\varepsilon^k x}$$
(using those same coefficients $\alpha_0,\ldots,\alpha_{N-1}$ we got before) is the function you want, and it will have exactly the desired coefficients in its Maclaurin series, due to linearity of those coefficients.
Example: How to get back to $\cos$: you want the coefficients to be $1,0,-1,0,1,0,-1,0,\ldots$, i.e. the period to be $N=4$. Take $\varepsilon=i$ (the $4$th root of unity) and express $(1,0,-1,0)^T$ as a linear combination of $(1,1,1,1)^T, (1,i,-1,i)^T, (1,-1,1,-1)^T$ and $(1,-i,-1,i)^T$. The coefficients will end up being $0,\frac{1}{2}, 0, \frac{1}{2}$, respectively. Thus, the function will end up being:
$$\frac{1}{2}e^{ix}+\frac{1}{2}e^{-ix}$$
for which Euler's formula says that it is the same as $\cos x$.
A: An easier if less interesting example than @StinkingBishop's:
If you want $n$ pluses followed by $n$ minuses, use e.g. $\sum_{j=0}^{n-1}x^j\cdot(1-x^n)f(x^{2n})$, where $f$ has positive coefficients for every power, such a with $f(x)=\exp x$ (I take this example to get an infinite radius of convergence). I've mentioned the cases $n\in\{2,\,3\}$ in a comment.
