It seems that no matter how long I teach signal processing, I always learn something new. Last week I thought of an interesting experiment regarding convolution and I was pretty surprised by the results. Consider a first order low pass filter with system response H(s) = wc / (s+wc) [where wc is the cutoff frequency in rads/sec]. The impulse response of this system is h(t) = wc*exp(-wc * t), and the corresponding differential equation is y' + wc*y = wc*x.

Suppose we are interested in using a computer to determine the system output y(t) in response to an input x(t). I reasoned that there are two ways of solving this problem. The first is to apply convolution: x(t) [conv] h(t). The second is to use numerical approximation such as Forward Euler to solve the differential equation. In this case, FE could be used to arrive at y[i] = y[i-1](1-wc*dt) + x[i-1](wc*dt), where "dt" is the timestep.

My big "aha" was the realization that there are two competing methods for numerically solving y(t), and in theory they should both give the same answer. However it seems reasonable that one method should be more "efficient" than the other in that it would work better with a larger value of dt (generally speaking you want to use the largest dt you can get away with to reduce your simulation time).

So I decided to test the two methods against each other. My results for simulating a first order step response are shown here:

I've used a pretty large dt in order to accentuate weaknesses of the two approaches. The input step x(t) is in blue and the true (expected) step response y(t) is in black. The green signal shows the answer as computed via convolution whereas the red signal is the answer as computed using Forward Euler. In this case, you can easily see that that Forward Euler/differential equation approach is much more accurate than the convolution method. Of course, if you make dt get smaller and smaller, eventually, both the green and red signals converge onto the true "black" signal.

So then I decided to repeat this experiment with a second order low underdamped low pass filter. Amazingly, the results were reversed!

In this case, the convolution method was much more accurate at low dts than the Forward Euler method. What's going on here? My suspicion is that it has to do with the complexity of the impulse response, which in this case is rather oscillatory, especially as compared to the first order case. My feeling is that the convolution method is better suited for capturing all those oscillations than the Forward Euler method, which is using an estimate of the derivative to capture those oscillations - I think that estimate becomes less accurate for large dt faster than the corresponding calculation of h(t) used in the convolution.

So I thought all this was really interesting! Based on my observations, I hypothesize that (a) for an overdamped 2nd order system, the Euler method would be more accurate than convolution, and (b) for anything higher than a 2nd order system, the convolution method would be more accurate. I've run out of time to test either of these but let me know if you'd like to give it a try. I'd be happy to post your solutions!

## No comments:

## Post a Comment