# Approaching the response of an RC circuit via y=ifft(fft(x)fft(h)). Why is this valid?

Some textbooks like (Numerical recipes the art of scientific computing) derive the DFT as a Riemann sum of the CTFT. With this in mind it would be natural then to approximate the identity $$y(t)=x*h=\mathcal{F}^{-1}\big\{XH\big\}$$

with the mathlab code y=ifft(fft(x).*fft(h)) which roughly means that my response is the inverse DFT of the product of the DFTs.

I have been reading recently that this approach isn't really valid in the case of the DFT. The relevant identity in the discrete realm is $$\mathcal{F}^{-1}(XH)_{n}=\sum_{l=0}^{N-1} x_l (y_N)_{n-l}$$ which is called a circular convolution.

But so far, my ifft(fft...) approach yields results that are completely compatible with the analytical results.

I also want to mention that I have checked for the well-known result that convolving with a shifted impulse, shifts your response along the domain; and the result that scaling an impulse, scales the response.

I've implemented impulses by inputting the coefficient in the dirac-delta function in some position on a vector, without really justifying why this works.

So therefore I have two questions:

Why is the y=ifft(fft(x).*fft(h)) approach valid and compatible with the theory? Is this the way its supposed to be? How can I justify such a thing? Why aren't the step factors $dt$ involved in this approach?

Why are impulses correctly modeled by only inputting the coefficient that would correspond to the dirac-delta function? (This seems intuitive to me, but I wouldn't like to say my opinion as I would prefer to listen to you mostly).

Thanks!

Edit: This is the problem I am working on

Using MATLAB, I've been told to use the convolution theorem to find the response of an RC circuit given a signal $x(t)=\displaystyle \sum_i \delta(t-t_i)$ and $x(t) = \cos(t)$ (and other similar ones like $x(t)=e^{-t}\cos(t)$, but this isn't important).

The purpose of this exercise is not to solve things analytically, but to use MATLAB. I specifically want to do this with the fft and ifft functions in MATLAB.

The way I'm proceeding is by writing something like:

 t=(-5:.01:5);

x=[zeros(1,500) 1 zeros(1,500)];

h=heaviside(t).*exp(-t);

plot(t,ifft(fft(h).*fft(x)));


Which works perfectly fine. If I want to analyse $x(t)=\cos(t)$

I just modify my code the following way:

t=(-5:.01:5);

x=cos(t);

h=heaviside(t).*exp(-t);

plot(t,.01*ifft(fft(h).*fft(x)));


which again, works fine.

I'll repeat my questions for the purpose of clarity:

Why is this valid? This convolution identity isnt valid in the discrete case. Also, the interval $(-5,5)$ is not at all similar to $(-\infty,\infty)$ so my Riemann approximation should suck (for the cosine case), but it doesn't.

Can anyone explain why using the step only in front of theifft is what works here? Namely why shouldn't I be doing 01*ifft(.01*fft(h).*fft(x)*.01) which seems more in line with the expression of the CTFT.

• Check out this answer, it might at least partially answer your question. – Matt L. Nov 7 '15 at 16:01
• I've noticed I don't have to use the step $dt$ in calculating responses to impulses. But in the case of an cosine signal, I do have to use it in order to have sensible result. Any ideas as to why this might happen? – DLV Nov 7 '15 at 16:11
• Could you edit your question and describe in detail the example you've been working on? Concerning the impulse as an input signal, note that you can't sample a continuous-time (Dirac) impulse, and of course there's no step $\Delta t$ if the function extends over an interval of size zero (as is the case for an ideal impulse). – Matt L. Nov 7 '15 at 17:54
• Sure I'll edit my question in just a second. – DLV Nov 7 '15 at 17:57
• I've edited my question @MattL. If something is unclear please don't hesitate to tell me. – DLV Nov 7 '15 at 18:15