# Chapter 5 : Frequency Response¶

## Example 5.1, Page No. 311¶

In :
#COUPLING CAPACITOR

import math
#Variable declaration
Rs=10.0               # series resistance in killo ohms
Xc1= Rs/10.0          # reactance at 20Hz

#Calcualtions
C1=(1.0/(2*math.pi*20*Xc1*10**3))*10**6     # CAPACITANCE IN MICRO FARAD

#Result
print("Capacitance = %.3f micro Farad.\nAs this is not a standard value will select 10 micro farad"%(math.floor(C1*1000)/1000))
#Answer is slightly different than in book

Capacitance = 7.957 micro Farad.
As this is not a standard value will select 10 micro farad


## Example 5.2, Page No. 311¶

In :
# amplifier gain

import math
#Variable declaration
f=20.0                   # frequency in hertz
Avm=100.0                # mid voltage gain
fl=40.0                  # lower cut off  frequency in hertz
fh=16.0                  # lower cut off  frequency in hertz

#Calcualtions
Avl= (Avm/(math.sqrt(1+(fl/f)**2))) # gain at lower cut off frequency
Avh= (Avm/(math.sqrt(1+(f/fh)**2))) # gain at upper cut off frequency

#Result
print("gain at lower cut off frequency = %.2f"%Avl)
print("gain at upper cut off frequency = %.2f"%Avh)

gain at lower cut off frequency = 44.72
gain at upper cut off frequency = 62.47


## Example 5.3, Page No. 312¶

In :
# amplifier gain

import math
#Variable declaration
f=40.0          # frequency in hertz
Avm=40.0        # mid voltage gain
fl=40.0         # lower cut off  frequency in hertz

#Calculations
Avl= (Avm/(math.sqrt(1+(fl/f)**2))) # gain at lower cut off frequency

#Result
print("gain at lower cut off frequency = %.2f"%Avl)

gain at lower cut off frequency = 28.28


## Example 5.4, Page No. 312¶

In :
# amplifier gain

import math
#Variable declaration
f=50.0               # frequency in hertz
Avm=150/0.707        # mid voltage gain
fh=20.0              # lower cut off  frequency in hertz

#Calculations
Avh= (Avm/(math.sqrt(1+(f/fh)**2))) # gain at upper cut off frequency

#Result
print("gain at upper cut off frequency = %.2f"%(math.floor(Avh*100)/100))

gain at upper cut off frequency = 78.79


## Example 5.5, Page No. 312¶

In :
# maximum voltage gain

import math
#Variable declaration
Avl=100.0               # voltage gain

#Calculations
Avm=Avl/0.707           # MID VOLTAGE GAIN

#Result
print("maximum voltage gain is %.2f"%Avm)

maximum voltage gain is 141.44


## Example 5.6, Page No.319¶

In :
# series capacitance and transfer function

import math
#Variable declaration
f=100.0            # frequency in hertz
fc=25.0            # corner frequency
rs=2.0             # series resistance in killo ohms
rp=4.0             # PARALLEL resistance in killo ohms

#Calculations
Cs= (1/(2*math.pi*fc*(rs+rp)*10**3))*10**6 # series capacitance in micro farad
ts= Cs*10**-6*(rs+rp)*10**3                # time constant
Tf= ((rp/(rs+rp))*((2*math.pi*f*ts)/(math.sqrt(1+(2*math.pi*f*ts)**2)))) # transfer function

#Result
print("series capacitance in micro farad = %.2f"%Cs)
print("transfer function is  %.3f"%(math.floor(Tf*1000)/1000))

series capacitance in micro farad = 1.06
transfer function is  0.646


## Example 5.7, Page No. 321¶

In :
# corner frequency and maximum magnitude asymptote

import math
#Variable declaration
Cp=2.0                # PARALLEL RESISTANCE IN PICO FARAD
rs=2.0                # series resistance in killo ohms
rp=10.0               # PARALLEL resistance in killo ohms

#Calculation
tp= ((rs*rp)/(rs+rp)*10**3*Cp*10**-12)    # time constant
f= (1/(2*math.pi*tp))*10**-6              # corner frequency in mega hertz
Am= rp/(rp+rs)                            # maximum amplitude
Amd= 20*(math.log10(Am))                  # maximum magnitude aymptote is dB

#Result
print("corner frequency = %.2f MHz"%(math.floor(f*100)/100))
print("maximum magnitude asymptote is %.2f dB"%Amd)

