import math
A_p=250.0
A_p_dB=10*math.log10(A_p)
print('Power gain(dB) when power gain is 250 = %d'% math.ceil(A_p_dB));
A_p=100.0
A_p_dB=10*math.log10(A_p)
print('Power gain(dB) when power gain is 100 = %d'%A_p_dB)
A_p=10.0
A_p_dB=20*math.log10(A_p)
print('Voltage gain(dB) when Voltage gain is 10 = %d'%A_p_dB)
A_p=0.50
A_p_dB=10*math.log10(A_p)
print('Power gain(dB) when voltage gain is 0.50 = %d'%A_p_dB)
A_p=0.707
A_p_dB=20*math.log10(A_p)
print('Power gain(dB) when power gain is 0.707 = %d'%A_p_dB)
v_out=0.707*10;
print('output voltage in volts at -3dB gain = %.2f'%v_out)
#at -6dB voltage gain from table is 0.5
v_out=0.5*10;
print('output voltage in volts at -6dB gain = %d'%v_out)
#at -12dB voltage gain from table is 0.25
v_out=0.25*10;
print('output voltage in volts at -12dB gain = %.1f'%v_out)
#at -24dB voltage gain from table is 0.0625
v_out=0.0625*10;
print('output voltage in volts at -24dB gain = %.3f'%v_out)
import math
R_in=1.0*10**3;
C1=1.0*10**-6;
A_v_mid=100.0; #mid range voltage gain
f_c=1/(2*math.pi*R_in*C1);
#at f_c, capacitive reactance is equal to resistance(X_C1=R_in)
attenuation=0.707;
#A_v is gain at lower critical frequency
A_v=0.707*A_v_mid;
print('lower critical frequency = %f Hz'%f_c)
print('attenuation at lower critical frequency =%.3f'%attenuation)
print('gain at lower critical frequency = %.1f'%A_v)
A_v_mid=100.0;
#At 1Hz frequency,voltage gain is 3 dB less than at midrange. At -3dB, the voltage is reduced by a factor of 0.707
A_v=0.707*A_v_mid;
print('actual voltage gain at 1Hz frequency = %.1f'%A_v)
#At 100Hz frequency,voltage gain is 20 dB less than at critical frequency (f_c ). At -20dB, the voltage is reduced by a factor of 0.1
A_v=0.1*A_v_mid;
print('actual voltage gain at 100Hz frequency = %d'%A_v)
#At 10Hz frequency,voltage gain is 40 dB less than at critical frequency (f_c). At -40dB, the voltage is reduced by a factor of 0.01
A_v=0.01*A_v_mid;
print('actual voltage gain at 10Hz frequency = %d'%A_v)
import math
R_C=10.0*10**3;
C3=0.1*10**-6;
R_L=10*10**3;
A_v_mid=50;
f_c=1/(2*math.pi*(R_L+R_C)*C3);
print('lower critical frequency = %f Hz'%f_c)
#at midrange capacitive reactance is zero
X_C3=0;
attenuation=R_L/(R_L+R_C);
print('attenuation at midrange frequency = %.1f'%attenuation)
#at critical frequency, capacitive reactance equals total resistance
X_C3=R_L+R_C;
attenuation=R_L/(math.sqrt((R_C+R_L)**2+X_C3**2));
print('attenuation at critical frequency = %f'%attenuation)
A_v=0.707*A_v_mid;
print('gain at critical frequency = %.2f'%A_v)
import math
B_ac=100.0;
r_e=12.0;
R1=62.0*10**3;
R2=22.0*10**3;
R_S=1.0*10**3;
R_E=1.0*10**3;
C2=100.0*10**-6;
#Base circuit impedance= parallel combination of R1, R2, R_S
R_th=(R1*R2*R_S)/(R1*R2+R2*R_S+R_S*R1);
#Resistance looking at emitter
R_in_emitter=r_e+(R_th/B_ac);
#resistance of equivalent bypass RC is parallel combination of R_E,R_in_emitter
R=(R_in_emitter*R_E)/(R_E+R_in_emitter);
f_c=1/(2*math.pi*R*C2);
print('critical frequency of bypass RC circuit = %f Hz'%f_c)
import math
V_GS=-10.0;
I_GSS=25.0*10**-9;
R_G=10.0*10**6;
C1=0.001*10**-6;
R_in_gate=abs((V_GS/I_GSS));
R_in=(R_in_gate*R_G)/(R_G+R_in_gate);
f_c=1/(2*math.pi*R_in*C1);
print('critical frequency = %f Hz'%f_c)
import math
V_GS=-12.0;
I_GSS=100.0*10**-9;
R_G=10.0*10**6;
R_D=10.0*10**3;
C1=0.001*10**-6;
C2=0.001*10**-6;
R_in_gate=abs((V_GS/I_GSS));
R_in=(R_in_gate*R_G)/(R_G+R_in_gate);
R_L=R_in; #according to question
f_c_input=1/(2*math.pi*R_in*C1);
print('critical frequency of input RC circuit = %f Hz'%f_c_input)
f_c_output=1/(2*math.pi*(R_D+R_L)*C2)
print('critical frequency of output RC circuit = %f Hz'%f_c_output)
import math
B_ac=100.0;
r_e=16.0;
R1=62.0*10**3;
R2=22.0*10**3;
R_S=600.0;
R_E=1.0*10**3;
R_C=2.2*10**3;
R_L=10.0*10**3;
C1=0.1*10**-6;
C2=10.0*10**-6;
C3=0.1*10**-6;
#input RC circuit
R_in=(B_ac*r_e*R1*R2)/(B_ac*r_e*R1+B_ac*r_e*R2+R1*R2);
f_c_input=1/(2*math.pi*(R_S+R_in)*C1);
print('input frequency = %f Hz'%f_c_input)
#For bypass circuit; Base circuit impedance= parallel combination of R1, R2, R_S
R_th=(R1*R2*R_S)/(R1*R2+R2*R_S+R_S*R1);
#Resistance looking at emitter
R_in_emitter=r_e+(R_th/B_ac);
#resistance of equivalent bypass RC is parallel combination of R_E,R_in_emitter
R=(R_in_emitter*R_E)/(R_E+R_in_emitter);
f_c_bypass=1/(2*math.pi*R*C2);
print('critical frequency of bypass RC circuit = %f Hz'%f_c_bypass)
f_c_output=1/(2*math.pi*(R_C+R_L)*C3)
print('output frequency circuit = %f Hz'%f_c_output)
R_c=R_C*R_L/(R_C+R_L);
A_v_mid=R_c/r_e;
attenuation=R_in/(R_in+R_S);
A_v=attenuation*A_v_mid; #overall voltage gain
A_v_mid_dB=20*math.log10(A_v);
print('overall voltage gain in dB = %f'%A_v_mid_dB)
import math
B_ac=125.0;
C_be=20.0*10**-12;
C_bc=2.4*10**-12;
R1=22.0*10**3;
R2=4.7*10**3;
R_E=470.0;
R_S=600.0;
R_L=2.2*10**3;
V_CC=10.0;
V_B=(R2/(R1+R2))*V_CC;
V_E=V_B-0.7;
I_E=V_E/R_E;
r_e=25.0*10**-3/I_E;
#total resistance of input circuit is parallel combination of R1,R2,R_s,B_ac*r_e
R_in_tot=B_ac*r_e*R1*R2*R_S/(B_ac*r_e*R1*R2+B_ac*r_e*R1*R_S+B_ac*r_e*R2*R_S+R1*R2*R_S);
R_c= 1100.0#R_C*R_L/(R_C+R_L)
A_v_mid=R_c/r_e;
C_in_Miller=C_bc*(A_v_mid+1)
C_in_tot=C_in_Miller+C_be;
C_in_tot=C_in_tot*10**10
f_c=1/(2*math.pi*R_in_tot*C_in_tot);
print('total resistance of circuit = %f Ohm'%R_in_tot)
print('total capacitance = %f * 10^-10 F'%C_in_tot)
print('critical frequency = %f Hz'%f_c)
import math
C_bc=2.4*10**-12; #from previous question
A_v=99.0; #from previous question
R_C=2.2*10**3;
R_L=2.2*10**3;
R_c=R_C*R_L/(R_C+R_L);
C_out_Miller=C_bc*(A_v+1)/A_v;
f_c=1/(2*math.pi*R_c*C_bc); #C_bc is almost equal to C_in_Miller
C_out_Miller=C_out_Miller*10**12
print('equivalent resistance = %d Ohm'%R_c)
print('equivalent capacitance =%f *10^-12 F'%C_out_Miller)
print('critical frequency =%f Hz'%f_c)
C_iss=6.0*10**-12;
C_rss=2.0*10**-12;
C_gd=C_rss;
C_gs=C_iss-C_rss;
C_gd=C_gd*10**12
C_gs=C_gs*10**12
print('gate to drain capacitance = %.1f * 10^-12 F'%C_gd)
print('gate to source capacitance = %.1f * 10^-12 F'%C_gs)
import math
C_iss=8.0*10**-12;
C_rss=3.0*10**-12;
g_m=6500.0*10**-6; #in Siemens
R_D=1.0*10**3;
R_L=10.0*10**6;
R_s=50.0;
C_gd=C_rss;
C_gs=C_iss-C_rss;
R_d=R_D*R_L/(R_D+R_L);
A_v=g_m*R_d;
C_in_Miller=C_gd*(A_v+1);
C_in_tot=C_in_Miller+C_gs;
f_c=1/(2*math.pi*C_in_tot*R_s);
print('critical frequency of input RC circuit =%.3f *10^8 Hz'%(f_c*10**-8))
import math
C_gd=3.0*10**-12; #from previous question
A_v=6.5; #from previous question
R_d=1.0*10**3; #from previous question
C_out_Miller=C_gd*(A_v+1)/A_v;
f_c=1/(2*math.pi*R_d*C_out_Miller);
print('critical frequency of the output circuit = %d Hz'%f_c)
f_cu=2000.0;
f_cl=200.0;
BW=f_cu-f_cl;
print('bandwidth = %d Hz'%BW)
f_T=175.0*10**6; #in hertz
A_v_mid=50.0;
BW=f_T/A_v_mid;
print('bandwidth = %d Hz'%BW)
f_cl=1.0*10**3; #lower critical frequency of 2nd stage in hertz
f_cu=100.0*10**3; #upper critical frequency of 1st stage in hertz
BW=f_cu-f_cl;
print('bandwidth = %d Hz'%BW)
import math
n=2.0; #n is the number of stages of amplifier
f_cl=500.0;
f_cu=80.0*10**3;
f_cl_new=f_cl/(math.sqrt(2**(1/n)-1));
f_cu_new=f_cu*(math.sqrt(2**(1/n)-1));
BW=f_cu_new-f_cl_new;
print('bandwidth = %f Hz'%BW)