# First Differentatior and Integrator

For discrete time series $Y$, first differentiation ($D_i=Y_i-Y_{i+1}$) and integrator ($S_i=Y_i+Y_{i+1}$) can be defined as two highpass and lowpass LTI digital filters. Where, transfer function for the first difference is: $$H(z)=1-z^{-1}$$ and for the first integrator is: $$H(z)=1+z^{-1}$$ These two transfer function corresponds to $\text{Conv}(Y,[1,-1])$ and $\text{Conv}(Y,[1,1])$ for differentiator and integrator, respectively.

I was wondering what the power transfer function of these two filters should be.

I have to add, in terms of implementation in Matlab, I can get $S_i$ and $D_i$ of a white noise by:

Y = randn(1,100); D = diff(Y); S = Y(1:end-1)+Y(2:end);

By filter in Matlab:

S_Filt = filter([1 1],1,Y); D_Filt = filter([1 -1],1,Y);

Or by convolving conv the corresponding windows:  S_Conv = conv(Y,[1 1]); D_Conv = conv(Y,[1 -1]);

Note, all D* and S* variables should be identical (regardless of head and tail of time series, of course).

• Your integrator expression does not seem to really be an integrator to me, as its finite difference equation is $y[n] = x[n] + x[n-1]$. Perhaps you wanted $H(z) = \dfrac{1}{1-z^{-1}}$ which has the finite difference equation $y[n] = y[n-1] + x[n]$? What do you mean by "power transform function"? – Andy Walls Oct 23 '17 at 14:02
• Thanks @AndyWalls. However, when I implement the transfer function you mentioned in Matlab I don't get the S_i. For Y~N(0,1), your transfer function is implemented as filter(1,[1 1],Y) while the S_i is only obtained via filter([1 1],1,Y) which is H(z)=1+z^-1. I meant 'power transfer function' which, apparently, is the absolute (modulus) of the transfer function. – soarfy Oct 23 '17 at 14:30
• Y=randn(1,100); D=diff(Y); S=Y(1:end-1)+Y(2:end); and their equivalent filter is S_Filt=filter([1 1],1,Y); D_Filt=filter([1 -1],1,Y); – soarfy Oct 23 '17 at 14:35
• Perhaps, you should check your expression for integration using the line Y=X as a test case, instead of noise. x=[-4:0.1:4]; y=x; d=diff(y); s = zeros(1,length(y)); s(1)=y(1); for i=[2:length(y)]; s(i)=s(i-1)+y(i); end; plot(x,s);  Generating s like that, gives me a parabola, as expected. – Andy Walls Oct 23 '17 at 14:50

For power transfer function of $1-z^{-1}$ we know: \begin{eqnarray*} 1-z^{-1}&=&1-e^{-jw}\\ &=& 1-\cos(\omega)+j\sin(w) \end{eqnarray*} Then by using complex conjugate properties we have: \begin{eqnarray*} |1-z^{-1}|^2&=&1-2\cos(\omega)+\cos(\omega)^2+\sin(\omega)^2\\ &=&2(1-\cos(\omega)). \end{eqnarray*} And simillarly, for $1+z^{-1}$, we have: \begin{eqnarray*} |1+z^{-1}|^2&=& 1+2\cos(\omega)+\cos(\omega)^2+\sin(\omega)^2\\ &=& 2(1+\cos(\omega)). \end{eqnarray*}
Note that the integrator in this question is a special case (see the expression for $S_i$) and is different than the conventional integrator $y[n]=y[n-1]+x[n]$.