corner frequency = 47.74 MHz
maximum magnitude asymptote is -1.58 dB


## Example 5.9, Page No. 330¶

In :
# 3-db frequency and bandwidth

import math
#Variable declaration
Cp=1.0            # PARALLEL capacitance IN PICO FARAD
Cs=2.0            # series capacitance IN micro FARAD
rs=1.0            # series resistance in killo ohms
rp=10.0           # PARALLEL resistance in killo ohms

#Calculations
ts= ((rs+rp)*10**3*Cp*10**-12)         # time constant
tp= ((rs*rp)/(rs+rp)*10**3*Cp*10**-12) # time constant
fl= (1/(2*math.pi*ts))*10**-6          # lower frequency in mega hertz
fl= math.floor(fl*100)/100
fh= round((1/(2*math.pi*tp))*10**-6)   # upper frequency in mega hertz
BW=fh-fl                               # bandwidth in mega hertz
ts= (rs+rp)*10**3*Cp*10**-12           # open circuit time constant
tp= ((rs*rp)/(rs+rp))*10**3*Cp*10**-12 #short time constant
Ts= (rp)/(rs+rp)                       # midband transfer function
Tsdb= 20*(math.log10(Ts))              # midband transfer function in db

#Result
print("(i)  open circuit time constant is %.f * 10^-9"%(ts*10**9))
print("(ii) short circuit time constant is %.f * 10^-12"%(tp*10**12))
print("(iii)lower 3 dB frequency = %.2f MHz"%fl)
print("(iv) upper 3 dB frequency = %f MHz"%fh)
print("(v)  Bandwidth = %.2f MHz"%BW)
print("(vi) midband transfer function in db is %.3f"%Tsdb)
#Short circuit time constant is different in book

(i)  open circuit time constant is 11 * 10^-9
(ii) short circuit time constant is 909 * 10^-12
(iii)lower 3 dB frequency = 14.46 MHz
(iv) upper 3 dB frequency = 175.000000 MHz
(v)  Bandwidth = 160.54 MHz
(vi) midband transfer function in db is -0.828


## Example 5.10, Page No. 331¶

In :
# 3-db frequency and bandwidth

import math
#Variable declaration
Cp=1.0                 # PARALLEL capacitance IN PICO FARAD
Cs=2.0                 # series capacitance IN micro FARAD
rs=1.0                 # series resistance in killo ohms
rp=2.0                 # PARALLEL resistance in killo ohms
ts= ((rs+rp)*10**3*Cs*10**-6)         # time constant
tp= ((rs*rp)/(rs+rp)*Cp*10**-12)      # time constant
tp1 = tp
fl= (1/(2*math.pi*ts))                # lower frequency in  hertz
tp= math.floor(tp*10**14)/10**14
fh= (1/(2*math.pi*tp))                # upper frequency in  hertz
BW=fh-fl                              # bandwidth in  hertz
#ts= ((rs*rp)/(rs+rp))*10**-3*Cs*10**-12          # time constant

#Result
print("Time constant(ts) in second is %.f * 10^-3"%(ts*1000))
print("\nTime constant(tp) in second is %.3f * 10^-12"%(tp1*10**12))
print("\nlower 3 dB frequency = %.f Hz"%fl)
print("\nupper 3 dB frequency = %.2f *10^9 Hz"%(fh*10**-9))
print("\nbandwidth = %.2f*10^9 Hz"%(BW*10**-9))

Time constant(ts) in second is 6 * 10^-3

Time constant(tp) in second is 0.667 * 10^-12

lower 3 dB frequency = 27 Hz

upper 3 dB frequency = 241.14 *10^9 Hz

bandwidth = 241.14*10^9 Hz


## Example 5.11, Page No. 336¶

In :
# low frequecy response

import math
#Variable declaration
Beta=100.0
Rs=1.0           # series resistance in killo ohms
R1=40.0          # resistance in killo ohms
R2=10.0          # resistance in killo ohms
hie=1.1          # in killo ohms
C1=10.0          # capacitance in micro farad
Ce=20.0          # emitter capacitance in micro farad
hic=1100.0       # in ohms
Rl_1=2.0         # resistance in killo ohms
Rl_2=1.8         # load resistance in killo ohms
Rc=4.0           # collector resistance in killo ohms
C2=1.0           # capacitance in micro farad

