import math
#Variable declaration
v2=10.7 #increased voltage
v1=2.1 #voltage
l1=2 #length in Km
l2=0.002 #length in Km
#Calculation
a=(10/(l1-l2))*math.log10(v2/v1) #Attenuation
u=0.2/(l1-l2) #incertainty
#Result
print'Attenuation per Km = %.1f dB Km^-1'%a
print'Uncertainty = ± %.1f dB'%u
import math
#Variable declaration
t2=100 #time in sec
t1=10 #time in sec
ti=0.525 #micro voltage
to=0.021 #micro voltage
C=1.64*10**4 #thermal capacity
tin=4.3*10**-4 #maximum temperature rise
pop=98*10**-3 #optical power
#Calculation
tc=(t2-t1)/(math.log(ti)-math.log(to)) #time constant for the calorimeter
a=(C*tin)/(pop*tc) #absortion loss
#Result
print'Absorption loss in dB = %.1f dB Km^-1'%a
import math
#Variable declaration
Vsc=6.14*10**-9 #voltage
Vop=153.38*10**-6 #voltage without scattering
l=2.92 #length of fibre in cm
#Calculation
a=4.343*10**5*Vsc/(l*Vop) #scattering loss
#Result
print'Scattering loss in dB = %.1f dB Km^-1'%a
import math
#Variable declaration
t1=12.6*10**-9 #time in sec
t2=0.3*10**-9 #time in sec
#Calculation
t=math.sqrt(t1**2-t2**2)/1.2 #pulse broadening
Bop=0.44/t #bandwidth length product
#Result
print'(a) 3dB pulse broadening = %.1f ns km^-1'%(t*10**9)
print'(b) Fiber bandwidth–length product = %.1f MHz km'%(Bop*10**-6)
import math
#Variable declaration
A=6.2 #output pattern size
D=10 #screen position
#Calculation
NA=A/math.sqrt(A**2+(4*D**2)) #numerical aperture
#Result
print'Numerical aperture = %.2f'%NA
#Variable declaration
phi=4 #angular velocity
l=0.1 #length in meter
we=300*10**-6 #shadow pulse width
#Calculation
s=l*phi #shadow velocity
d=we*s #fibre diameter
#Result
print'Outer fibre diameter = %.1f um'%(d*10**6)
import math
#Variable declaration
a=5*10**-3 #optical signal power
b=20*10**-6 #optical signal power
c=0.3*10**-3 #optical signal power
d=800*10**-9 #optical signal power
#Calculation
adb=10*math.log10(a*10**3) #in dBm
bdb=10*math.log10(b*10**3) #in dBm
cdb=10*math.log10(c*10**6) #in dBu
ddb=10*math.log10(d*10**6) #in dBu
#Result
print'(a) For a 1 mW reference power level'
print' optical signal power of 5 mW = %.2f dBm'%adb
print' optical signal power of 20 uW = %.2f dBm'%bdb
print'\n(b) For a 1 μW reference power level'
print' optical signal power of 0.3 mW = %.2f dBu'%cdb #value given in a textbook is incorrect
print' optical signal power of 800 nW = %.2f dBu'%ddb
import math
#Variable declaration
NA=0.02 #numerical aperture
yr=0.7*10**-3 #Rayleigh scattering coefficient
c=2.998*10**8 #speed of light
wo=50*10**-9 #pulse time
n1=1.5
#Calculation
p=0.5*(((NA**2)*yr*wo*c)/(4*(n1**3))) #power ratio
pdb=10*math.log10(p*10**3) #in dB
#Result
print'Power ratio = %.3f X 10^-7'%(p*10**7) #value given in a textbook is incorrect
print'Power ratio in dB = %.1f dB'%pdb #value given in a textbook is incorrect