Numerical tests: periodic, continuous, differentiable function needed For numerical test of a code that solves the fractional diffusion equation I need a function with the following properties:


*

*periodic on $[0,2\pi]$

*differentiable everywhere

*$C^\infty$ would be great, but not necessary. However, the higher the order, the better.

*No function of the type $f=\sum a_n \sin(n\pi x)+b_n \cos(n \pi x)$

*Compact support optional


Since the code is a spectral method, the convergence of my solution depends on the smoothness of the initial function. I do a Fourier expansion in space, so a composition of $\sin(n\pi x)$ and $\cos(n\pi x)$ is uninteresting. 
The standard example would be the Bump function, but I would appreciate another example. Since the problem is related to diffusion, I would like to use a Gaussian initial function. However, the derivatives of a Gaussian aren't continuous for the periodic scenario. 
Any idea is appreciated!
 A: Any periodic smooth function can be represented as a Fourier series. Your fourth requirement cannot be met.
If what you want are examples given not in terms of its Fourier series, you can consider for instance $f$ to be the periodic extension of $x^n(\pi-x)^m$ with $m,n\ge2$; it is of class $C^{\min(m,n)-1}$.
If you want compact support you can consider the periodic extension of $(x-a)^n(b-x)^m$ with $m,n\ge2$ and $0<a<b<2\,\pi$.
A: Take any rational expression in terms of the form $\cos( k x)$, $\sin(k x)$ with $k\in{\mathbb N}$; making sure that no denominator vanishes. A simple example would be
$$f(x):={\cos(3x)-2\sin x\over 3+\cos(2x)-\sin (4x)}\ ,$$
which is plotted here:

A: As doubly-periodic entire functions, the Jacobi theta functions present an obvious source of examples of the desired type. For instance, consider the $2\pi$-periodic Jacobi theta function $\vartheta_3(x/2,q)$ with nome $q$, defined as $$\vartheta_3(x/2,q)=\sum_{n=-\infty}^\infty q^{n^2}e^{-i n x}=1+2\sum_{n=1}^\infty q^{n^2} \cos n x.$$ This function is analytic everywhere in the complex plane, and its Fourier coefficients of this function decay very rapidly (note that the series is convergent if $|q|<1$). This seems ideal for numerical tests.
We may write this in a more suggestive form. Introducing $q=e^{-\sigma^2/2}$ for convenience, we may use Jacobi's imaginary transformation (which we may prove via Poisson summation) to obtain 
\begin{align*}
\vartheta_3(x/2,e^{-\sigma^2/2})
&=\sqrt{\frac{2\pi}{\sigma^2}}e^{-x^2/2\sigma^2}\,\vartheta_3\left(\frac{i\pi x}{\sigma^2},e^{-2\pi^2/\sigma^2}\right)\\
&=\sqrt{\frac{2\pi}{\sigma^2}}e^{-x^2/2\sigma^2}\sum_{n=-\infty}^{\infty} e^{-2n^2\pi ^2/\sigma^2}e^{2\pi n x/\sigma^2}=2\pi \sum_{n=-\infty}^\infty \frac{1}{\sigma\sqrt{ 2\pi }}e^{-(x-2\pi n)^2/2\sigma^2}
\end{align*}
So $\vartheta_3(x/2,e^{-\sigma^2/2})$ represents an infinite sum of $2\pi$-displaced Gaussians pdfs with variance $\sigma^2$. For small $\sigma$ one essentially has a narrow Gaussian in the range $[-\pi,\pi]$, which should make this natural for your purpose.