#Calcualtions
x=(R1*R2)/(R1+R2)
Y=(x*hie)/(x+hie)
Rin= math.floor((Y+Rs)*100)/100
fc=(1/(2*math.pi*Rin*10**3*C1*10**-6))
Rth=(x*Rs)/(x+Rs)*10**3
Rx= (Rth+hic)/(Beta)
R= (Rx*Rl_1*10**3)/(Rx+Rl_1*10**3)
R = math.floor(R*100)/100
fc1=(1/(2*math.floor(math.pi*100)*R*Ce*10**-6/100))
fc2=(1/(2*math.pi*(Rl_2+Rc)*10**3*C2*10**-6))

#Result
print("CUT OFF FREQUENCY OF INPUT RC NETWORK  = %.2f Hz"%fc)
print("CUT OFF FREQUENCY OF BYPASS RC NETWORK = %.2f Hz"%fc1)
print("CUT OFF FREQUENCY OF OUTPUT RC NETWORK = %.2f Hz"%(math.ceil(fc2*100)/100))

CUT OFF FREQUENCY OF INPUT RC NETWORK  = 8.12 Hz
CUT OFF FREQUENCY OF BYPASS RC NETWORK = 404.36 Hz
CUT OFF FREQUENCY OF OUTPUT RC NETWORK = 27.45 Hz


## Example 5.12, Page No.346¶

In :
# corner frequency and maximum GAIN

import math
#Variable declaration
Vcc=10.0              # Colector voltage in volts
Beta= 100.0
Rc=1.0                # Collector resistance in killo ohms
Rs=600.0              # SERIES RESISTANCE IN OHMS
Re=0.2                # in kilo ohms
R1= 50.0              # in kilo ohms
R2= 10.0              # in kilo ohms
Vbe=0.7               # Base to emitter voltage in volts
C1=1.0                # capacitance in micro farad

Vth=Vcc * (R2/(R1+R2))                           # VOLTAGE AT BASE
Rth= (R1*R2)/(R1+R2)
Ib=((Vcc-Vbe)/((Rth+(1+Beta)*Re)*10**3))*10**5   # in micro ampere
Icq= Beta*Ib*10**-3                              # in milli ampere
Vt=26.0                                          # volate at room termprature in milli volts
gm= (Icq/Vt)*10**3                               # transconductance in milli ampere per volts
rpi= (Beta*Vt*10**-3)/(Icq*10**-3)               # resistance
Rb=math.floor(Rth*100)/100                       # base resistance in killo ohms

x=(rpi+(1+Beta)*Re*10**3)
y=(Rs+Rb*10**3)
ts=((x*y)/(x+y))*C1*10**-3                       # in milli second
fl= (1/(2*math.pi*ts*10**-3))                    # corner frequency in hertz
Ri=(x*Rb*10**-3)/(Rb+x*10**-3)
Av= ((gm*10**-3*rpi*Rc*10**3)*Rb*10**3)/((Ri+Rs*10**-3)*10**3*(x*10**-3+Rb)*10**3)

#Result
print(rpi)
print("corner frequency = %.2f Hz"%fl)
print("maximum gain     = %.2f"%Av)

797.70609319
corner frequency = 25.40 Hz
maximum gain     = 4.33


## Example 5.13, Page No. 348¶

In :
print("Theoretical example")

Theoretical example


## Example 5.14, Page No. 349¶

In :
print("Theoretical example")

Theoretical example


## Example 5.15, Page No. 349¶

In :
print("Theoretical example")

Theoretical example


## Example 5.16, Page No. 350¶

In :
# TIME CONSTANTS , MIDBAND VOLTAGE GAIN AND COERNER FREQUENCIES

import math
#Variable declaration
Rl=4.0               # load resistance in killo ohms
Rs=250.0             # SERIES RESISTANCE IN OHMS
rpi= 2.0             # resistance IN KILLO OHMS
Re=0.2               # in kilo ohms
C1=2                 # capacitance in micro farad
Cl=50.0              # capacitance in pico farad
gm= 6.5                            # transconductance in milli ampere per volts

#Calcualtions
ts=(Rs*10**-3+rpi)*10**3*C1*10**-3 # open circuit time constant in milli second
tp=Rl*Cl*10**-3                    # short circuit time constant in micro second
Av= (((gm*10**-3*rpi*10**3*Rl*10**3))/(Rs*10**-3+rpi)*10**3)*10**-5
fl=(1/(2*math.pi*ts*10**-3))       # lower cut off frequency in hertz
fh=(1/(2*math.pi*tp*10**-6))*10**-6#upper cut off frequency in mega hertz

