In [2]:

```
#calculate the image frequency and rejection ratio in both cases
import math
from math import sqrt
#given data
Q = 100.#quality factor
f_i = 455.*10**3#intermediate frequency
#calculations
#first case
f_s = 1000.*10**3#incoming frequecy of first case
f_si = f_s + 2*f_i#image frequency of first case
p = (f_si/f_s) - (f_s/f_si);
alpha = sqrt(1+(Q**2*p**2))#rejection ratio of first case
#second case
f_s1 = 25.*10**6#incoming frequecy of second case
f_si1 = f_s1+ 2*f_i#image frequency of second case
p1 = ((f_si1/f_s1) - (f_s1/f_si1));
alpha1 = sqrt(1+(Q**2*p1**2))#rejection ratio of second case
#results
print "(i)a.Image frequency of first case (kHz)",f_si/1000.
print " b.Rejection ratio of first case = ",round(alpha,1)
print " (ii)a.Image frequency of second case (MHz) = ",round(f_si1/10**6,2)
print " b.Rejection ratio of second case = ",round(alpha1,2)
print "Note: Their is mistake in textbook in the calculation of rejection ratio"
```

In [4]:

```
#calculate the image frequency and rejection ratio in both cases
import math
from math import sqrt
#given data
Q = 90.
f_i = 455.*10**3#intermediate frequency
#calculations
#first case
f_s = 950.*10**3#incoming frequency of first case
f_si = f_s + 2*f_i#image frequency of first case
p = (f_si/f_s) - (f_s/f_si);
alpha = sqrt(1+(Q**2*p**2))#rejection ratio of first case
#second case
f_s1 = 10.*10**6#incoming frequecy of second case
f_si1 = f_s1+ 2*f_i#image frequency of second case
p1 = ((f_si1/f_s1) - (f_s1/f_si1));
alpha1 = sqrt(1+(Q**2*p1**2))#rejection ratio of second case
#results
print "(i)a.Image frequency of first case (kHz)",f_si/1000.
print " b.Rejection ratio of first case = ",round(alpha,1)
print " (ii)a.Image frequency of second case (MHz) = ",round(f_si1/10**6,2)
print " b.Rejection ratio of second case = ",round(alpha1,2)
```

In [6]:

```
#calculate the quality factor and new intermediate frequency
#given
import math
from math import sqrt
a1 = 130.5#rejection ratio
f_s = 10.*10**3#incoming frequency
print ("from fig 4.8 from t/b we can write that")
#calculations
#first case
alpha = 130.5#from problem 4.2 of first case
alpha2 = 15.72#from problem 4.2 of second case
alpha1 = alpha/alpha2#rejection ratio ofgiven RF amplifer
p1 =.174#from problem 4.2 of second case
Q = (sqrt(alpha1**2 - 1)/p1)#quality factor
#second case
p2 = 1.45#from problem 4.2 of second case
f_si =1860.*10**3#from problem 4.2 of second case
f_i = 950.*10**3#incoming frequency
f_i1 = 10.*10**6#good image frequency
f_si1 = (f_si*f_i1)/f_i; #image frequency
f_i2 = (f_si1 - f_i1)/2#new intermediate frequency
#results
print "(i)Quality factor = ",round(Q,2)
print "(ii)New intermediate frequency (MHz) = ",round(f_i2/10**6,3)
```

In [8]:

```
#calculate the local oscillator frequency and image frequency rejection ratio
import math
from math import sqrt
#given
IF = 455.*10**3#intermediate frequency in hertz
f_s = 900.*10**3#signal frequency in hertz
Q = 80.#quality factor
#calculations
f_0 = f_s + IF#local oscillator frequency
f_si = f_s + 2* IF#image frequency
p = (f_si/f_s)-(f_s/f_si)
a = sqrt(1+(Q*p)**2)#image frequency rejection ratio
#results
print "(i)Local oscillator frequency (kHz) = ",f_0/1000.
print "(ii)Image frequency (kHz) = ",f_si/1000.
print "(iii)Image frequency rejection ratio = ",a
print "Note:Their is mistake in textbook in the calculation of image frequency"
```

In [10]:

```
#calculate the image frequency, rejection ratio
import math
from math import sqrt
#given
Q = 125. #quality factor
#calculations
#first case
IF1 = 465.*10**3#intermediate frequency
f_s1 = 1.*10**6#incoming frequency for first case in hertz
f_s2 = 30.*10**6#second incoming frequency for first case in hertz
f_si1 = f_s1 + 2*IF1#image frequency for incoming frequency 1MHz for first case
f_si2 = f_s2 + 2*IF1#image frequency for incoming frequency 30MHz for first case
p1 = (f_si1/f_s1)-(f_s1/f_si1);
p2 = (f_si2/f_s2)-(f_s2/f_si2);
alpha1 = sqrt(1+(Q*p1)**2);#rejection ratio at 1MHz incoming frequency
alpha2 = sqrt(1+(Q*p2)**2);#rejection ratio at 30MHz incoming frequency
#second case
f_s3 = 1.*10**6#incoming frequency for second case in hertz
f_si3 = (f_si1*f_s2)/f_s3#image frequency
IF2 = (f_si3-f_s2)/2.#intermediate frequency
#results
print "(i)a.Image frequency for 1MHz incoming frequency (kHz) = ",f_si1/1000.
print " b.Rejection ratio for 1MHz incoming frequency = ",round(alpha1,2)
print " c.Image frequency for 30MHz incoming frequency (MHz) = ",f_si2/10**6
print " d.Rejection ratio for 30MHz incoming frequency =",round(alpha2,2)
print "(ii)intermediate frequency for second case (Hz) = ",round(IF2/10**6,1)
print 'The answers are a bit different from textbook due to rounding off error'
```

In [11]:

```
#calculate the range of local oscillator frequency and image frequency
#given
fs1=3 #MHz
fs2=30 #MHz
IF=40.525 #MHZ
#calculations
f01=fs1+IF
f02=fs2+IF
fsi1=fs1+2*IF
fsi2=fs2+2*IF
#results
print 'The range of local oscillator frequency is ',f01,'MHz to',f02,'MHz'
print 'The range of image frequency is ',fsi1,'MHz to',fsi2,'MHz'
```

In [13]:

```
#calculate the Q factor of RF amplifier
#given
fr=1*10**6 #Hz
BW=10.*10**3 #Hz
#calculations
Q=fr/BW
#results
print 'Q factor = ',Q
```