# Consider inverting configuration
# 2.1a
R_1=1000.0; # (ohm)
R_2=100*10.0**3; # (ohm)
A=10**3; # (V/V)
print A,"= A (V/V)"
G=-R_2/R_1/(1+(1+R_2/R_1)/A);
print round(-G,2),"= G"
e=(-G-(R_2/R_1))/(R_2/R_1)*100;
print round(e,2),"= e (%)"
v_1=0.1; # (V)
v_1=G*v_1/A;
print round(v_1*1000,2),"= v_1 (mV)"
A=10**4; # (V/V)
print A,"= A (V/V)"
G=-R_2/R_1/(1+(1+R_2/R_1)/A);
print round(-G,2),"= G"
e=(-G-(R_2/R_1))/(R_2/R_1)*100;
print round(e,2),"= e (%)"
v_1=0.1; # (V)
v_1=G*v_1/A;
print round(v_1*1000,3),"= v_1 (mV)"
A=10**5; # (V/V)
print A,"= A (V/V)"
G=-R_2/R_1/(1+(1+R_2/R_1)/A);
print round(-G,2),"= G"
e=(-G-(R_2/R_1))/(R_2/R_1)*100;
print round(e,2),"= e (%)"
v_1=0.1; # (V)
v_1=G*v_1/A;
print round(v_1*1000,3),"= v_1 (mV)"
# 2.1b
A=50000; # (V/V)
print A,"= A (V/V)"
G=-R_2/R_1/(1+(1+R_2/R_1)/A);
print round(-G,2),"= G"
print "Thus a -50% change in the open loop gain results in only -0.1% in the closed loop gain"
R_2=1-50000-1/1000.0+50;
print round(-R_2/1000.0,1),"= R_2 (Kohm)"
R_1=-2*R_2/999;
print round(R_1),"= R_1 (ohm)"