#Result
print("open circuit time constant = %.1f ms"%ts)
print("short circuit time constant= %.1f micro-sec"%tp)
print("maximum gain               = %.2f"%Av)
print("lower cut off frequency    = %.2f Hz"%(math.floor(fl*100)/100))
print("upper cut off frequency    = %.4f Hz"%(math.floor(fh*10000)/10000))

open circuit time constant = 4.5 ms
short circuit time constant= 0.2 micro-sec
maximum gain               = 231.11
lower cut off frequency    = 35.36 Hz
upper cut off frequency    = 0.7957 Hz


## Example 5.17, Page No. 552¶

In :
# frequency response

import math
#Variable declaration
Rg=10.0                     # resistance in mega ohms
Vgs=10.0                    # gate to soure voltage
Igss=10.0                   # current in nano ampere
C1=0.001                    # capacitance in micro farad
Rd=1.8                      # drain resistance in killo ohms
Rl=18.0                     # load resistance in killo ohms
C2=1.0                      # Capacitance in micro farad

#Calculations
x= (Vgs/Igss)*1000.0                       # resistance in mega ohms
Rin= ((Rg*x)/(Rg+x))                       # input resistance in mega ohms
fc= (1/(2*math.pi*Rin*10**6*C1*10**-6))    # input critical frequency of the RC network
fc1=(1/(2*math.pi*(Rd+Rl)*10**3*C2*10**-6))# output critical frequency of the RC network

#Result
print("input critical frequency of the RC network = %.2f Hz"%(math.ceil(fc*100)/100))
print("input critical frequency of the RC network = %.2f Hz"%fc1)

input critical frequency of the RC network = 16.08 Hz
input critical frequency of the RC network = 8.04 Hz


## Example 5.18, Page No. 556¶

In :
# frequency

import math
#Variable declaration
rpi=2.0                                # resistance in killo ohms
Cpi=1.8                                # capacitance in pico farad
Cmu=0.12                               # capacitance in pico farad

#Calculations
fb=(1/(2*math.pi*rpi*10**3*(Cpi+Cmu)*10**-6))# frequency in mega hertz

#Result
print("frequency = %.3f MHz"%(math.floor(fb*1000)/1000))

frequency = 41.446 MHz


## Example 5.19, Page No.558¶

In :
# bandwidth and capacitance

import math
#Variable declaration
Vt=26.0                # voltage in milli volts
ft=500.0               # frequecy in mega hertz
Ic=1.0                 # collector current in mili ampere
Bo=90.0
Cmu=0.2                # capacitance in pico farad

#Calculations
fb=ft/Bo               # frequency in mega hertz
x= ((Ic*10**-3)/(2*math.pi*Vt*10**-3*ft*10**6))*10**12
Cpi= x-Cmu

#Result
print("Bandwidth  = %.2f MHz"%(math.floor(fb*100)/100))
print("Capacitance of the transistor = %.3f pF"%(math.floor(Cpi*1000)/1000))
#Answer for bandwidth is wrong in the book

Bandwidth  = 5.55 MHz
Capacitance of the transistor = 12.042 pF


## Example 5.20, Page No.360¶

In :
# corner frequency

import math
#Variable declaration
Rs=1.0               # series resistance in killo ohms
Rl=3.7               # load resistance in killo ohms
Rc=3.7               # Collector resistance in killo ohms
R1= 200.0            # in kilo ohms
R2= 200.0            # in kilo ohms
Vbe=0.7              # Base to emitter voltage in volts
rpi=2.5              # resistance in killo ohms
Cpi=0.18             # capacitance in pico farad
gm=40.0              # transconductance in milli ampere per volts
C1=4.0                                      # capacitance in pico farad

#Calcualtions
Rb= (R1*R2)/(R1+R2)
y=(Rc*Rl)/(Rc+Rl)
Cmu= Cpi*(1+gm*y)
Cm2=Cmu
z=(Rs*rpi)/(Rs+rpi)
R=(Rb*z)/(Rb+z)
C=Cmu+4
f3db= (1/(2*math.pi*R*10**3*C))*10**6       # 3-dB frequency in mega hertz
f3db1= (1/(2*math.pi*R*10**3*C1))*10**6     # 3-dB frequency in mega hertz

