from __future__ import division
output=13 #laser output
sensitivity=-31 #APD sensitivity
coupling_loss=0.5
L=80 #length in km
sl=0.1 #loss correspond to one splice in dB
fl=0.35 #fiber loss in dB/km
noise=1.5
allowed_loss=output-sensitivity
splices_loss=(L-1)*sl
fiber_loss=L*fl
margin=allowed_loss-(splices_loss+fiber_loss+coupling_loss+noise)
print "Final margin is %.1f dB." %margin
from numpy import sqrt
L=10
ts=10
tD=8
tmod=L*6
tt=L*2
Tsys=1.1*sqrt(ts**2+tmod**2+tt**2+tD**2)
Bt=0.7/Tsys
Bt=Bt*10**3
print "Maximum bit rate for link using NRZ data format is %.2f Mbits/sec." %Bt
#calculation error in the book.