The Problem
Given a trigonometric polynomial of order $K$: $$y(t)=\sum_{k=-K}^K c_k \ e ^ {j k \bar \omega t} \ , \qquad c_{-k}=\bar c_k$$ we want to find the best approximation to it using a periodic continuous piecewise linear function defined by the $N$ (in general not equispaced) knots $(t_i,p_i)$ with $i \in \{1,2,...,N\}$ and $0\le t_i< t_{i+1}<T=1/\bar\omega$: $$ p(t) = (t-t_i)\frac{p_{i+1}-p_i}{t_{i+1}-t_i} \qquad t \in [t_i,t_{i+1}] \qquad t_0=t_N-T, \ p_0=p_N $$
With best we intend the approximation that exactly matches the harmonic content up to order $K$, while being the purest possible with respect to the higher harmonics.
What if the $p_i$ are constrained to be quantized i.e. $\ p_i/q\in \mathbb{Z} \ $ ?
My path so far
I was able to do the following. First of all I am considering the $p_i$ unconstrained.
We find the spectrum of the linear approximation:
- its mean is $M=1/{2T}\sum_{i=0}^{N-1} (t_{i+1}-t_i) (p_i+p_{i+1})$
- its first derivative is a periodic step function, with zero mean;
- its second derivative is a sequence of deltas with areas equal to the slope changes $\Delta m_i=(p_{i+1}-p_i)/(t_{i+1}-t_i)-(p_i-p_{i-1})/(t_i-t_{i-1})$
- therefore its Fourier transform is $$ \hat p(\omega)=M \delta(\omega) - \sum_{k=-K}^K { {1\over k^2\bar\omega^2} \sum_{i=1}^N \Delta m_i \ e^{-j k\bar\omega t_i} \ \delta(\omega - k\bar\omega)} \ . $$ where $M$ comes in with the integration constant, and corresponds to the above mentioned average, and, being $p(t)$ periodic, the spectrum is sampled at pulsations $\omega=k\bar\omega$
Therefore, equating term by term, the best match should satisfy the following equations:
\begin{array}{3} c_0=M & & & [0]\\ c_k=-{1\over k^2\bar\omega^2} \sum_{i=1}^N \Delta m_i \ e^{-j k\bar\omega t_i} & 0 \lt |k| \le K & & [1] \\ c_k=0 & |k| \gt K & & [2] \end{array}
Lines [0] and [1] are $2K+1$ real relationships, the unknowns being 2N, therefore we need at least $N=K+1$ points, and the remaining $2(N-K)-1$ degrees, can be used to solve the equations [3], and minimize the higher order $c_k$'s for example in a least squares sense, $$S = \sum_{k=K+1}^{\infty} |c_k|^2 $$ \begin{array}{2} {\partial S \over \partial t_i} = 0 & & & [2'] \cr {\partial S \over \partial p_i} = 0 & & & [2''] \end{array}
Where I can't go forward
These are another 2N equation therefore in total we have 2N unknowns and 2N+2K+1 equations. It seems I am lost with the balance, or I don't really remember how to apply the least squares method in practice. Help!
Then, beside the least squares, all equations except the first [0], are transcendent in the $t_i$, which appear both in the $\Delta m_i$ coefficients and in the arguments of trigonometric functions, while it is rational in the $p_i$. What is a good strategy to find an approximate solution?
Finally, the method that I am looking for, should be able to work out the optimal knots, given that the $p_i$ are finite precision, so they are multiples of a quantum $q$. Being it a constrained optimization, I can only think of Lagrange's multipliers method, but I have not started developing the math as I feel it will be overly complicated...
Not to mention that I have tested the above math on simple cases $K=1,2$ , $N=4,6$, and have found myself lost
I will be grateful if anybody of you out there can confirm my path so far, and really happy to get some ideas how to go on...