Construct a differentiable and periodic function I am looking for a differentiable and periodic function $f$ such that the following conditions are satisfied:
$1)$ $f(x_i) = y_i,~ $ for given $x_i,y_i$, $ \forall i \in \{0,1,...,n-1\}$; 
$2)$ $f(x_{i+kn}) = f(x_i), ~ \forall k \in \mathbb{Z}$;
$3)$ $ x_{j} - x_{j-1} = \Delta x~ (constant),~\forall j \in \mathbb{Z}.$
Is there some method to construct a such function?
I appreciate some hints/references to solve this problem. Thanks in advance!
 A: Suppose that the number of points $n$ is odd. For example, consider $x_0 = -2$, $x_1 = -1$, $x_2 = 0$, $x_3 = 1$ and $x_4 = 2$, and $y_0 = 4$, $y_1 = 2, y_2 = 1, y_3 = -1$ and $y_4 = -2$ ($n=5$).
In this case $\Delta x = 1$, while the period is $T = n\Delta x = 5.$
You can try to find your function using a truncated Fourier series of order $m = \frac{n-1}{2}:$
$$f(x) = \frac{a_0}{2} + \sum_{k=1}^{m}\left(a_k \cos\left(\frac{2\pi xk}{T}\right) + b_k \sin\left(\frac{2\pi xk}{T}\right)\right). $$
In your case, $m=2$, and you have to find the parameters $a_0$, $a_1$,$a_2$, $b_1$ and $b_2$. They are $5$, which is the same number of available points $n$. This is very important.
Now, you can substitute the available points to the function $f$:
$$\begin{cases}
f(x_0) = y_0 \\
f(x_1) = y_1 \\
f(x_2) = y_2 \\
f(x_3) = y_3 \\
f(x_4) = y_4
\end{cases} \Rightarrow\\
\begin{cases}
\frac{a_0}{2} + \sum_{k=1}^{2}\left(a_k \cos\left(\frac{-4\pi k}{5}\right) + b_k \sin\left(-\frac{4\pi k}{5}\right)\right) = 4\\
\frac{a_0}{2} + \sum_{k=1}^{2}\left(a_k \cos\left(\frac{-2\pi k}{5}\right) + b_k \sin\left(-\frac{2\pi k}{5}\right)\right) = 2\\
\frac{a_0}{2} + \sum_{k=1}^{2}\left(a_k \cos\left(0\right) + b_k \sin\left(0\right)\right) = 1\\
\frac{a_0}{2} + \sum_{k=1}^{2}\left(a_k \cos\left(\frac{2\pi k}{5}\right) + b_k \sin\left(\frac{2\pi k}{5}\right)\right) = -1\\
\frac{a_0}{2} + \sum_{k=1}^{2}\left(a_k \cos\left(\frac{4\pi k}{5}\right) + b_k \sin\left(\frac{4\pi k}{5}\right)\right) = -2\\
\end{cases}.$$
This system can be rewritten in matricial form:
$$\begin{bmatrix}
\frac{1}{2} & \cos\left(-\frac{4\pi}{5}\right) & \cos\left(-\frac{8\pi}{5}\right) & \sin\left(-\frac{4\pi}{5}\right) & \sin\left(-\frac{8\pi}{5}\right)\\
\frac{1}{2} & \cos\left(-\frac{2\pi}{5}\right) & \cos\left(-\frac{4\pi}{5}\right) & \sin\left(-\frac{2\pi}{5}\right) & \sin\left(-\frac{4\pi}{5}\right)\\
\frac{1}{2} & \cos\left(0\right) & \cos\left(0\right) & \sin\left(0\right) & \sin\left(0\right)\\
\frac{1}{2} & \cos\left(\frac{2\pi}{5}\right) & \cos\left(\frac{4\pi}{5}\right) & \sin\left(\frac{2\pi}{5}\right) & \sin\left(\frac{4\pi}{5}\right)\\
\frac{1}{2} & \cos\left(\frac{4\pi}{5}\right) & \cos\left(\frac{8\pi}{5}\right) & \sin\left(\frac{4\pi}{5}\right) & \sin\left(\frac{8\pi}{5}\right)\\
\end{bmatrix} \cdot \begin{bmatrix}
a_0 \\
a_1 \\
a_2\\
b_1\\
b_2
\end{bmatrix} = \begin{bmatrix}
4 \\
2 \\
1\\
-1\\
-2
\end{bmatrix}.$$
If the matrix is invertible, then you are done!
In this case, I get the following:
$$  a_0 \simeq 1.6, a_1 \simeq  -0.1236,
    a_2 \simeq 0.32,
   b_1 \simeq  -2.5520,
    b_2 \simeq 1.5772.$$
Here is how this function looks like:

Addition The number of points must be odd, since the number of parameters of the truncated Fourier series is odd too. In order to have a well posed system of equation, you need to have as many unknowns (the parameters) as the available data, as well as the same number of equations.
For more details on Fourier series, look here.