#Result
print("3-dB frequency due to miller effect = %.3f MHz"%f3db)
print("3-dB frequency                      = %.1f MHz"%f3db1)
print("\nDue to miller effect the capacitance gets multiplied by 75,")
print("hence due to miller effect the bandwidth is reduced.")

3-dB frequency due to miller effect = 12.823 MHz
3-dB frequency                      = 56.1 MHz

Due to miller effect the capacitance gets multiplied by 75,
hence due to miller effect the bandwidth is reduced.


## Example 5.21, Page No. 367¶

In :
# mid band gain and upper 3 db frequency

import math
#Variable declaration
Vt=26.0            # voltage in milli volts
Beta=150.0
Icc=1.0            # current in milli ampere
Icq=1.0            # current in milli ampere
Rc=4.7             # collector resistance in killo ohms
Rl=10.0            # load resistance in killo ohms
Cmu=3.0            # capacitance in pico farad
R1= 50.0           # in kilo ohms
R2= 5.0            # in kilo ohms
rs=1.0             # in killo ohms

#Calculations
rpi= ((Beta*Vt)/Icc)*10**-3
gm=(Icq/Vt)*10**3  # transconductance in mili ampere per volt
gm = math.floor(gm*100)/100
Rld= (Rc*Rl)/(Rc+Rl)
Rld = math.floor(Rld*1000)/1000
Cm=round(Cmu*(1+gm*Rld)) #miller capacitance in pico farad
Rb= (R1*R2)/(R1+R2)
Rb = math.floor(Rb*1000)/1000
x=(Rb*rs)/(Rb+rs)
y=(rpi*x)/(rpi+x)
y = math.ceil(y*10**4)/10**4
fh=(1/(2*math.pi*y*10**3*(Cm+Cpi)*10**-12)) # 3-db upper cut off frequency in mega hertz
z=(Rb*rpi)/(Rb+rpi)
Avm=(gm*Rld*z)/(z+rs)

#Result
print("3-db upper cut off frequency = %.3f MHz"%(fh*10**-6))
print("Midband  Gain  = %.2f"%Avm)
#Value of Fh is wrong in the book
#wrong value of gm is used for Avm calculation

3-db upper cut off frequency = 0.570 MHz
Midband  Gain  = 83.28


## Example 5.22, Page No.370¶

In :
# mid band gain and upper 3 db frequency

import math
#Variable declaration
Vt=26.0             # voltage in milli volts
Beta=150.0
Icq=1.0             # current in milli ampere
rs=1.0              # in killo ohms
re=0.5              # in killo ohms
Rc=4.7              # collector resistance in killo ohms
Rl=10.0             # load resistance in killo ohms
Cmu=3.0             # capacitance in pico farad
R1= 50.0            # in kilo ohms
R2= 5.0             # in kilo ohms

#Calcualtions
rpi= ((Beta*Vt)/Icq)*10**-3
gm=(Icq/Vt)*10**3                                 # transconductance in mili ampere per volt
gm = math.floor(gm*100)/100
g=(rs*re)/(rs+re)
m=rpi/(1+Beta)
m = math.floor(m*10000)/10000
tpi= ((m*g)/(m+g))*10**3*Cpi*10**-12
tpi = math.floor(tpi*10**14)/10**14
fh1=(1/(2*math.pi*tpi))/10**6                     # first 3-db upper cut off frequency in mega hertz
fh1 = (math.floor(fh1*1000)/1000)
Rld= (Rc*Rl)/(Rc+Rl)
Rb= (R1*R2)/(R1+R2)
fh2=(1/(2*math.pi*Cmu*10**-8*Rld*10**3))*10**-2   # second 3-db upper cut off frequency in mega hertz
x=(m*re)/(m+re)
Avm=(gm*Rld*x)/(x+rs)

#Result
print("3-db upper cut off frequency       = %.3f MHz"%fh1)
print("second 3-db upper cut off frequency= %.4f MHz"%fh2)
print("Midband Gain                       = %.4f"%Avm)
# Value for fh2 and Avm slightly differs from the book

3-db upper cut off frequency       = 166.156 MHz
second 3-db upper cut off frequency= 16.5927 MHz
Midband Gain                       = 2.9446


## Example 5.23, Page No.375¶

In :
# mid band gain and upper 3 db frequency

