In [1]:

```
from math import log
from __future__ import division
n1=1.46## core refractive index
n=1## refractive index due to air
r=((n1-n)/(n1+n))**2#
r1=0.03## r take upto two decimal place
l_s=-10*log(1-r1)/log(10)## fiber loss in db
l_t=2*l_s## total loss in db
print "The fiber loss =%0.2f db"%( l_s)#
print "\n there is a similar loss at the other interface"#
print "\n The total fiber loss =%0.2f db"%( l_t)
```

In [3]:

```
from math import log,pi,acos
from __future__ import division
n1=1.46## core refractive index
n=1## refractive index due to air
a=25*10**-6## core radius in m
y=3*10**-6## in m
A=(y/a)*(1-(y/(2*a))**2)**0.5#
B=acos(y/(2*a))#
C=n1/n#
M=(16*C**2)/(pi*(1+C)**4)#
n_lat=M*(2*B-A)## coupling efficiency for multimode step index fiber
L_lat=-10*log(n_lat)/log(10)## insertion loss for lateral misalignment
n_lat1=(1/pi)*(2*B-A)## coupling efficiency when there is no air gap
L_lat1=-10*log(n_lat1)/log(10)## insertion loss for lateral misalignment when there is no air gap
print "The coupling efficiency for multimode step index fiber =%0.2f"%( n_lat)#
print "\n The insertion loss for lateral misalignment =%0.2f dB"%( L_lat)#
print "\n The coupling efficiency when there is no air gap =%0.2f"%( n_lat1)#
print "\n The insertion loss for lateral misalignment when there is no air gap =%0.2f dB"%( L_lat1)
```

In [4]:

```
from math import log,acos,pi,sqrt
from __future__ import division
n1=1.50## core refractive index
n=1## refractive index due to air
a=25*10**-6## core radius in m
y=4*10**-6## in m
A=(y/a)*(1-(y/(2*a))**2)**0.5#
B=acos(y/(2*a))#
C=n1/n#
M=(16*C**2)/(pi*(1+C)**4)#
n_lat=M*(2*B-A)## coupling efficiency for multimode step index fiber
L_lat=-10*log(n_lat)/log(10)## insertion loss for lateral misalignment
dx=4*(3.14/180)## angular misalignment in radian
dl=0.02## relative index difference
NA=n1*sqrt(2*dl)## numerical aperture
n_ang=1-(0.069/(3.14*NA))## coupling efficiency due to angular misalignment
L_ang=-10*log(n_ang)/log(10)## loss due to angular misalignment
Lt=L_lat+L_ang## total insertion loss in dB
print "The total insertion loss =%0.2f dB"%( Lt)#
print "\n the answer is wrong in the textbook"
```

In [6]:

```
from math import log,acos,pi,sqrt
from __future__ import division
n1=1.46## core refractive index
n=1## refractive index due to air
a=1## core radius in m
y=0.12## lateral offset
A=(y/a)*(1-(y/(2*a))**2)**0.5#
B=acos(y/(2*a))#
C=n1/n#
M=(16*C**2)/(pi*(1+C)**4)#
n_lat=M*(2*B-A)## coupling efficiency when there is a smsll air gap
L_lat=-10*log(n_lat)/log(10)## insertion loss when there is a smsll air gap
n_lat1=(1/pi)*(2*B-A)## coupling efficiency when the joint is indexed matched
L_lat1=-10*log(n_lat1)/log(10)## insertion loss when the joint is indexed matched
print "The insertion loss when there is a smsll air gap =%0.2f dB"%( L_lat)#
print "\n The insertion loss when the joint is indexed matched =%0.2f dB"%( L_lat1)
```

In [1]:

```
from math import log
from __future__ import division
d1=60*10**-6## core diameter of fiber 1 in m
d2=50*10**-6## core diameter of fiber 1 in m
NA1=0.25## numerical aerture of fiber 1
NA2=0.22## numerical aerture of fiber 2
a1=2.0## for fiber 1
a2=1.9## for fiber 2
n_cd=(d2/d1)**2#
n_NA=(NA2/NA1)**2#
n_a=(1+(2/a1))/(1+(2/a2))#
n_t=n_cd*n_NA*n_a## total coupling efficiency
Lt=-10*log(n_t)/log(10)## total loss at the joint in dB
print "The total coupling efficiency in the frw direction =%0.2f"%( n_t)#
print "\n The total loss at the joint in the frw direction =%0.2f dB"%( Lt)#
print "\n In the backward direction n_cd & n_a are all unity therefore there will be no loss in the backward direction of transmission of the signal "
```

In [2]:

