# what is the theory behind Butter function?

I want to understand why this code used tan and cos ?

function [ b, a ] = butterTwoBp( dt, fl, fu )
q=pi*dt*(fu-fl);
r=pi*dt*(fu+fl);
N = (tan(q)^2) + sqrt(2)*tan(q) + 1;
M = (tan(q)^2) / N; %M after N because it depends on N
O = -cos(r) * (2*sqrt(2)*tan(q) + 4) / ((cos(q))*N);
P = (-2*(tan(q)^2) + ((  (2*cos(r))   /  (cos(q))   )^2) + 2 )  /   N;
Q = cos(r)*(2*sqrt(2)*tan(q) - 4)/(cos(q)*N);
R = (   (tan(q)^2) - sqrt(2)*tan(q) + 1   )  /  N;

b=[M 0 -2*M 0 M];
a=[1 O P Q R];

• For the $\cos$ or $\tan$ substitutions, check the bottom of Audio EQ Cookbook by Robert Bristow-Johnson Sep 9 '19 at 16:05
• Many thanks Laurent Duval for your comment. Indeed I need to understand the general benefit from using tan and cos in [a,b] generation as preparation step for the FILTER function in matlab since this function used for transform the discrete signal into z-domain. Sep 10 '19 at 19:40
• @LaurentDuval: You're right about the bilinear transform, but there's no two-pass filtering going on, just an ordinary 4th order Butterworth band pass filter. Sep 11 '19 at 13:33
• Yes, I checked afterward the result was not symmetric. I'll update my comment this week-end Sep 11 '19 at 22:29

The trigonometric functions enter the calculation because of the use the bilinear transform for transforming an analog filter to a discrete-time filter. The bilinear transform warps the frequencies of the analog filter, that's why we have to pre-warp the frequencies of the analog filter in order to obtain the desired cut-off frequencies of the discrete-time filter.

The frequency warping of the bilinear transform is described by the following equation:

$$\Omega=\tan\left(\frac{\omega}{2}\right)\tag{1}$$

where $$\Omega$$ is the frequency (in radians) in the analog domain, and $$\omega$$ is the normalized frequency (in radians) in the discrete-time domain. Eq. $$(1)$$ is used to pre-warp the specified frequencies to obtain the edge frequencies for designing the analog prototype filter. After applying the bilinear transform to that analog prototype, the resulting discrete-time filter will have the correct edge frequencies.

The design procedure is as follows:

1. Pre-warp the given edge frequencies according to $$(1)$$.
2. Design an analog band pass filter with the pre-warped edge frequencies by applying a frequency transformation to a low pass prototype filter.
3. Apply the bilinear transform to the analog band pass filter to obtain the desired discrete-time filter.