import math
#Variable declaration
Cmu=3.0           # capacitance in pico farad
Vt=26.0           # voltage in milli volts
Beta=150.0
Icq=1.0           # current in milli ampere
rs=1.0            # in killo ohms
re=4.7            # in killo ohms
R1= 40.0          # in kilo ohms
R2= 20.0          # in kilo ohms
R3= 27.0          # in kilo ohms
Rc=4.7            # collector resistance in killo ohms
Rl=10.0           # load resistance in killo ohms

#Calculations
rpi= ((Beta*Vt)/Icq)*10**-3
gm=(Icq/Vt)*10**3                    # transconductance in mili ampere per volt
gm = math.floor(gm*100)/100
Rb=(R2*R3)/(R2+R3)
g=(rs*rpi)/(rs+rpi)
tp1=(((Rb*g)*(Cpi+2*Cmu))/(Rb+g))*10**-9
m=rpi/(1+Beta)
tp2= m*(Cmu+Cpi)*10**-9
Rld= (Rc*Rl)/(Rc+Rl)
tp3=Cmu*10**-12*Rld*10**3
fh1=(1/(2*math.pi*tp1*10**6))         # first 3-db upper cut off frequency in mega hertz
fh2=(1/(2*math.pi*tp2*10**6))         # second 3-db upper cut off frequency in mega hertz
fh3=(1/(2*math.pi*tp3*10**6))        # third 3-db upper cut off frequency in mega hertz
Avm= -gm*Rld*(rpi/(rpi+1))

#Result
print("3-db upper cut off frequency        = %.3f MHz"%fh1)
print("second 3-db upper cut off frequency = %.2f MHz"%fh2)
print("third 3-db upper cut off frequency  = %.3f MHz"%fh3)
print("Midband Gain                        = %.2f"%Avm)
# Value for fh2 and fh3 slightly differs from the book

3-db upper cut off frequency        = 4.648 MHz
second 3-db upper cut off frequency = 143.31 MHz
third 3-db upper cut off frequency  = 16.593 MHz
Midband Gain                        = -97.87


## Example 5.24, Page No.383¶

In :
# corner frequency and bandwidth

import math
#Variable declaration
tr=16.0         # rise time in micro second
V=100.0         # voltage in milli volts
Vd=90.0         # voltage in milli volts
f=5.0           # frequecny in killo hertz

#Calculations
fh= (0.35/(tr*10**-6))*10**-3   # upper cut off frequency in killo hertz
P= ((V-Vd)/V)*100
fl=(P*10**3*f)/(100*math.pi)     # lower cut off frequency in hertz
BW=(fh*10**3-fl)*10**-3          # bandwith in killo hertz

#Result
print("upper cut off frequency = %.3f kHz"%fh)
print("lower cut off frequency = %.2f Hz"%fl)
print("Bandwidth               = %.3f kHz"%(math.floor(BW*1000)/1000))

upper cut off frequency = 21.875 kHz
lower cut off frequency = 159.15 Hz
Bandwidth               = 21.715 kHz


## Example 5.25, Page No.384¶

In :
# PERCENTAGE TILT

import math
#Variable declaration
Rc=4.0                # RESISTANCE IN KILLO OHMS
Rl=2.0                # RESISTANCE IN KILLO OHMS
C=10.0                # capacitance in micro farad
f=200.0               # frequency in hertz

#Calculations
R1=Rc+Rl
fl=(1/(2*math.pi*R1*10**3*C*10**-6))# LOWER CUT -OFF FREQUENCY
P = (math.pi*fl*100)/f              # % tilt

#Result
print("percentage tilt = %.1f%%"%(math.floor(P*10)/10))

percentage tilt = 4.1%


## Example 5.26, Page No. 385¶

In :
# PERCENTAGE TILT

import math
#Variable declaration
Rc=2.0                    # RESISTANCE IN KILLO OHMS
Rl=10.0                   # RESISTANCE IN KILLO OHMS
C=10.0                    # capacitance in micro farad
f=100.0                   # frequency in hertz
p1=0.02

#Calculations
R1=Rc+Rl
fl=(1/(2*math.pi*R1*10**3*C*10**-6))#LOWER CUT -OFF FREQUENCY
fl= math.floor(fl*100)/100
P= (math.floor(math.pi*100)*fl)/(f*100)
f=(math.floor(math.pi*100)*fl)/(p1*100)

