0010*************************************************************
0020 PRINT:"*:*:* SYMMETRICAL ELLIPTIC FILTERS *:*:*"
1000*************************************************************
1010 DOUBLE PRECISION B(16),C(16),D(16),E(15),F(30),W,X,Y,Z
1020 DBN=.23025851;PI=3.1415927
2000*------------------------------------------------------------
2010 20 PRINT:"STOPBAND EDGE (KHZ) ?";READ:FS
2020 PRINT:"PASSBAND EDGE (KHZ) ?";READ:FP
2030 IF(ABS(FS-FP).LE.0)GO TO 20
2040 21 PRINT:"NUMBER OF PEAKS (1-15) ?";READ:N
2050 IF(N.LE.0)GO TO 20
2060 M=2*N+1
2070*
2080 FC=SQRT(FS*FP)
2090 R=FC+FC
2100 DO 24 K=1,2
2110 S=FS+FP
2120 DO 22 J=1,6
2130 P=SQRT(S*R)
2140 S=(S+R)/2
2150 IF(1.E08*(S-P).LT.S)GO TO 23
2160 22 R=P
2170 23 IF(K.GE.2)GO TO 25
2180 Q=M/S
2190 24 R=ABS(FS-FP)
2200 25 Q=Q*S
2210 S=EXP(-PI/Q)
2220 Y=DBLE(S)
2230 PRINT:"CRITICAL Q",Q/(4*(1-S)*S**N)
2240*
2250 PRINT:"STOPBAND REJECTION (DB) ?";READ:S
2260 IF(S.LE.0)GO TO 20
2270 S=EXP(S*DBN/2)
2280 R=EXP(PI*Q)
2290 P=(ALOG(1+(S*S-1)/(R/4+1/R)**2))/DBN
2300 PRINT:"PASSBAND RIPPLE (DB)",P
2310 R=R/(2*(S+SQRT(S*S-1)))
2320 R=ALOG(R+SQRT(R*R+1))/(2*Q)
2330 R=SIN(R)/COS(R)
2340 W=DBLE(R)
2350 PRINT:"3 DB ABOUT (KHZ)",FP+(FS-FP)/(1+FC/(FP*R*R))
2360 PRINT:"NOMINAL RESISTANCE (OHM) ?";READ:R
2370 IF(R.LE.0)GO TO 21
2380*
2390 Z=Y;E(N)=W;W=W*W
2400 DO 26 J=1,M-1
2410 26 F(J)=1
2420 K=1
2430 DO 28 J=1,1024
2440 F(K)=F(K)*(1-Z)/(1+Z)
2450 IF(K.LT.M-1)GO TO 27
2460 Z=Z*Y
2470 X=((1-Z)/(1+Z))**2
2480 E(N)=E(N)*(W+X)/(1+W*X)
2490 K=0
2500 27 Z=Z*Y
2510 IF(Z.LT..25D-18)GO TO 29
2520 28 K=K+1
2530 29 DO 30 J=1,N
2540 F(J)=F(J)*F(M-J)
2550 30 F(M-J)=F(J)
3000*------------------------------------------------------------
3010 DO 31 J=1,N
3020 D(J)=F(2*J)*(1-F(J)**4)/F(J)
3030 31 B(J)=E(N)*F(J)
3040 C(1)=1/B(N)
3050 DO 32 J=1,N-1
3060 C(J+1)=(C(J)-B(N-J))/(1+C(J)*B(N-J))
3070 32 E(N-J)=E(N+1-J)+E(N)*D(J)/(1+B(J)*B(J))
4000*------------------------------------------------------------
4010 DO 40 J=1,N
4020 B(J)=((1+C(J)*C(J))*E(J)/D(J)-C(J)/F(J))/2
4030 C(J)=C(J)*F(J)
4040 40 D(J)=F(J)*F(J)
4050 B(N+1)=B(N);C(N+1)=C(N);D(N+1)=D(N)
5000*------------------------------------------------------------
5010 IF(N.EQ.1)GO TO 60
5020 DO 50 L=1,2
5030 DO 50 K=L+2,N+1,2
5040 DO 50 J=L,K-2,2
5050 Y=C(J)-C(K)
5060 Z=1/(Y/(B(J)*(D(K)-D(J)))-1)
5070 B(K)=(B(K)-B(J))*Z*Z-B(J)*(1+Z+Z)
5080 50 C(K)=Y*Z
6000*------------------------------------------------------------
6010 S=SNGL(B(N)/B(N+1)-1)
6020 60 Q=.0005/(PI*FC)
6030 P=Q*R;Q=Q/R
6040 IF(FS.LT.FP)GO TO 62
6050*
6060 PRINT:"               *:* LOW-PASS FILTER *:*"
6070 DO 61 J=1,N
6080 C(J)=Q*C(J)
6090 D(J)=Q*B(J)*D(J)
6100 B(J)=P/B(J)
6110 61 F(J)=FC/F(J)
6120 C(N+1)=Q*C(N+1)
6130 GO TO 64
6140*
6150 62 PRINT:"               *:* HIGH-PASS FILTER *:*"
6160 DO 63 J=1,N
6170 C(J)=Q/C(J)
6180 D(J)=Q/(B(J)*D(J))
6190 B(J)=P*B(J)
6200 63 F(J)=FC*F(J)
6210 C(N+1)=Q/C(N+1)
6220*
6230 64 PRINT:"   KILOHERTZ              FARAD            HENRY"
6240 DO 65 J=1,N,2
6250 PRINT 71,C(J)
6260 65 PRINT 72,F(J),J,D(J),B(J)
6270 PRINT 71,C(N+1)
6280 IF(N.EQ.1)GO TO 70
6290 L=((N+1)/2)*2;K=M-1-L
6300 DO 66 J=L+2,M-1,2
6310 PRINT 72,F(K),K,D(K),B(K)
6320 PRINT 71,C(K)
6330 66 K=K-2
6340 PRINT:"PRECISION TEST:",S
7000*------------------------------------------------------------
7010 70 PRINT:"END (1) OR REPEAT (0) ?";READ:N
7020 IF(N.NE.1)GO TO 20;STOP
7030 71 FORMAT(20X,D17.8)
7040 72 FORMAT(1X,D15.8,I4,2D17.8)
