Quite often in C code you see something along the lines of:
$$ y = (1-a) y_{prev} + input * a $$
..where $a$ is some small number. This equation then runs in discrete intervals at the loop rate.
Let's assume $a = 0.1$.
If I convert this difference equation into z domain I arrive at the following:
$$ Y(z) = 0.1 / (1 - 0.9 * z^{-1}) = 0.1z/(z - 0.9)$$
This function has a horrific phase response:
If I instead start with a continuous time low pass filter and convert it to difference equation I get a slightly different filter.
$$ H(s) = 1 / (s + 1)$$
I convert it into z domain using bi-linear transform:
$$ H(z) = (0.04762 + 0.04762 z^{-1})/(1 - 0.9048z^{-1}) $$
I then convert this into difference equation:
$$ y_n = 0.04762x_n + 0.04762x_{n-1} + 0.9048 * y_{n-1} $$
The result compared to the "simplistic" filter:
The result of the "proper" C implementation looks much more like a low pass filter than the "simplistic" implementation. The simplistic implementation is more like a lag regulator (I realized this while writing this post so it's almost that I have answered my own question). While the "proper" lpf is more like an analog LPF. Obviously this can negatively impact the performance of the system if the different behaviors are not taken into account. Are there situations when either one is better suited than the other?