#Result
print("percentage tilt = %.3f%%"%(P*100))
print("Lowest value of f for P= 2%%, will be= %.2f Hz"%f)
print("\nConclusion:\nAs the input frequency increases the %% tilt decreases.")

percentage tilt = 4.145%
Lowest value of f for P= 2%, will be= 207.24 Hz

Conclusion:
As the input frequency increases the %% tilt decreases.


## Example 5.27, Page No. 389¶

In :
# fh,fl and bandwidth

import math
#Variable declaration
fln=25.0                # in hertz
fhn=16.0                # in kelo hertz
n=3.0

#Calcualtions
x=math.sqrt(2**(1/n)-1)
fl=x*fln                # lower cut off frequency in hertz
fh=fhn/x                # upper cut off frequency in hertz
BW=(fh*10**3)-fl        # bandwidth

#Result
print("lower cut off frequency = %.2f Hz"%(math.floor(fl*100)/100))
print("upper cut off frequency = %.2f kHz"%fh)
print("Bandwidth               = %.2f kHz"%(BW/1000))

lower cut off frequency = 12.74 Hz
upper cut off frequency = 31.38 kHz
Bandwidth               = 31.37 kHz


## Example 5.28, Page No. 390¶

In :
# bandwidth

import math
#Variable declaration
fl=40.0              # in hertz
fh=20.0              # in kelo hertz
n=4.0

#Calculations
x=math.sqrt(2**(1/n)-1)
fhn=x*fh             # lower cut off frequency in hertz
fln=fl/x             # upper cut off frequency in hertz
BW=fhn-fln*10**-3    # bandwidth

#Result
print("lower cut off frequency = %.2f Hz"%(math.floor(fln*100)/100))
print("upper cut off frequency = %.1f kHz"%fhn)
print("Bandwidth               = %.1f kHz"%BW)

lower cut off frequency = 91.95 Hz
upper cut off frequency = 8.7 kHz
Bandwidth               = 8.6 kHz


## Example 5.29, Page No. 390¶

In :
# cut off frequencies

import math
#Variable declaration
fln = 20           # in Hz
fhn=100.0          # in kelo hertz
n=3.0

#Calculations
x=math.sqrt(2**(1/n)-1)
fl=fln*x           # lower cut off frequency in hertz
fh=fhn/x           # upper cut off frequency in hertz

#Result
print("lower cut off frequency = %.2f Hz"%(math.floor(fl*100)/100))
print("upper cut off frequency = %.2f KHz"%(math.floor(fh*100)/100))

lower cut off frequency = 10.19 Hz
upper cut off frequency = 196.14 KHz


## Example 5.30, Page No. 391¶

In :
# Avm,Fh,Cc

import math
#Variable declaration
mu=70.0
rd=44.0            # resistance in killo ohms
Rd2=50.0           # resistance in killo ohms
Rg=1.0             # gate resisatnce in mega ohms
Csh=200            # capacitance in pico farad
fl=50.0

#Calculations
gm= mu/(rd)                                      # transconductane in milli ampere per volt
gm = math.ceil(gm*10)/10
x=(rd*Rd2)/(rd+Rd2)
x = math.floor(x*10)/10
Av2m= gm*x                                       # mid frequency gain of second stage
y= (x*Rg*10**3)/(x+Rg*10**3)
Av1m= -gm*y                                      # mid frequency gain of first stage
Av= Av1m*Av2m                                    # total gain
Req=y
fh=(1/(2*math.pi*Req*10**3*Csh*10**-9))          # upper cut off frequency in killo hertz
Ro1=x
Cc=(1/(2*math.pi*fl*(Ro1*10**3+Rg*10**6)))*10**9 # coupling capacitance in nano farad

#Result
print(x)
print("mid frequency gain of second stage = %.2f"%Av2m)
print("upper cut off frequency            = %.2f kHz"%(math.ceil(fh*100)/100))
print("coupling capacitance               = %.2f nF"%Cc)

23.4
mid frequency gain of second stage = 37.44
upper cut off frequency            = 34.81 kHz
coupling capacitance               = 3.11 nF


## Example 5.31, Page No. 392¶

In :
# gain

import math
#Variable declaration
gm= 10.0                     # transconductane in milli ampere per volt
Csh=20.0                     # capacitance in pico farad
BW=10.0                      # bandwidth in mega hertz
fhn=10.0                     # in mega hertz
n=2.0

