# “Improved” MZT/IIM type One pole LPF

Some time ago, while playing with all kind of approximation of common math functions, I came up to this idea to calculate a1 coefficient for a 1st order LPF filter:

$$\begin{array}{l}a1=-(1+x+\frac12x^2),\;where\;\\x\;=\frac1{fT},\;\\f=sampling\;frequecy\;(Hz),\;\\T=time\;constant\;(\mu s)\end{array}$$

so the final filter would be (Octave code):

% --------------------
% OCTAVE PACKAGES
% --------------------
% --------------------

clf

fs=44100;
fc=10000;
fct=1/(2*pi*fc);
fs2 = fs/2;
N=1; % order

% --------------------
% MZT approximated
% --------------------
x = 1.0/(fs*fct);
MZTa0 = 1.0;
MZTa1 = -(1 + x + 0.5 * x^2);
MZTb0 = MZTa0 + MZTa1;
MZTb1 = 0.0;

MZTa = [MZTa0 MZTa1];
MZTb = [MZTb0 MZTb1];

MZT2=tf(MZTb, MZTa, 1/fs);

% --------------------
% Analog model
% --------------------
w0 = 2*pi*fc;
Analogb = 1;
Analoga = [1 w0];
Analog = tf(Analogb, Analoga);
Analog = Analog/dcgain(Analog);

% --------------------
% MZT
% --------------------
p1 = exp(-1.0/(fs*(1/(2 * pi * fc))))
z1 = 0.0;
MZTa0 = 1.0;
MZTa1 = -p1;
MZTb0 = 1.0-p1;
MZTb1 = -z1;

MZTa = [MZTa0 MZTa1];
MZTb = [MZTb0 MZTb1];

MZT=tf(MZTb, MZTa, 1/fs);

% --------------------
% IIM
% --------------------
[IIMb,IIMa]=impinvar(Analogb,Analoga,fs);
IIM=tf(IIMb, IIMa, 1/fs);
IIM=IIM/dcgain(IIM);

% --------------------
% BLT
% --------------------
w0 = 2*pi*(fc/fs);
%BLTb0 =   sin(w0);
%BLTb1 =   sin(w0);
%BLTa0 =   cos(w0) + sin(w0) + 1.0;
%BLTa1 =   sin(w0) - cos(w0) - 1.0;
%
%BLTa = [BLTa0 BLTa1];
%BLTb = [BLTb0 BLTb1];
%
%BLT=tf(BLTb, BLTa, 1/fs);
%BLT=BLT/dcgain(BLT);

BLT = c2d(Analog, 1/fs, 'prewarp', w0);

% --------------------
% Plot
% --------------------

nf = logspace(0, 5, fs2);

figure(1);
% analog model
[mag, pha] = bode(Analog,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'g', 'linewidth', 2);
axis([10 fs2 -30 1]);
hold on;
%semilogx(nf, pha, 'color', 'g', 'linewidth', 2, 'linestyle', '--');

% BLT
[mag, pha] = bode(BLT,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'm', 'linewidth', 1.0, 'linestyle', '-');
%semilogx(nf, pha, 'color', 'm');

% MZT
[mag, pha] = bode(MZT,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'k', 'linewidth', 1.0, 'linestyle', '-');
%semilogx(nf, pha, 'color', 'k', 'linewidth', 1.0, 'linestyle', '--');

% IIM
[mag, pha] = bode(IIM,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'c', 'linewidth', 1.0, 'linestyle', '--');
%semilogx(nf, pha, 'color', 'c', 'linewidth', 1.0, 'linestyle', '--');

% MZT approximated
[mag, pha] = bode(MZT2,2*pi*nf);
semilogx(nf, 20*log10(abs(mag)), 'color', 'r', 'linewidth', 2.0, 'linestyle', '--');
%semilogx(nf, -pha, 'color', 'r', 'linewidth', 2.0, 'linestyle', '--');

grid on;

str=num2str(fs);
str2=num2str(fc);
str3=num2str(N);

str = sprintf("LPF (various TF), order:%s, fs=%s, fc=%s, ",str3, str, str2);
title(str);
legend('Analog', 'BLT', 'MZT', 'IIM', 'MZTapprox', 'location', 'southwest');
xlabel('Hz');ylabel('dB');


By octave plots, frequency response improves a bit when cut-off frequency is closing fs/2: and phase response differs a lot from the original MZT phase response: I've measured (as c/c++ function) this approximation method about 20 times faster than using std::exp function.

Idea used here is to use approximation ($$e^x$$ (exp(x)) using Taylor series (or other approximation methods) in this case) error to cancel the error in MZT/IIM methods ... when higher degree polynomial is used the error decreases and the resulting filter closes the original MZT/IIM responses. See the values for s, c and v, v2: https://www.desmos.com/calculator/s5wftcupmr

Someone, with better math skills than what I have, can easily improve this idea by finding better polynomial with suitable error to better cancel the error in MZT/IIM method.

Any thoughts on possible drawbacks in calculating one pole LP filter this way.

NOTE: There are few well known methods available to improve the MZT/IIM type filters as like these:

and BLT type filters

which all are more complicated and are also more portable. My target is speed (realtime use) and improved responses of one pole LPF.

• I get that IIM means Impulse Invariance Method. What does MZT mean? What are you trying to accomplish? – Ben Mar 27 '19 at 22:58
• it's the Matched Z-transform, @Ben . the most simple. just map the analog poles and zeros to the digital poles and zeros using $z=e^{sT}$. – robert bristow-johnson Mar 28 '19 at 0:02
• You should add this info in your question. – Ben Mar 28 '19 at 12:09