In [1]:

```
import math
#Given angle modulated signal is x = 3*math.cos[2*pi*(10**6)*t+2*math.sin(2*pi*10**3*t)]
#So, phase of the angle modulates signal is Q = 2*pi*(10**6*t)+2*math.sin(2*pi*(10**3)*t)
#Insmath.tanmath.taneous frequency = dQ/dt = 2*pi*(10**6)+ 4*pi*(10**3)*math.sin(2*pi*(10**3)*t)
#For Insmath.tanmath.taneous frequency at 0.25ms, Substituting t = 0.25ms in Insmath.tanmath.taneous frequency
#Insmath.tanmath.taneous frequency is expressed as f1_rad for frequency in radians per second
f1_rad = 2*math.pi*(10**6)+ 4*math.pi*(10**3)*math.sin(2*math.pi*(10**3)*0.00025)
#Insmath.tanmath.taneous frequency is expressed as f1_hz for frequency in hertz
f1_hz = f1_rad/(2*math.pi)
print 'the Instantaneous frequency at time t = 0.25ms is ',f1_rad,' rad/sec = ',f1_hz,' Hz'
#For Insmath.tanmath.taneous frequency at 0.25ms, Substituting t = 0.5ms in Insmath.tanmath.taneous frequency
#Insmath.tanmath.taneous frequency is expressed as f2rad for frequency in radians per second
f2_rad = 2*math.pi*(10**6)+ 4*math.pi*(10**3)*math.sin(2*math.pi*(10**3)*0.0005)
#Insmath.tanmath.taneous frequency is expressed as f2hz for frequency in hertz
f2_hz = f2_rad/(2*math.pi)
print 'the Instantaneous frequency at time t = 0.5ms is ',f2_rad,' rad/sec = ',f2_hz,' Hz'
#Maximum phase deviation = max[2*math.sin(2*pi*(10**3)*t)] = 2*1
maxDp = 2;
print 'Maximum phase deviation is ',maxDp,' rad'
#Maximum frequency deviation = max[4*pi*(10**3)*math.sin(2*pi*(10**3)*t)] = 4*pi*(10**3)*1
maxDf = 4*math.pi*(10**3)*1;
print 'Maximum frequency deviation is %.4f'%maxDf,' Hz'
#print ('in rad',maxDf,'Maximum frequency deviation is')
#In the textbook the calculated value of max frequency devaition is = 2000 Hz, in reality the value = 12566.371 Hz
```

In [2]:

```
import math
#Given modulating signal m(t) = 2*math.sin(2*pi*(10**3)*t), B for phase modulation Bp = 10 & for fequency modulation Bf = 10
Bp = 10.
Bf = 10.
#So Amplitude of modulating signal is Am = 2 metres
Am = 2.
#Frequency of modulating signal is fm = 1000 hertz
fm = 1000.
#Bandwidth = 2*(1+B)*fm
#Bandwidth for phase modulation with modulating signal m(t) is bw_pm = 2*(1+Bp)*fm
bw_pm = 2.*(1+10)*1000
#Bandwidth for frequency modulation with modulating signal m(t) is bw_fm = 2*(1+Bf)*fm
bw_fm = 2*(1+10)*1000.
print 'Bandwidth for phase modulation ',bw_pm,' Hz'
print 'Bandwidth for frequency modulation ',bw_fm,' Hz'
#Bandwidth for phase & frequency modulation if frequency of modulating signal is doubled i.e fm = 2000 hertz
#Bp & Bf after frequency of modulating signal is doubled
#Bp = kp*Am, observing the equation as there is no change in amplitude Bp = 10
Bp = 10.
#Bf = kf*Am/fm, observing the equation as there is change in frequency Bf = 10/2 = 5
Bf = 5.
#Bandwidth for phase modulation if frequency of modulating signal is doubled is bw_double_pm = 2*(1+Bp)*fm
bw_double_pm = 2.*(1+10)*2000
#Bandwidth for frequency modulation if frequency of modulating signal is doubled is bw_double_fm = 2*(1+Bf)*fm
bw_double_fm = 2*(1+5)*2000.
print 'Bandwidth for phase modulation for doubled frequency ',bw_double_pm,' Hz'
print 'bandwidth for frequency modulation for doubled frequency ',bw_double_fm,' Hz'
#Bandwidth for phase & frequency modulation if amplitude of modulating signal is halfed i.e Am = 1 metre
#Bp & Bf after amplitude of modulating signal is halfed
#Bp = kp*Am, observing the equation as there is change in amplitude Bp = 10/2 = 5
Bp = 5
#Bf = kf*Am/fm, observing the equation as there is change in amplitude Bf = 5/2 = 2.5
Bf = 2.5
#Bandwidth for phase modulation if frequency of modulating signal is doubled is bw_halfed_pm = 2*(1+Bp)*fm
bw_halfed_pm = 2*(1+5)*2000
#Bandwidth for frequency modulation if frequency of modulating signal is doubled is bw_halfed_fm = 2*(1+Bf)*fm
bw_halfed_fm = 2*(1+2.5)*2000
print 'Bandwidth for phase modulation for halfed amplitude ',bw_halfed_pm,' Hz'
print 'Bandwidth for frequency modulation for halfed amplitude ',bw_halfed_fm,' Hz'
```