# Problems with derivative of $\operatorname{sinc}$ when trying to interpolate in Matlab

Let $\psi\in C_c^{\infty}(\mathbb{R})$, with support away from zero and let $t\mapsto \phi(t)$ be a function of time satisfying the equality:

$$\phi(t)=\int_0^t\psi(s)\,ds$$

and therefore:

$$\psi(x)=\frac{d}{dx}\phi(x).$$

Suppose that we begin with an analogue sampled $\phi[n]:=\phi(n\Delta t)$, where $\Delta t$ is our sampling interval, and we want to use this to reconstruct $\psi$. Then we can use the following $\operatorname{sinc}$ based interpolation formula to first reconstruct

$$\phi(t)=\sum_{n=-\infty}^{\infty}\phi[n]\operatorname{sinc}\left(\frac{t-n\Delta t}{\Delta t}\right).$$

Consequently, we can reconstruct $\psi(x)$ from $\phi[n]$ using

$$\psi(x)=\sum_{n=-\infty}^{\infty}\phi[n]\frac{d}{dx}\operatorname{sinc}\left(\frac{x-n\Delta t}{\Delta t}\right).$$

However, I am really struggling to account for the derivative of $\operatorname{sinc}$ in my Matlab code.

I can, for instance, use:

function psi = interpolate(ts,phin,x)
psi = 0;
for n=1:length(ts)
psi = x+phin(n)*diff(sinc((x-n.*T)./T));
end
psi = [psi 0];


But the problem is that this is a numerical approximation of the derivative and my plot is essentially shifted due to the vector I remove to allow me to plot $x(t)$ with respect to $t$.

Red = The actual function; Blue = The reconstructed function

Of course, I can analytically deduce the actual derivative of $\operatorname{sinc}$, but as Fabian noted in his answer, the sampled version doesn't resemble the actual derivative of $\operatorname{sinc}$ at all.

The sinc function is heavily oscillation. Does it is not a good idea to take its derivative; or in other words, the derivative of $\phi(x)$ via the sampled expression will not have a lot to do with the "real" derivative.
In any case, it would be more useful and stable to rely on standard discrete approximations to $\frac{d}{dx} \phi(x)$ such as the forward, backward, or central difference.
• Well, diff in Matlab calculates the forward difference. The problem I have is that I have to delete a vector in my array to plot it, so that it does not align perfectly with the true function (and is thus shifted slightly along the axis). Do you know how I can solve this problem? – Jason Born Mar 10 '17 at 18:11
• I was also wondering if the central difference of $\operatorname{sinc}$ would yield zero, since it is highy oscillatory, as you say? – Jason Born Mar 30 '17 at 15:32