#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
# 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)
# 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)
# 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))
# 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)
# 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))
# 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)
# 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
# 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))
# 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))
# 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)
print("Theoretical example")
print("Theoretical example")
print("Theoretical example")
# 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))
# 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)
# 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))
# 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
# 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.")
# mid band gain and upper 3 db frequency
import math
#Variable declaration
Cpi=40.0 # in pico farad
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
# mid band gain and upper 3 db frequency
import math
#Variable declaration
Cpi=40.0 # 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=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
# mid band gain and upper 3 db frequency
import math
#Variable declaration
Cmu=3.0 # capacitance in pico farad
Cpi=40.0 # 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
# 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))
# 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
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.")
# 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))
# 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)
# 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))
# 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)
# 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))
# Avm,Fh,Fl
import math
#Variable declaration
n=2.0
C=50.0 # in micro farad
Cc=0.1 # in micro farad
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
# Avm,Fh,Fl
import math
#Variable declaration
n=3.0
Cc=0.005 # in micro farad
C=100.0 # in pico farad
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