Page 283 - Analog and Digital Filter Design
P. 283
280 Analog and Digital Filter Design
COUE << "Enter ratio wb/wa (>1.0)" << endl;
cin >> ratio;
kk = l.O/ratio;
angle = acos(kk) ;
cout << 'Angle = "<< angle << 'I radians, or "<< angle *57.2958 <<"
(degrees)" c<endl;
k = sin(ang1e);
kay = integrate2 (k) ;
kaydash = in~egrate2 (kk) ;
q = exp-PI + kaydash/ kay);
del = 4.0 * pow(q, (doub1e)n);
cout <<\%q = <> << q << '' Error = I' << del << "radians"<< endl;
rejection = 20.0 * loglO(l.0 / (tan(del/2.0)) );
cout << "Rejection = << rejection << "dB" << endl;
for(i=O; i<n; itc)
{
ui = (double) (4*i + 1) /(double) (2*n) ;
u = ui * kay;
jacobian (u, k) ;
pole = sqrt(ratio) * cn / sn;
cout << "pole = << pole << endl;
1
return (1) ;
i
doilble integrate2 (double kl
{
double knO, knl, kn2, sum;
knO = k;
sum = 1.0;
do
r
knl = sqrt(l.O - (knO * kn0));
kn2 = (1.0 - knl)/(l.O + knl);
sum = sum * (l.O+knZ);
knO = kn2;
}while(knZ > (TOL * TOL));
return(P1 * sum /2.0);
I
void jacobian(doub1e u, double k)
(
extern double sn, cn;
double snn, cnn;
double templ, temp2, temp3, temp4;
double array1 [ARRAY] , array2 [ARRAY] ;
double kc-squared,angle;
int i, j, max-array;
kc-squared = 1.0 - (k * k);
templ = 1.0;
for(i=O; iamY;i++)
max-array = i;
arrayl[il = templ;
array2[il = (kc-squared = sqrt(kc-squared));
temp3 = 0.5 * (templ+kc-squared);
if (fabs(Eempl-kc-squared) <= TOL * templ)
break;
kc-squared = kc-squared * terrpl;
templ = temp3;