# Gain
import math
#Variable declaration
a=60.0 # OPEN LOOP VOLTAGE GAIN IN dB
A= 10**(a/20) # open voltage gain
Beta= (1.0/20) # feedback ratio
#Calculations
Af= (A/(1+(Beta*A))) # GAIN WITH FEEDBACL
AfdB= 20*(math.log10(Af)) # gain with feedback in dB
#Result
print("Gain with feedback is %.2f dB"%AfdB)
# feedback factor
import math
#Variable declaration
a=60.0 # OPEN LOOP VOLTAGE GAIN IN dB
A= 10**(a/20) # open voltage gain
AfdB=40.0 # gain with feedback in dB
#Calculations
Af= 10**(AfdB/20) # GAIN WITH FEEDBACK
BetaA= (A/Af)-1 # feedback factor
#Result
print("feedback factor is %.f"%BetaA)
# feedback output
import math
#Variable declaration
A= 600.0 # open voltage gain
Af=50.0
#Calculations
Beta=( (A/Af)-1)/A # feedback ratio
fop= (Beta*100) # percentage of output voltage which is fedback to the input is
#Result
print("Percentage of output voltage which is fedback to the input is %.3f%%"%fop)
# feedback ratio
import math
#Variable declaration
Vo= 5.0 # output voltage
Vin=0.1 # input voltage without feedback
Vin1=0.2 # input voltage with feedback
#Calculations
A= Vo/Vin # Gain without feedback
Af= Vo/Vin1 # Gain with feedback
Beta=( (A/Af)-1)/A # feedback ratio
#Result
print("feedback ratio = %.2f"%Beta)
# Change in gain
import math
#Variable declaration
A= 1000.0 # open loop voltage gain
Beta= 0.002 # feedback ratio
#Calculations
Af= (A/(1+(Beta*A))) # GAIN WITH FEEDBACL
A1= (1-0.15)*A # new open loop voltage gain
Af1= (A1/(1+(Beta*A1))) # GAIN WITH FEEDBACL
dA=((Af-Af1)/Af)*100 # Change in overall gain in percentage
#Result
print("Change in overall gain is %.1f%%"%dA)
# open loop voltage gain
import math
#Variable declaration
Af= 100.0 # GAIN WITH FEEDBACK
dAf=1.0/100 # OPEN LOOP VOLTAGE GAIN
dA= 10.0/100 # open voltage gain
#Calculations
BetaA=(dA/dAf)-1 # feedback factor
A=Af*(1+BetaA) # open loop voltage gain
#Result
print("open loop voltage gain is %.f"%A)
# open loop voltage gain & negaive feedback
import math
#Variable declaration
Af= 100.0 # GAIN WITH FEEDBACK
dAf=0.1/100 # OPEN LOOP VOLTAGE GAIN
dA= 10.0/100 # open voltage gain
#Calculations
BetaA=(dA/dAf)-1 # feedback factor
A=Af*(1+BetaA) # open loop voltage gain
NF= Af/A # amount of negative feedback
#Result
print("open loop voltage gain is %.f"%A)
print("amount of negative feedback is %.2f"%NF)
# GAIN,INPUT VOLTAGE AND OUTPUT VOLTAGE
import math
#Variable declaration
Vs=10.0 # output voltage in milli volts
Vi= 0.01 # input voltage in volts
A=200.0 # amplifier gain without feedback
D=0.1 # distortion without feedback
Df=0.01 # distortion with feedback
#Calculations
Beta=( (D/Df)-1)/A # feedback ratio
fop= (Beta*100) # percentage of output voltage which is fedback to the input is
Af= (A/(1+(Beta*A))) # GAIN WITH FEEDBACL
Vo= Af*Vs*10**-3 # new output volate in volts
Vin= (Vi +(-Beta*Vo))*10**3
#Resut
print("gain with feedback = %.f"%Af)
print("new output volate = %.1f V"%Vo)
print("new input voltage = %.f mV"%Vin)
# INPUT VOLTAGE ,distortion AND close loop gain
import math
#Variable declaration
Vs=10.0 # output voltage in milli volts
A=1000.0 # amplifier gain without feedback
D=0.1 # distortion without feedback
BetaAd=40.0 # FEEDBACK FACTOR IN dB
#Calculations
BetaA=10**(BetaAd/20) # feedback ratio
Df= ((D/(1+BetaA)))*100 # distortion in percentage with feedbck
Af= (A/(1+(BetaA))) # GAIN WITH FEEDBACL
Vo= Vs*(1+BetaA)*10**-3 # new output volate in volts
#Result
print("input signal voltage = %.2f V"%Vo)
print("Percentage second harmonic distortion will be %.1f%%"%Df)
print("Closed loop voltage gain will be %.1f"%Af)
# input & output impedance
import math
#Variable declaration
A= 10000.0 # open voltage gain
Beta=0.02 # feedback ratio
Zi=1.0 # input impedance without feedback in kiilo ohms
Zo=10.0 # output impedance without feedback in kiilo ohms
#calculaltions
Zif= (1+A*Beta)*Zi # input impedance with feedback in kiilo ohms
Zof=(Zo/(1+Beta*A))*10**3 # output impedance with feedback in ohms
#Result
print("input impedance with feedback = %.f k-ohm"%Zif)
print("output impedance with feedback = %.2f ohm"%Zof)
# feedback factor and Change in gain
import math
#Variable declaration
Zi=1.0 # input impedance without feedback in kiilo ohms
Zo=10.0 # output impedance without feedback in kiilo ohms
Zof=1.0 # output impedance with feedback in killo ohms
A= 1000.0 # open loop voltage gain
Af=100.0 # FEEDBACK
#Calculations
Beta=( (Zo/Zof)-1)/A # feedback ratio
BetaA= Beta*A # feedback factor
A1= (1-0.1)*A # new open loop voltage gain
Af1= (A1/(1+(Beta*A1))) # GAIN WITH FEEDBACL
dA=((Af-Af1)/Af)*100 # Change in overall gain in percentage
#Result
print("feedback factor is %.f"%BetaA)
print("Change in overall gain in percentage is %.1f%%"%dA)
# Avf,Fhf,Flf
import math
#Variable declaration
Fh=20.0 # upper cutoff frequency in killo hertz without feedback
Fl=30.0 # upper cutoff frequency in hertz without feedback
Av= 50000.0 # open loop voltage gain
Beta=5*10**-5 # feedback ratio
#calaculations
Avf= (Av/(1+(Beta*Av))) # GAIN WITH FEEDBACL
Fhf=Fh*(1+Av*Beta) # uppor cutoff frequency with feedback in killo hertz
Flf=Fl/(1+Av*Beta) # lower cutoff frequency with feedback in hertz
#Result
print("Voltsge gain with feedback is %.1f"%Avf)
print("uppor cutoff frequency with feedback = %.f kHz"%Fhf)
print("lower cutoff frequency with feedback = %.2f Hz"%Flf)
# feedback factor and bandwidth
import math
#Variable declaration
B=4.0 # bandwidth in mega hertz without feedback
Av= 1500.0 # open loop voltage gain
Avf= 150.0 # GAIN WITH FEEDBACk
#Calculations
AvB= ((Av/Avf)-1) # feedback factor
BWf=(1+AvB)*B # bandwidth in mega hertz with feedback
#Result
print("feedback factor is %.f"%AvB)
print("bandwidth with feedback is %.f MHz"%BWf)
# voltage gain ,input & output resistance
import math
#Variable declaration
A= 500.0 # open voltage gain
Beta=0.01 # feedback ratio
Ri=3.0 # input resistance without feedback in kiilo ohms
Ro=20.0 # output resistance without feedback in kiilo ohms
#Calculations
Af=(A/(1+A*Beta)) # Voltage gain is
Rif= (1+A*Beta)*Ri # input RESISTANCE with feedback in kiilo ohms
Rof=(Ro/(1+Beta*A))# output resistance with feedback in killo ohms
#Result
print("Voltage gain is %.2f"%Af)
print("input resistance with feedback = %.f k-ohm"%Rif)
print("output resistance with feedback = %.2f k-ohm"%Rof)
# INPUT IMPEDANCE
import math
#Variable declaration
Beta=100.0 # gain
Rl=18.6 # load resistance in killo ohms
Re=9.3 # emitter resistance in killo ohms
Vbe=0.7
Vcc=10.0 # collector voltage in volts
R1=10.0 # resistance in killo ohms
R2=10.0 # resistance in killo ohms
#Calculations
V2= Vcc*(R2/(R1+R2)) # voltage at resistor R2
Ve=V2-Vbe # volate at emitter
Ie=Ve/Re # Emitter current in milli ampere
re=(25/Ie) # AC emitter resistance
Re=(Rl*Re)/(Rl+Re) # effective emitter resistance in killo ohms
Zib=Beta*(Re*10**3+re)*10**-3
x=(R1*R2)/(R1+R2) # resistance in killo ohms
Zi=(Zib*x)/(Zib+x) # input impedance of the emitter follower in killo ohms
#Result
print("input impedance of the emitter follower = %.2f k-ohm"%Zi)
# gain
import math
#Variable declaration
gm=4000.0 # gain in micro second
Ro=10.0 # output resistance in killo ohms
Rd=10.0 # resistance in killo ohms
R1=80.0 # resistance in killo ohms
R2=20.0 # resistance in killo ohms
#Calculations
Rl=(Ro*Rd)/(Ro+Rd) # load resistance in killo ohms
A= -(gm*10**-6*Rl*10**3) # gain without feedback
Beta= -(R2/(R1+R2)) # feedback factor
Af=(A/(1+A*Beta)) # gain with feedback
#Result
print("gain without feedback is %.f"%A)
print("gain with feedback is %.f"%Af)
# gain
import math
#Variable declaration
R1=1.8 # resistance in killo ohms
R2=0.2 # resistance in killo ohms
A=100000.0 # gain without feedback
#Calculations
Beta= (R2/(R1+R2)) # feedback factor
Af1=(A/(1+A*Beta)) # gain with feedback
Af=(1/Beta) # AS A*Beta>>1
#Result
print("gain with feedback AS A*Beta>>1 is %.f"%Af)
# Av,Rif,Avf,Rof
import math
#Variable declaration
Rs=600.0 # Internal resistance in ohms
Rl=2.0 # Load resistance in killo ohms'
Rb=40.0 # base resistance in killo ohms
# H-paramters are
hie=5.0 # in killo ohms
hre=80.0
hfe=80.0
#Calculations
RL1=(Rb*Rl)/(Rb+Rl)
Av=(-(hfe*(RL1*10**3/hie*10**3)))*10**-6
Av = math.floor(Av*100)/100
x=(Rb*10**3/(1-Av))
Rif= (hie*10**3*x)/(hie*10**3+x)
Avf=(Av*Rif)/(Rif+Rs)
Rof=((Rb*10**3*(Rs+hie*10**3))/(Rs*hfe))*10**-3
Rof1=(Rof*Rl)/(Rof+Rl)
#Result
print("Voltage gain is %.2f"%Av)
print("input resistance with feedback = %.3f ohm"%(math.ceil(Rif*1000)/1000))
print("Overall Voltage gain is %.2f"%Avf)
print("output resistance with feedback = %.1f k-ohm"%Rof1)
# A,Beta,Rif,Af amd loop gain
import math
#Variable declaration
R1=1.0 # resistance in killo ohms
R2=20.0 # resistance in killo ohms
Re=100.0 # emitter resistance in ohms
# H-paramters are
hie=2.0 # in killo ohms
hfe=80.0
Rl=1.0 # load resistance in killo ohms
#Calculations
Ri=hie # input resistance in killo ohms
A= -(hfe*Rl*10**3)/(hie*10**3)
Beta=Re/(Rl*(10**3)) # GAIN
Rif= (hie*10**3+(1+hfe)*Re)*10**-3 # input resistance with feedback in killo ohms
Av=(-(hfe*(Rl*10**3/Rif*10**3)))*10**-6
BetaA= Beta*A # loop gain
BetaAd= 20*(math.log10(-BetaA)) # loop gain in dB
#Result
print("Voltage gain without feedback is %.f"%A)
print("Feedback ratio is given by %.1f"%Beta)
print("input resistance with feedback = %.1f k-ohm"%Rif)
print("Voltage gain with feedback is %.2f"%Av)
print("loop gain is %.2f dB"%BetaAd)
# voltage gain
import math
#Variable declaration
re=7.5 # A.C. Resistance
R1=470.0 # resistance in ohms
Rc=2.2 # resistance in killo ohms
Re=510.0 # emitter resistance in ohms
# H-paramters are
hie=900.0 # in ohms
hfe=120.0
#Calculations
A=-(hfe)/(hie+Re) # gain without feedback
Beta=-Re # gain
GF= (1+A*Beta) # gain factor
Af=A/(GF) # GAIN WITH FEEDBACK
Avf= Af*Rc*10**3 # voltage gain with feedback
Av= -(Rc*10**3/re) # voltage gain without feedback
#Result
print("voltage gain with feedback is %.1f"%Avf)
print("voltage gain without feedback is %.1f"%Av)
# change in overall gain
import math
#Variable declaration
Beta=0.01 # feedback
Ad= 60.0 # gain in dB
dA= 11.0 # open voltage gain
#Calculations
A= 10**(Ad/20) # gain
dAf= (1/(1+Beta*A))*dA # GAIN WITH FEEDBACK
#Result
print("change in overall gain is = %.f %%"%dAf)
print("\nThe result clearly shows that the %% change reduction in overall gain")
print("with negative feedback is reduced from 11%% to 1%%.")
print("That is why we say that amplifier with negative feedback have stable gain.")
# input impedence with feedback
import math
#Variable declaration
A= 1000.0 # open voltage gain
Beta=0.005 # feedback ratio
Zi=2.0 # input impedance without feedback in kiilo ohms
#Calculations
Zif= (1+A*Beta)*Zi # input impedance with feedback in kiilo ohms
#Result
print("input impedance with feedback = %.f k-ohm"%Zif)
# feedback factor and change in overall gain
import math
#Variable declaration
Zo=12.6 # output impedance in killo ohms
Zofb=600.0 # output impedance in ohms with feedback
Ad= 60.0 # gain in dB
dA= 10.0 # open voltage gain
#Calcualtions
A= 10**(Ad/20) # gain
Beta= ((Zo*10**3/Zofb)-1)/A
dAf= (1/(1+Beta*A))*dA # GAIN WITH FEEDBACK
#Result
print("feedbck factor is %.2f"%Beta)
print("change in overall gain = %.3f %%"%dAf)
# feedback fration ,overall voltage gain and output voltage
import math
#Variable declaration
A=5000.0 # gain wtihout feedback
R1=1.0 # resistance in killo ohms
R2=9.0 # resistance in killo ohms
Vs=2.0 # input voltage without feedback in milli volts
#Calcualtions
Beta= R1/(R1+R2) # feedback fraction
Afb=round(A/(1+Beta*A))
Vo= round(Afb*Vs) # output voltage with feedback in milli volts
#Result
print("feedback fraction = %.1f"%Beta)
print("overall voltage gain = %.f"%Afb)
print("output voltage with feedback = %.f mV"%Vo)
# feedback fraction ,overall voltage gain,input impedance ,output impedance and output volatge
import math
#Variable declaration
Zi=5.0 # input impedance in killo ohms
Zo=100.0 # input impedance in ohms
A=10000.0 # gain wtihout feedback
R1=2.0 # resistance in killo ohms
R2=18.0 # resistance in killo ohms
Vs=10.0 # input voltage without feedback in milli volts
#Calculations
Beta= R1/(R1+R2) # feedback fraction
Afb=round(A/(1+Beta*A)) # overall gain
Zif= round((1+A*Beta)*Zi*10**-3) # input impedance with feedback in mega ohms
Zof= Zo/(1+Beta*A) # OUTPUT impedance with feedback in ohms
Vo= round(Vs/Afb) # output voltage with feedback in milli volts
#Result
print("feedback fraction = %.1f"%Beta)
print("overall voltage gain = %.f"%Afb)
print("input impedance with feedback = %.f M-ohm"%Zif)
print("output impedance with feedback= %.1f ohm"%Zof)
print("output voltage with feedback = %.f mV"%Vo)
# Gain
import math
#Variable declaration
a=60.0 # OPEN LOOP VOLTAGE GAIN IN dB
A= 10**(a/20) # open voltage gain
Beta=0.009 # feedback ratio
#Calculations
Af= (A/(1+(Beta*A))) # GAIN WITH FEEDBACL
AfdB= 20*(math.log10(Af))# gain with feedback in dB
#Result
print("gain with feedback = %.2f"%AfdB)
#Answer for the gain with feedback is wrong in the book
# reduction in distortion
import math
#Variable declaration
a=54.8 # OPEN LOOP VOLTAGE GAIN IN dB
A= 10**(a/20) # open voltage gain
Beta=0.02 # feedback ratio
#Calculations
Af= (A/(1+(Beta*A))) # GAIN WITH FEEDBACL
dA= (1/(1+Beta*A))*100# percentage change in distortion
#Result
print("percentage reduction in distortion is %.2f%%"%(math.floor(dA*100)/100))
# gain with feedback ,input impedance and output impedance
import math
#Variable declaration
Zi=1.0 # input impedance in killo ohms
Zo=40.0 # input impedance in killo ohms
A=10000.0 # gain wtihout feedback
Beta=0.05 # gain
#Calculations
Afb=(A/(1+Beta*A))
Zif= ((1+A*Beta)*Zi)
Zof= (Zo*10**3/(1+Beta*A))
#Result
print("overall voltage gain = %.f"%Afb)
print("input impedance with feedback = %.f M-ohm"%Zif)
print("output impedance with feedback = %.f ohms"%Zof)
#Answer in the book for input impedance is wrong
# bandwidth
import math
#Variable declaration
F2=16.0 # upper cutoff frequency in killo hertz without feedback
F1=40.0 # upper cutoff frequency in hertz without feedback
A= 800.0 # open loop voltage gain
Beta=0.02 # feedback ratio
#CAlaculations
Afb= (A/(1+(Beta*A))) # GAIN WITH FEEDBACk
F2f=F2*(1+A*Beta) # uppor cutoff frequency with feedback in killo hertz
F1f=F1/(1+A*Beta)*10**-3 # lower cutoff frequency with feedback in killo hertz
Bw=F2-F1*10**-3 # bandwidth without feedback in killo hertz
Bwf=round(F2f-F1f) # bandwidth with feedback in killo hertz
#Result
print("bandwidth without feedback = %.2f kHz"%Bw)
print("bandwidth with feedback = %.f"%Bwf)
# bandwidth
import math
#Variable declaration
BW=10.0 # bandwidth without feedback in killo hertz
A= 100.0 # open loop voltage gain
Beta=0.1 # feedback ratio
#Calculations
Afb= (A/(1+(Beta*A))) # GAIN WITH FEEDBACk
Bwf=round(BW*(1+Beta*A))# bandwidth with feedback in killo hertz
#Result
print("feedback gain = %.2f"%Afb)
print("bandwidth with feedback = %.f kHz"%Bwf)
# gain and harmonic distortion
import math
#Variable declaration
A2= 200.0 # open loop voltage gain
Beta=0.1 # feedback ratio
D2=0.02 # first stage distortion
#Calculations
D2d= (D2/(1+Beta*A2))*100
A2d=A2/(1+Beta*A2)
A1=round(A2/A2d)
#Result
print("second stage harmonic distortion , A2' %.2f%%"%(D2d*100))
print("gain of first stage, A1 = %.f"%A1)
# pole frequency
import math
#Variable declaration
R2=2*10**5 # effective resistance in ohms
Av2=1000.0 # gain of second stage
Cf=20.0 # feedback capacitor in pico farad
#Calculations
Cm=(1+Av2)*Cf
fp1= 1/(2*math.pi*R2*Cm*10**-12)
#Result
print("pole frequency = %.2f Hz"%fp1)