```
from math import log
from __future__ import division
d1=80*10**-6## core diameter of fiber 1 in m
d2=60*10**-6## core diameter of fiber 1 in m
NA1=0.25## numerical aerture of fiber 1
NA2=0.20## numerical aerture of fiber 2
a1=1.9## for fiber 1
a2=2.1## for fiber 2
n_cd=(d2/d1)**2#
n_NA=(NA2/NA1)**2#
n_a=(1+(2/a1))/(1+(2/a2))#
n_t=n_cd*n_NA*n_a## total coupling efficiency in the frw direction
Lt=-10*log(n_t)/log(10)## total loss at the joint in the frw direction in dB
n_cd1=1#
n_NA1=1#
n_a1=(1+(2/a2))/(1+(2/a1))#
n_t1=n_cd1*n_NA1*n_a1## total coupling efficiency in the backward direction
Lt1=-10*log(n_t1)/log(10)## total loss at the joint in the backward direction in dB
print "The total loss at the joint in the frw direction =%0.2f dB"%( Lt)#
print "\n The total loss at the joint in the backward direction =%0.2f dB"%( Lt1)
```

In [3]:

```
from math import log,acos,pi
from __future__ import division
n1=1.5## core refractive index
n=1.47## refractive index due to air
a=1## core radius in m
y=0.12## lateral offset
A=(y/a)*(1-(y/(2*a))**2)**0.5#
B=acos(y/(2*a))#
C=n1/n#
M=(16*C**2)/(pi*(1+C)**4)#
n_lat=M*(2*B-A)## coupling efficiency of the splice
L_lat=-10*log(n_lat)/log(10)## insertion loss of the splice
print "The insertion loss of the splice =%0.2f dB"%( L_lat)
```

In [4]:

```
from math import pi,sqrt
from __future__ import division
L_f=0.036#
n_f=10**(-0.036)#
# here we get a quadratic equation in n1 and on solving we get
n1=(2.17+sqrt((-2.17)**2-4*1*1))/2## refractive index of the fiber core
print "The refractive index of the fiber core =%0.2f"%( n1)
```

In [1]:

```
from math import pi
from __future__ import division
n1=1.46## core refractive index
n=4## refractive index due to air
x=pi/180#
A=(16*n1**2)/((1+n1)**4)#
B=n*x#
n_ang=10**(-0.06)## angular coupling efficiency
NA=B/((pi)*(1-(n_ang/A)))## numerical aperture
print "The numerical aperture =%0.2f"%( NA)
```

In [3]:

```
from math import log,pi
from __future__ import division
y=5*10**-6## lateral misalignment in m
a=25*10**-6## core diameter in m
Lt=0.85*(y/a)## misalignment loss
n_c=1-Lt## coupling efficiency
L_i=-10*log(n_c)/log(10)## insertion loss in dB
Lt1=0.75*(y/a)## misalignment loss if we have both guided and leaky modes
n_c1=1-Lt1## coupling efficiency
L_i1=-10*log(n_c1)/log(10)## insertion loss in dB if we have both guided and leaky modes
print "The insertion loss =%0.2f dB"%( L_i)#
print "\n The insertion loss,if we have both guided and leaky modes =%0.2f dB"%( L_i1)
```

In [4]:

```
from math import log,pi
from __future__ import division
n1=1.5## core refractive index
n=1## refractive index due to air
x=5*pi/180#
C=n1/n#
A=(16*C**2)/((1+C)**4)#
B=n*x#
NA=0.22## numerical aperture
n_ang=A*(1-(B/(pi*NA)))## angular coupling efficiency
L_ang=-10*log(n_ang)/log(10)## inserion loss when NA=0.22
NA1=0.32## numerical aperture
n_ang1=A*(1-(B/(pi*NA1)))## angular coupling efficiency
L_ang1=-10*log(n_ang1)/log(10)## inserion loss when NA=0.32
print "The inserion loss when NA=0.22 =%0.2f dB"%( L_ang)#
print "\n The inserion loss when NA=0.32 =%0.2f dB"%( L_ang1)
```

In [5]:

```
from math import pi
from __future__ import division
V=2.50## normalised frequency
n1=1.5## core refractive index
a=4.5*10**-6## core radius in m
NA=0.2## numerical aperture
y=3*10**-6## lateral misalignment in m
w=a*((0.65+1.62*(V)**-1.5+2.88*(V)**-6)/2**0.5)## normalised spot size in m
T1=2.17*(y/w)**2## Loss due to lateral offset in dB
x=(pi/180)*w#
Ta=2.17*((x*n1*V)/(a*NA))**2## loss due to angular misalignment in dB
T=T1+Ta## total insertion loss in dB
print "The total insertion loss =%0.2f dB"%( T)#
print "\n The answer is wrong in the textbook"
```

