import math
#Input signal strength Si = 0.5 W
Si = 0.5;
#Gaussian Power Spectral Density n = 10**(-10) W/Hz
n = 10**(-10);
#Baseband cutoff signal fM = 15 kHz
fM = 15 * 10**3;
#Maximum frequency deviation Df = 60 kHz
Df = 60 * 10**3;
#Average power of the modulating signal mt = 0.1 W
mt = 0.1;
SNR = (3/(4*math.pi**2))*((Df/fM)**2)*mt**2*(Si/(n*fM));
print 'SNR is %.4f'%(10*math.log10(SNR)),' dB'
#Part b
#Required SNR at output>40 dB = 10000
#From (a), required Si/0.5 > 10000/4052.8
#Or, required Si > 1.2337 W
#Since, channel loss is 20 dB ( = 100),
#Required transmitter power > 1.2337*100 = 123.37
print ('Required transmitter power > 1.2337 x 100 = 123.37 ');
#Baseband cutoff signal fM = 15 kHz
fM = 15. * 10**3;
#Maximum frequency deviation Df = 60 kHz
Df = 60 * 10**3;
#Figure of Merit for FM is G_FM
G_FM = (3./2)*(Df/fM)**2;
print 'Figure of Merit for FM system is ',G_FM
#Ratio of Figure of Merits of FM and AM systems is R
R = G_FM/(1./3);
print 'Ratio of Figure of Merits for FM and AM systems is ',R
Df_new = 2*Df;
#Figure of Merit for FM when bandwidth is doubled is G_FM_new
G_FM_new = (3./2)*(Df_new/fM)**2;
#Ratio of Figure of Merits of FM and AM systems when bandwidth is doubled is R_new
R_new = G_FM_new/(1./3);
print 'Ratio of Figure of Merits for FM and AM systems when bandwidth is doubled is ',R_new
import math
#Resismath.tance R = 1000 Ohm
R = 10**3;
#Capacitance C = 0.1 * 10**-6 F
C = 0.1*10**-6;
#Break point for RC filter is f1
f1 = 1/(2*math.pi*R*C)
#Baseband bandwidth of signal fM = 15 kHz
fM = 15 * 10**3;
Gain = math.atan(fM/f1)/(3*(f1/fM)*(1 - (f1/fM)*math.atan(fM/f1)));
print 'Initial Gain is %.4f'%(10*math.log10(Gain)),' dB'
#New Baseband bandwidth of signal fM_new = 15 kHz
fM_new = 2*15 * 10**3;
Gain_new = math.atan(fM_new/f1)/(3*(f1/fM_new)*(1 - (f1/fM_new)*math.atan(fM_new/f1)));
print 'Final Gain is %.4f'%(10*math.log10(Gain_new)),' dB'
import math
#Baseband cutoff signal fM = 15 kHz
fM = 15. * 10**3;
#Carrier filter bandwidth is B = 60 kHz
B = 60. * 10**3;
#RMS frequency division Df_RMS = 30 kHz
Df_RMS = 30. * 10**3;
#Let a = Df_RMS/fM for substitution
a = Df_RMS/fM;
#Let b = fM/B for substitution
b = fM/B;
#Let input SNR 1 be I_SNR1 = 10 dB = 10
I_SNR1 = 10;
#Output SNR is O_SNR1
O_SNR1 = (3*(a**2)*I_SNR1)/(1+6*((2/math.pi)**0.5)*I_SNR1*math.exp(-(b)*I_SNR1));
print 'Output SNR is %.4f'%(10*math.log10(O_SNR1)),' dB'
#Let input SNR 2 be I_SNR2 = 20 dB = 100
I_SNR2 = 100;
#Output SNR is O_SNR2
O_SNR2 = (3*(a**2)*I_SNR2)/(1+6*((2/math.pi)**0.5)*I_SNR2*math.exp(-(b)*I_SNR2));
#Solution given in the book is 13.5431 which is fallacious, the correct answer is 24.32444
print 'Output SNR is %.4f'%(10*math.log10(O_SNR2)),' dB'
#Let input SNR 3 be I_SNR3 = 30 dB = 1000
I_SNR3 = 1000;
#Output SNR is O_SNR3
O_SNR3 = (3*(a**2)*I_SNR3)/(1+6*((2/math.pi)**0.5)*I_SNR3*math.exp(-(b)*I_SNR3));
print 'Output SNR is %.4f'%(10*math.log10(O_SNR3)),' dB'