hie=1600.
hfe=60.
hre=5*10**-4
hoe=25*10**-6
hic=1600.
hfc=-61.
hrc=1.
hoc=25*10**-6
print "For the second stage ZL = RE2 and the current gain of the second stage is"
RE2=4000.
AI2=-hfc/(1+(hoc*RE2))
print " AI2 = -Ie2 / Ib2 = -hfc / (hoc*RE2) =%0.2f"%AI2
print "For the second stage,"
Ri2 = hic + (hrc*AI2*RE2)
Ri22=Ri2*10**-3
print " Ri2 = hic + (hrc*AI2*RE2) =%0.2f kohm"%Ri22
Re2=4000.
AV2=(AI2*Re2)/Ri2
print " AV2 = Vo/V2 = (AI2*Re2) / Ri2 = %0.2f "%AV2
print "The First Stage :"
RC1=4000.
RL1=(RC1*Ri2)/(RC1+Ri2)
RL11=RL1*10**-3
print " RL1= RC1 || Ri2 =%0.2f kohm"%RL11
print "Current gain,"
AI1= -hfe/(1+(hoe*RL1))
print " AI1 = -IC1/Ib1 = -hfe/(1+(hoe*RL1)) =%0.2f"%AI1
print "The input impedance of the first stage, which is also the input impedance of the cascaded amplifier is"
Ri1=hie +(hre*AI1*RL1) # answer in textbook is wrong
Ri11=Ri1*10**-3
print " Ri1 = hie + hre*AI1*RL1 =%0.2f kohm"%Ri11
print "The voltage gain of the first stage is"
AV1=(AI1*RL1)/Ri1 # answer in textbook is wrong
print " AV1 = V2/V1 = (AI1*RL1) / Ri1 =%0.2f"%AV1
print "The output admittance of the first transistor Q1"
RS=600.
Yo1=hoe-((hfe*hre)/(hie+RS))
Yo0=Yo1*10**6
print " Yo1(uA/V) = hoe - ((hfe*hre) / (hie+RS)) =%0.2f"%Yo0
print "The output impedance of the first stage"
Ro1=1./Yo1
Ro0=Ro1*10**-3
print " Ro1 = 1 / Yo1 =%0.2f kohm"%Ro0
print "The output impedance taking RC1 into account is"
Rot1=(Ro1*RC1)/(Ro1+RC1)
Rott=Rot1*10**-3
print " Rot1(k-ohm) = Ro1 || RC1 =%0.2f kohm"%Rott
print "The output admittance of the second stage"
Yo2=hoc-((hfc*hrc)/(hic+Rot1))
print " Yo2 = hoc-((hfc*hrc) / (hic+Rot1)) =%0.2f A/V"%Yo2
print "Output impedance,"
RO2=1/(11.525*10**-3)
print " RO2 = 1 / Yo2 =%0.2f ohm"%RO2
Ro2=(87.*4000.)/(87+4000)
print "Hence, Ro2(ohm) = (RO2*RE2) / (RO2+RE2) =%0.2f ohm"%Ro2
Rc1=4000.
x=(-Rc1)/ (Rc1+Ri2)
print " Ib2/Ic1 = -Rc1/ Rc1+Ri2 =%0.2f"%x
AI=-AI2*x*AI1
print " AI = -AI2*AI1*(Rc1 / Ri2+Rc1) =%0.2f"%AI
AV=AV2*AV1
print " AV = AV2*AV1 =%0.2f"%AV # answer in textbook is wrong
print "The overall voltage gain taking the source impedance into account,"
AVs=AV*(Ri1/(Ri1+RS))
print " AVs = Vo/Vs = Av(Ri1 / Ri1+Rs) =%0.2f"%AVs # answer in textbook is wrong
from math import pi
hfe=50.
hie=1200.
hoe=30*10**-6
hre=2.5*10**-4
RC=5*10**3
C=160*10**-12
CC=6*10**-6
R1=100*10**3
R2=10*10**3
gm=50*10**-3
Ro=1./hoe
x1=(Ro*10**-3)
print "Ro = 1/hoe =%0.2f kohm"%x1
RB=(R1*R2)/(R1+R2)
x2=RB*10**-3
print "RB = R1 || R2 =%0.2f kohm"%x2
Ri=hie
x3=Ri*10**-3
print "Ri = hie =%0.2f kohm"%x3
R_C=(RC*Ro)/(RC+Ro)
x4=R_C*10**-3
print "RC'' = RC || Ro =%0.2f kohm"%x4
R_i=(RB*Ri)/(RB+Ri)
x6=R_i*10**-3
print "Ri'' = RB || Ri =%0.2f kohm"%x6
R_ci=(R_C*R_i)/(R_C+R_i)
x7=R_ci*10**-3
print "Rci'' = Rc'' || Ri'' =%0.2f kohm"%x7
rbe=hfe/gm
print "rbe = hfe / gm =%0.2f ohm"%rbe
print "(a) Mid-band current gain,"
AIm=(-50*4.35*10**3)/((4.35*10**3)+(1.1*10**3))
print "AIm = (-hfe*R''C) / (RC''+Ri'') =%0.2f"%AIm
print "(b) Mid-band voltage gain,"
AVm=(-50)*((0.87*10**3)/(1.2*10**3))
print "AVm = (-hfe) * (Rcid/hie) =%0.2f"%AVm
print "(c) Lower 3dB frequency,"
fL=1./(2*pi*6*10**-6*(5.45*10**3))
print "fL = 1 / (2*pi*CC*(R_C+R_i)) =%0.2f Hz"%fL
print "Higher 3dB frequency,"
fH=1/(2*pi*C*rbe)
x8=fH*10**-3
print "fH = 1 / (2*pi*C*rbe) =%0.2f kHz"%x8 # answer in textbook is wrong
print "(d) Voltage gain x bandwidth"
y=abs(AVm*fH)
x9=(y*10**-6)
print "|AVmfH| =%0.2f"%x9