In [6]:

```
from math import log
from __future__ import division
P1=65## optical power in uW
P2=0.005## output power at port 2 in uW
P3=24## output power at port 3 in uW
P4=26.5## output power at port 4 in uW
Le=10*log(P1/(P3+P4))/log(10)## Excess loss in dB
Le1=10*log(P1/P3)/log(10)## insertion loss port 1 to 3 in dB
Le2=10*log(P1/P4)/log(10)## insertion loss port 1 to 4 in dB
ct=10*log(P2/P1)/log(10)## cross talk in dB
sr=(P3/(P3+P4))*100## split ratio
print "The Excess loss =%0.2f dB"%( Le)#
print "\n The insertion loss port 1 to 3 =%0.2f dB"%( Le1)#
print "\n The insertion loss port 1 to 4 =%0.2f dB"%( Le2)#
print "\n The cross talk =%0.2f dB"%( ct)#
print "\n The split ratio =%0.2f %%"%( sr)
```

In [7]:

```
from math import log
from __future__ import division
n=1#
n1=1.48#
r=((n1-n)/(n1+n))**2## fresnel's reflection
Ls=-10*log(1-r)/log(10)## optical loss in dB
Lt=2*Ls## total fresnel loss
print "The total fresnel loss =%0.2f dB"%( Lt)
```

In [8]:

```
from math import log
from __future__ import division
NA1=0.32## numerical aperture for fiber1
NA2=0.22## numerical aperture for fiber2
Lc=20*log(NA1/NA2)/log(10)## NA mismatch coupling loss
print "The NA mismatch coupling loss =%0.2f dB"%( Lc)
```

In [9]:

```
from math import log
from __future__ import division
P0=250## optical power in uW
P1=80## output power at port 1 in uW
P2=70## output power at port 2 in uW
P3=5*10**-3## output power at port 3 in uW
cr=(P2/(P1+P2))*100## coupling ratio
Le=10*log(P0/(P1+P2))/log(10)## Excess loss in dB
Le1=10*log(P0/P1)/log(10)## insertion loss port 0 to 1 in dB
Le2=10*log(P0/P2)/log(10)## insertion loss port 0 to 2 in dB
ct=10*log(P3/P0)/log(10)## cross talk in dB
print "The coupling ratio =%0.2f %%"%( cr)#
print "\n The Excess loss =%0.2f dB"%( Le)#
print "\n The insertion loss port 0 to 1 =%0.2f dB"%( Le1)#
print "\n The insertion loss port 0 to 2 =%0.2f dB"%( Le2)#
print "\n The cross talk =%0.2f dB"%( ct)
```

In [10]:

```
from math import log
from __future__ import division
P_21=4/5## ratio of the input available at port2
P_31=1/5## ratio of the input available at port3
Lt=-10*log(P_21)/log(10)## throughput loss
Lp=-10*log(P_31)/log(10)## tap loss
Le=-10*log(P_21+P_31)/log(10)## excess loss
print "The throughput loss =%0.2f dB"%( Lt)#
print "\n The tap loss =%0.2f dB"%( Lp)#
print "\n Directionality=-10*log(0/Pi=infinity)"#
print "\n The excess loss =%d dB"%( Le)
```

In [11]:

```
from math import log
from __future__ import division
Le=4## excess loss in dB
D=60## Directionality in dB
P_41=10**-6## the ratio of P4 to P1
P_31=0.670/5## the ratio of P3 to P1
P_21=P_31*4## the ratio of P2 to P1
Lt=-10*log(P_21)/log(10)## throughput loss
Lp=-10*log(P_31)/log(10)## tap loss
Ls=-10*log(0.670)/log(10)## loss due to radiation scattering in dB
print "The fraction of the input power goes to each of the ports =%0.2f dB"%( P_21)#
print "\n The throughput loss =%0.2f dB"%( Lt)#
print "\n The tap loss =%0.2f dB"%( Lp)#
print "\n The loss due to radiation scattering =%0.2f dB"%( Ls)
```

In [12]:

```
from math import log
from __future__ import division
L1=1.5## length in km
L2=2/1000## length in km
Pi=50.1*10**-6## optical power in W
Po=385.4*10**-6## output power in W
a=(10/(L1-L2))*log(Po/Pi)/log(10)## attenuation per km
print "The attenuation per km =%0.2f dB/km"%( a)
```

In [13]:

```
from __future__ import division
Psc=5.31*10**-9##
Popt=98.45*10**-6##
L=5.99## length in km
asc=(4.343*10**5/L)*(Psc/Popt)## scattering loss in the fiber in dB
print "The scattering loss in the fiber =%0.2f dB/km"%( asc)
```