from __future__ import division
from math import log10
#Given data
Av1 = 60 # voltage gain of first stage
Av2 = 100 # voltage gain of second stage
Av3 = 160 # voltage gain of third stage
Av= Av1*Av2*Av3 # overall voltage gain
Av_indB= 20*log10(Av) # overall voltage gain in dB
print "The overall voltage gain of the amplifier = %0.3f dB " %Av_indB
#Given data
Av = 80 # overall voltage gain in dB
Av2 = 20*log10(150) # voltage gain of second stage in dB
Av1= Av-Av2 #voltage gain of first stage in dB
print "The voltage gain of first stage = %0.2f dB " %Av1
#Given data
Av1 = -60 # voltage gain of first stage
R_C = 500 # in ohm
Rin = 1 # in k ohm
Rin = Rin * 10**3 # in ohm
h_fe = 50 # unit less
Av2 = -h_fe*(R_C/Rin) # voltage gain of second stage
Av = Av1*Av2 # overall voltage gain stage
print "The overall voltage gain = %0.f" %Av
#Given data
R11 = 4 # in k ohm
R21 = 20 # in k ohm
h_ie = 1.1 # in k ohm
R_C1=4 # in k ohm
R22= 10 # in k ohm
R12= 2 # in k ohm
Zb = h_ie # in k ohm
Zin = (R11*R21*Zb)/( (R11*R21)+(R21*Zb)+(Zb*R11) ) # in k ohm
print "The input impedance = %0.3f k ohm " %Zin
h_oe = 0 # unit less
R_C2 = 2 # in k ohm
# Zout= 1/h_oe || R_C2 = R_C2
Zout = R_C2 # in k ohm
print "The output impedance = %0.f k ohm " %Zout
h_fe = 50 # unit less
R_L = 10 # in k ohm
Av2= -h_fe/h_ie*(R_C2*R_L/(R_C2+R_L)) # voltage gain of second stage
Rac1= 1/(1/R_C1+1/R22+1/R12+1/h_ie) # in k ohm
Av1= -h_fe/h_ie*Rac1 # voltage gain of first stage
Av= Av1*Av2 # overall voltage gain
print "The overall voltage gain = %0.f " %Av
#Given data
R1 = 10 # in k ohm
R2 = 5 # in k ohm
Zb = 1 # in k ohm
Zin = (R1*R2*Zb)/( (R1*R2)+(R2*Zb)+(Zb*R1) ) # in k ohm
print "The input impedance = %0.3f k ohm " %Zin
R_C1 = 2 # in k ohm
R_E1 = 2 # in k ohm
R_C2 = 2 # in k ohm
R_E2 = 2 # in k ohm
h_oe = 0 # unit less
#Zout= 1/h_oe || R_C2
Zout = R_C2 # in k ohm
print "The output impedance = %0.f k ohm " %Zout
h_fe = 100 # unit less
h_ie = 1 # in k ohm
R_ac=0.222 # in k ohm
Av2= -h_fe/h_ie*R_C2 # voltage gain of second stage
Rac1= 1/(1/R_C1+1/R1+1/R2+1/h_ie) # in k ohm
Av1= -h_fe/h_ie*R_ac # voltage gain of first stage
Av= Av1*Av2 # overall voltage gain
print "The overall voltage gain = %0.f " %Av
from math import sqrt
#Given data
Z_L = 16 # in ohm
Z_desh_L = 10 # in k ohm
Z_desh_L = Z_desh_L* 10**3 # in ohm
# a = N1/N2 = sqrt( ZdasL/Z_L )
a = sqrt( Z_desh_L/Z_L ) # ratio of primary to secondary turns of step-down transformer
print "The transformer turm ratio = %0.f " %a
#Given data
Z_L = 10 # in ohm
Z_desh_L = 1 # in k ohm
Z_desh_L = Z_desh_L * 10**3 # in ohm
Zs = Z_desh_L # in ohm
# a = N1/N2 = sqrt(Z_desh_L/Z_L)
a = sqrt(Z_desh_L/Z_L) #turn ratio of the transformer
print "The turn ratio of the transformer = %0.f " %a
#Given data
Z_L = 25 # in ohm
Z_S = 10 # in k ohm
Z_S = Z_S * 10**3 # in k ohm
# Z_S = (a**2)*Z_L
a = sqrt(Z_S/Z_L) #turn ratio of the transformer
print "The transformer turn ratio = %0.f " %a
#V2 = V1/a = Vs/a
Vs = 8 # in V
V2 = Vs/a # in V
V_L =V2 # in V
print "The load voltage = %0.1f V " %V_L
from numpy import pi
#Given data
V_CC = 12 # in V
r_e = 25 # in mV
r_e = r_e * 10**-3 # in V
R1 = 1.2 # in Mohm
R1 = R1 * 10**6 # in ohm
R3 = 1.2 # in Mohm
R3 = R3 * 10**6 # in ohm
R4 = 8 # in k ohm
R4 = R4 * 10**3 # in ohm
R5 = 24 # in k ohm
R5 = R5 * 10**3 # in ohm
Beta1 = 100 # unit less
Beta2 = 100 # unit less
I_B2 = V_CC/R3 # in A
I_C2 = Beta2*I_B2 # in A
I_E2 = I_C2 # in A
r_e2 = r_e/I_E2 # in ohm
Rac2 = (R4*R5)/(R4+R5) # in ohm
Av2 = -(Rac2/r_e2) #voltage gain of second stage
print "The voltage gain of second stage = %0.f " %Av2
Rac1 = (R3*(Beta2*r_e2))/(R3+(Beta2*r_e2)) # in ohm
L = 1 # in H
f = 4 # in kHz
f = f * 10**3 # in Hz
X_L = 2*pi*f*L # in ohm
r_e1 = r_e2 # in ohm
Av1 = round(-Rac1/r_e1 ) # voltage gain of first stage
print "The voltage gain of first stage at 4 kHz = %0.f " %Av1
Av = Av1*Av2 # overall voltage gain
Av = 20*log10(Av) # in dB
print "The overall voltage gain = %0.1f dB " %Av
#Given data
V_CC = 25 # in V
R1 = 180 # in k ohm
R1 = R1*10**3 # in ohm
R2 = 20 # in k ohm
R2 = R2 * 10**3 # in ohm
R_C2 = 20 # in k ohm
R_C2 = R_C2 * 10**3 # in ohm
R_C1 = R_C2 # in ohm
R_E1 = 1.8 # in k ohm
R_E1 = R_E1 * 10**3 # in ohm
R_E2 = 4.3 # in k ohm
R_E2 = R_E2 * 10**3 # in ohm
R_L = 30 # in k ohm
R_L = R_L * 10**3 # in ohm
V_BE = 0.7 # in V
Beta2 = 50 # unit less
Beta1 = 50 # unit less
V_Th1 = (V_CC/(R1+R2))*R2 # in V
R_Th1 = (R1*R2)/(R1+R2) # in ohm
I_B = (V_Th1-V_BE)/( R_Th1+((Beta1+1)*R_E1) ) # in A
I_E1 = (Beta1+1)*I_B # in A
V_T = 25 # in mV
V_T = V_T * 10**-3 # in V
r_e1 = V_T/I_E1 # in ohm
I_C1 = I_E1 # in A
V_C1 = V_CC-(I_C1*R_C1) # in V
#V_E2 = V_B2-V_BE = V_C1-V_BE # in V
V_E2 = V_C1-V_BE # in V
I_E2 = V_E2/R_E2 # in A
r_e2 = V_T/I_E2 # in ohm
Rac2 = (R_C1*R_L)/(R_C1+R_L) # in ohm
Av2 = -Rac2/(r_e2+R_E2) # voltage gain of second stage
Rac1 = (R_C1*(Beta1*(r_e2+R_E2)))/(R_C1+(Beta1*(r_e2+R_E2))) # in ohm
Av1 = -Rac1/(r_e1+R_E1) # voltage gain of first stage
Av = Av1*Av2 # voltage gain
print "The voltage gain = %0.2f " %Av
r_in = R1*R2*Beta1*(r_e1+R_E1)/( (R1*R2)+(R2*(Beta1*(r_e1+R_E1)))+((Beta1*(r_e1+R_E1))*R1) ) # in ohm
r_in= r_in*10**-3 # in k ohm
print "The input resistance = %0.2f k ohm " %r_in
#Given data
I_DSS = 15 # in mA
I_DSS = I_DSS * 10**-3 # in A
V_P = -4 # in V
g_mo = (-2*I_DSS)/V_P # in S
V_GSQ = -2 # in V
g_m = g_mo*( 1-(V_GSQ/V_P) ) # in S
R_D = 2.7 # in k ohm
R_D = R_D * 10**3 # in ohm
Av1 = -g_m*R_D # voltage gain of first stage
Av2 = Av1 # voltage gain of second stage
Av = Av1*Av2 # overall voltage gain
print "The overall voltage gain = %0.1f " %Av
R_G = 2 # in Mohm
Rin = R_G # in Mohm
print "The input impedance = %0.f Mohm " %Rin
Rout = R_D # in ohm
Rout= Rout*10**-3 # in k ohm
print "The output impedance = %0.1f k ohm " %Rout
Rout= Rout*10**3 # in ohm
Vin = 15 # in mV
Vin = Vin * 10**-3 # in V
Vout = Av*Vin # in V
print "The output voltage = %0.2f V " %Vout
R_L = 15 # in k ohm
R_L = R_L * 10**3 # in ohm
V_L = (R_L/(Rout+R_L))*Vout # in V
print "The output voltage across load resistance = %0.1f V " %V_L
#Given data)
f2 = 100 # in kHz
f_H = f2/(sqrt(2**(1/3)-1 )) # in kHz
print "The upper 3-dB frequency of each stage = %0.2f kHz " %f_H
f1 = 25 # in kHz
f_L = f1/(sqrt(2**(1/3)-1 )) # in kHz
print "The lower 3-dB frequency of each stage = %0.2f kHz " %f_L
# Note: The value of upper 3-dB frequency in the book is not accurate and the
# calculated value of f_L is wrong. because 25 will be divided by 0.51 not multiplied.
#Given data
R_E= 1 # in k ohm
h_ie= R_E # in k ohm
h_fe= 100 # unit less
#V1= I1*[h_ie+(1+h_fe)*h_ie+(1+h_fe)**2*R_E]+I2*R_E (i)
#V2= I1*(1+h_fe)**2*R_E + I2*R_E (ii)
#Z= [(h_ie+(1+h_fe)*h_ie+(1+h_fe)**2*R_E) R_E (1+h_fe)**2*R_E R_E]
Z11= (h_ie+(1+h_fe)*h_ie+(1+h_fe)**2*R_E) # k ohm
Z12= R_E # k ohm
Z21= (1+h_fe)**2*R_E # k ohm
Z22= R_E # k ohm
print "The value of Z11 = %0.1f M ohm " %(Z11*10**-3)
print "The value of Z12 = %0.f k ohm " %(Z12)
print "The value of Z21 = %0.1f M ohm " %(Z21*10**-3)
print "The value of Z22 = %0.f k ohm " %(Z22)