In [1]:

```
import math
#Variables
Ad = 100.0 #Differential mode gain
Acm = 0.01 #Common-mode gain
#Calculation
CMRR = Ad/Acm #CMRR
CMRR1 = 20*math.log10(CMRR) #CMRR (in db)
#Result
print "CMRR : ",CMRR1,"db."
```

In [2]:

```
#Variables
Ad = 1.0 * 10**5 #Differential mode gain
CMRR = 1.0 * 10**4 #CMRR
#Calculation
Acm = Ad/CMRR #Common-mode gain
#Result
print "Common mode gain : ",Acm,"."
```

In [4]:

```
#Variables
V1 = 745.0 * 10**-6 #Input voltage1 (in volts)
V2 = 740.0 * 10**-6 #Input voltage2 (in volts)
Vcm = (V1 + V2)/2 #Commonn mode signal (in volts)
Vd = V1 - V2 #Differential voltage (in volts)
Ad = 5 * 10**5 #Differential voltage gain
CMRR = 1.0 * 10**4 #CMRR
#Calculation
Vout = Ad*Vd*(1 + 1/CMRR*Vcm/Vd) #output voltage (in volts)
error = Vout - Ad*Vd #Error voltage (in volts)
Percerror = error/Vout*100 #Percentage error
#Result
print "Output voltage :",round(Vout,6),"V."
print "Percentage error : ",round(Percerror,4),"%."
```

In [5]:

```
#Variables
A = 200000.0 #Open loop voltage gain
Vd = 25.0 * 10**-6 #Input differential voltage (in volts)
#Calculation
Vout = A*Vd #output voltage (in volts)
#Result
print "Output voltage : + (or) - ",Vout,"V."
```

In [6]:

```
#Variables
Af = 10.0 #Voltage gain
R1 = 3.0 * 10**3 #Resistance (in ohm)
#Calculation
Rf = (Af - 1)*R1 #Resistance (in ohm)
#Result
print "Rf : ",Rf*10**-3,"kilo-ohm."
```

In [8]:

```
#Variables
R1 = 2.0 * 10**3 #Resistance (in ohm)
Rfmin = 0.0 #Resistance (in ohm)
Rfmax = 100.0 * 10**3 #Resistance (in ohm)
#Calculation
Afmin = 1 + Rfmin/R1 #Minimum voltage gain
Afmax = 1 + Rfmax/R1 #Maximum voltage gain
#Result
print "Maximum closed loop voltage gain",Afmax,"."
print "Minimum closed loop voltage gain",Afmin,"."
```

In [10]:

```
#Variables
R1 = 5.0 * 10**3 #Resistance (in ohm)
Rf = 500.0 * 10**3 #Feedback resistance (in ohm)
Vin = 0.1 #Input voltage (in volts)
#Calculation
Af = -Rf/R1 #Voltage gain
Rin = R1 #Input resistance (in ohm)
Rout = 0 #Output resistance (in ohm)
Vout = Af*Vin #Output voltage (in volts)
Iin = Vin/R1 #Input current (in Ampere)
#Result
print "Voltage gain : ",Af,"."
print "Input resistance : ",Rin*10**-3,"kilo-ohm."
print "Output resistance : ",Rout,"ohm."
print "Output voltage : ",Vout,"V."
print "Input current : ",Iin*10**3,"mA."
```

In [11]:

```
#Variables
Rf = 2.0 * 10**3 #Feedback resistance when S is open (in ohm)
Vin = 1.0 #Input voltage when S is open (in volts)
R1 = 1.0 * 10**3 #Resistance (in ohm)
R2 = R3 = 1.0 * 10**3 #Resistance (in ohm)
#Calculation
Vout = -Vin*Rf/R1 #Output voltage when S is open (in volts)
Af = -(R3 + R2)/R1 #gain
Vout1 = Af*Vin #Output voltage when S is closed (in volts)
#Result
print "O/P voltage when switch is open : ",Vout,"V."
print "O/P voltage when switch is closed : ",Vout1,"V."
```

In [14]:

```
#Variables
Rf = 1.0 * 10**6 #Feedback resistance (in ohm)
Ri = 1.0 * 10**6 #Input resistance (in ohm)
Vi = 1 #Input voltage (in volts)
#Calculation
Vo = -Rf/Ri*Vi #Output voltage (in volts)
Av = Vo/Vi #Voltage gain
Ai = 1 #Current gain
Ap = abs(Av*Ai) #Power gain
#Result
print "Voltage gain : ",Av,"."
print "Current gain : ",Ai,"."
print "Power gain : ",Ap,"."
```

In [15]:

```
#Variables
Rf = 20.0 * 10**3 #Feedback resistance (in ohm)
R1 = 10.0 * 10**3 #Resistance (in ohm)
#Calculation
Aoffnoninv = 1 + Rf/R1 #Amplifier gain when S open and non inverted
Aoffinv = -Rf/R1 #Amplifier gain when S open and inverted
Aoff = Aoffinv + Aoffnoninv #Amplifier gain when S open
Aon = -Rf/R1 #Amplifier gain when S is closed
#Result
print "Amplifier gain when S is open : ",Aoff,"."
print "Amplifier gain when S is closed : ",Aon,"."
```

