# FM demodulation using complex differentiation

I'm trying to implement the complex differentiation discriminator which is taken from Software-Defined Radio Using MATLAB, Simulink, and the RTL-SDR. The final result is $$s(t) = \frac{s_q'(t) s_i(t) - s_i'(t)s_q(t)}{s_i^2(t) + s_q^2(t)}$$ where $$s_i(t)$$ and $$s_q(t)$$ are in-phase and quadrature components. If we approximate the differentiation by $$\frac{dx}{dt} = \frac{x[n] - x[n-2]}{2T_s}$$then $$s(t)$$ becomes(ignoring the scale factor $$\frac{1}{2T_s}$$) $$s[n] = \frac{(s_q[n] - s_q[n-2])s_i[n] - (s_i[n] - s_i[n-2])s_q[n]}{s_i^2[n] + s_q^2[n]}$$but this is not correct: I don't understand why we need the single sample delay. In general, when do delays are necessary to keep the outputs of digital filters synchronized?

Note that ideally you would approximate the derivative at time instance $$t=nT_s$$ by the following central difference quotient:

$$\frac{dx(nT_s)}{dt}\approx\frac{x[(n+1)T_s]-x[(n-1)T_s]}{2T_s}\tag{1}$$

Since such a system is non-causal - because you would need to know the signal one time step ahead in order to compute the output - you add a delay of one sample, resulting in

$$\frac{dx[(n-1)T_s]}{dt}\approx\frac{x[nT_s]-x[(n-2)T_s]}{2T_s}\tag{2}$$

Consequently, in order to keep the inputs and outputs of the causal differentiator synchronized, you also need to delay the inputs by one sample.

• Thanks. I understand that we approximate derivative at $t = nT_s$ by $\frac{x(nT_s)-x((n-2)T_s)}{2T_s}$ but we need to multiply the input and derivative at $t = nT_s$. So the result should be $x(nT_s) \times \frac{x(nT_s)-x((n-2)T_s)}{2T_s}$. Jul 7 at 12:09
• @S.H.W: I've edited my answer for clarification. The output of the causal differentiator is delayed by one sample, so in order to have the original signal and its derivative in sync, you need to delay the original signal by one sample. Jul 7 at 13:35
• Thanks now I see what you mean. Jul 7 at 13:51