#Calculations
x=math.sqrt(2**(1/n)-1)
fh=fhn/x                               # lower cut off frequency in mega hertz
R=(1/(2*math.pi*Csh*10**-12*fh*10**6)) # resiatnce in ohms
Av1=-gm*R*10**-3                       # mid frequency gain of first stage
Av2=Av1                                # mid frequency gain of second stage
Av= Av1*Av2                            # total gain
Avdb=20*(math.log10(Av))                    # total gain dB

#Result
print("Total gain = %.2f dB"%(math.floor(Avdb*100)/100))

Total gain = 28.37 dB


## Example 5.32, Page No. 393¶

In :
# Avm,Fh,Fl

import math
#Variable declaration
n=2.0
rd=50.0              # resistance
Rs=1.0               # series resistance in killo ohmstance in killo ohms
gm= 2.0              # transconductane in milli ampere per volt
Rd=10.0              # resistance in killo ohms
Csh=10.0             # capacitance in pico farad

#Calculations
x=(rd*Rd)/(rd+Rd)

Rg=1.0                                 # gate resisatnce in mega ohms
y= (x*Rg*10**3)/(x+Rg*10**3)
Avm= -gm*y                             # mid frequency gain of first stage
Av2m= -gm*y                            # mid frequency gain of second stage
Avm = math.ceil(Avm*100)/100
Av= Avm*Av2m                           # total gain
Avdb=20*(math.log10(Av))
Req=y
fh=(1/(2*math.pi*Req*10**3*Csh*10**-6))# upper cut off frequency in mega hertz
Ro1=y
fl=(1/(2*math.pi*Cc*10**-6*Ro1*10**3)) # lower cut off frequency in hertz
x=math.sqrt(2**(1/n)-1)
fhn=x*fh                               # lower cut off frequency in hertz
fln=fl/x                               # upper cut off frequency in hertz

#Result
print("Total voltage gain           = %.2f dB"%(math.floor(Avdb*100)/100))
print("lower cut off frequency      = %.2f Hz"%fl)
print("upper cut off frequency      = %.4f MHz"%fh)
print("3dB lower cut off frequency  = %.2f Hz"%fln)
print("3dB upper cut off frequency  = %.2f MHz"%fhn)
# Values are slightly different than that of book

Total voltage gain           = 48.72 dB
lower cut off frequency      = 192.58 Hz
upper cut off frequency      = 1.9258 MHz
3dB lower cut off frequency  = 299.22 Hz
3dB upper cut off frequency  = 1.24 MHz


## Example 5.33, Page No.393¶

In :
# Avm,Fh,Fl

import math
#Variable declaration
n=3.0
rd=7.7
Rs=1.0                 # series resistance in killo ohmstance in killo ohms
gm= 25.0               # transconductane in milli ampere per volt
Rd=10.0                # resistance in killo ohms
Rg=1.0                 # gate resisatnce in mega ohms
Csh=100.0              # capacitance in pico farad

#Calculations
x=(rd*Rd)/(rd+Rd)
Av2m= -gm*x                                       # mid frequency gain of second stage
y= (x*Rg*10**3)/(x+Rg*10**3)
Avm= -gm*y                                        # mid frequency gain of first stage
Av= Avm*Avm*Avm                                   # total gain
Avdb=20*(math.log10(-Av))
Req=y
fh=(1/(2*math.pi*Req*10**3*Csh*10**-9))           # upper cut off frequency in killo hertz
Ro1=y
fl=(1/(2*math.pi*Cc*10**-6*(Ro1*10**3+Rg*10**6))) # lower cut off frequency in hertz
x=math.sqrt(2**(1/n)-1)
fhn=x*fh                                          # lower cut off frequency in hertz
fln=fl/x                                          # upper cut off frequency in hertz

#Result
print("Total voltage gain          = %.f dB"%math.ceil(Avdb))
print("lower cut off frequency     = %.3f Hz"%(math.floor(fl*1000)/1000))
print("upper cut off frequency     = %.2f kHz"%fh)
print("3dB lower cut off frequency = %.3f Hz"%(math.floor(fln*1000)/1000))
print("3dB upper cut off frequency = %.1f kHz"%fhn)
# Some values are slightly different than that of book

Total voltage gain          = 123 dB
lower cut off frequency     = 31.693 Hz
upper cut off frequency     = 367.44 kHz
3dB lower cut off frequency = 62.165 Hz
3dB upper cut off frequency = 187.3 kHz