In [16]:

```
#Variables
Rf = 100.0 #Feedback resistance (in kilo-ohm)
#Calculation
R1 = Rf #Resistance1 (in ohm)
R2 = Rf/10 #Resistance2 (in ohm)
R3 = Rf/100 #Resistance3 (in ohm)
#Result
print "R1 : ",R1,"kilo-ohm.\nR3 : ",R2,"kilo-ohm.\nR3 : ",R3,"kilo-ohm."
```

In [22]:

```
#Variables
Rf = 12.0 * 10**3 #Feedback resistance (in ohm)
R1 = 12.0 * 10**3 #Resistance1 (in ohm)
R2 = 2.0 * 10**3 #Resistance2 (in ohm)
R3 = 3.0 * 10**3 #Resistance3 (in ohm)
Vi1 = 9.0 #Input voltage1 (in volts)
Vi2 = -3.0 #Input voltage2 (in volts)
Vi3 = -1.0 #Input voltage3 (in volts)
#Calculation
Vout = -Rf*(Vi1/R1 + Vi2/R2 + Vi3/R3) #Output voltage (in volts)
#Result
print "Output voltage : ",Vout,"V."
```

In [23]:

```
#Variables
Rf = 6.0 #Feedback resistance (in kilo-ohm)
#Calculation
R1 = Rf #Resistance1 (in ohm)
R2 = Rf/2 #Resistance2 (in ohm)
R3 = Rf/3 #Resistance3 (in ohm)
#Result
print "R1 : ",R1,"kilo-ohm.\nR3 : ",R2,"kilo-ohm.\nR3 : ",R3,"kilo-ohm."
```

In [25]:

```
#Variables
R3 = 10.0 #Resistance (in kilo-ohm)
#Calculation
Rf = 4*R3 #Feedback resistance (in ohm)
R2 = Rf/3 #Resistance2 (in ohm)
R1 = Rf/2 #Resistance1 (in ohm)
#Result
print "Rf : ",Rf,"kilo-ohm.\nR2 : ",round(R2,2),"kilo-ohm.\nR1 : ",R1,"kilo-ohm."
```

In [26]:

```
#Variables
V1 = 2.0 #Voltage1 (in volts)
V2 = -1.0 #Voltage2 (in volts)
#Calculation
Vs1 = V1*(1.0/2/(1+1.0/2)) #I/P at non-inverting I/P terminal (in volts)
V1o = Vs1*(1 + 2/1) #O/P voltage1 (in volts)
Vs2 = V2*(1.0/2/(1+1.0/2)) #I/P voltage2 (in volts)
V2o = Vs2*(1 + 2/1) #O/P voltage2 (in volts)
Vout = V1o + V2o #Output voltage (in volts)
#Result
print "Output voltage : ",Vout,"V."
```

In [27]:

```
#Variables
R = 10.0 #Resistance (in kilo-ohm)
#Calculation
Rf = 10*R #feedback resistance (in kilo-ohm)
#Result
print "Feedback resistor : ",Rf,"kilo-ohm."
```

In [29]:

```
#Variables
C = 2.0 * 10**-6 #Capacitance (in Farad)
R = 50.0 * 10**3 #Resistance (in ohm)
#Calculation
scale_factor = -1/(C*R) #Scale factor (in second)
#Result
print "Output voltage : 0.0113(cos(4000*t)-1) mV."
```

In [30]:

```
import math
#Variables
C = 2.0 * 10**-6 #Capacitance (in Farad)
R = 50.0 * 10**3 #Resistance (in ohm)
f = 2.0 * 10**3 #Frequency (in Hertz)
Vpeak = 10.0 * 10**-6 #Peak voltage (in volts)
#Calculation
scale_factor = (C*R) #Scale factor (in second)
#Result
print "Output voltage : 13.56*cos(4000*math.pi*t)."
```

In [31]:

```
#Variables
IB1 = 10.0 * 10**-6 #Base current1 (in Ampere)
IB2 = 7.5 * 10**-6 #Base current2 (in Ampere)
#Calculation
Iinbias = (IB1 + IB2)/2 #Input bias current (in Ampere)
Iinoffset = IB1 - IB2 #Input offset current (in Ampere)
#Result
print "Input bias current : ",round(Iinbias*10**6,2),"micro-Ampere."
print "Input offset current : ",round(Iinoffset*10**6,2),"micro-Ampere."
```

In [32]:

```
#Variables
dVout = 20.0 #Output voltage (in volts)
dt = 4.0 #time (in micro-seconds)
#Calculation
SR = dVout/dt #Slew rate (in volt per micro-second)
#Result
print "Slew rate : ",SR," V/micro-second."
```