In [6]:

```
import math
#Given Data:
m=4 #order
N=1./5000*10**-2 #N=(a+b) grating element(cm)
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
#for longest wavelength, sin(theta)=1
lamda=(N/m) #longest wavelength
print"The longest wavelength is =" ,lamda,"m"
```

In [22]:

```
import math
#Given Data:
m=1 #order
lamda=6.5*10**-7 #Wavelength of red light
theta=30*3.142/180 #angle of diffraction
#Calculations:
#We know, a*sin(theta)=m*lamda
a=m*lamda/math.sin(theta) #width of slit
print"width of slit is = ",a,"m"
```

In [7]:

```
import math
#Given Data:
m=1 #order
lamda=4*10**-7 #Wavelength of light
a=10**-6 #width of slit
#Calculations:
#We know, a*sin(theta)=m*lamda
theta=math.asin(m*lamda/a)*180/3.142 #angular position in first minima
print"angular position in first minima is =",theta,"degrees"
```

In [8]:

```
import math
#Given Data:
m=1 #order
lamda1=4*10**-7 #Wavelength of light
lamda2=7*10**-7 #Wavelength of light
n=1./6000*10**-2 #n=(a+b) grating element
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
theta1=math.asin(m*lamda1/n)*(180/3.142) #angle of diffraction
theta2=math.asin(m*lamda2/n)*(180/3.142) #angle of diffraction
d=theta2-theta1 #angular breadth of first order visible spectrum
print"angular breadth of first order visible spectrum is = ",d,"degrees"
```

In [1]:

```
import math
#Given Data:
m=1 #order
lamda=6.56*10**-7 #Wavelength of red light
theta=18.25*math.pi/180 #angle of diffraction
W=2*10**-2 #width of grating
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
N=math.sin(theta)/(m*lamda) #N-number of lines per m, N=1/(a+b)
Tn=N*W #Total number of lines on grating
print"Total number of lines on grating is =",Tn
```

In [13]:

```
import math
#Given Data:
GE=2.54/15000*10**-2 #GE=(a+b) grating element
lamda1=4*10**-7 #Wavelength of light
lamda2=7*10**-7 #Wavelength of light
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
theta11=math.asin(1*lamda1/GE)*180/math.pi #angular position of first minima for lamda1
theta12=math.asin(2*lamda1/GE)*180/math.pi #angular position of second minima for lamda1
theta13=math.asin(3*lamda1/GE)*180/math.pi #angular position of third minima for lamda1
theta21=math.asin(1*lamda2/GE)*180/math.pi #angular position of first minima for lamda2
theta22=math.asin(2*lamda2/GE)*180/math.pi #angular position of second minima for lamda2
theta23=math.asin(1)*180/math.pi #angular position of third minima for lamda2
print"Thus the angular position for lamda1 and lamda2 are as follows:"
print"First order:",theta11,"degrees"
print"",theta21,"degrees --Isolated"
print"Second order:",theta12,"degrees"
print"",theta22,"degrees --Overlap"
print"Third order: ",theta13,"degrees"
print"",theta23," degrees --Overlap "
```

In [16]:

```
import math
#Given Data:
lamda=5.893*10**-7 #Wavelength of light
d=0.01*10**-2 #width of slit (a=d)
f=1 #distance between screen and slit
#Calculations:
x=f*lamda/d #separation between central maxima and first minima
print"Separation between central maxima and first minima is = ",x,"m"
```

In [1]:

```
import math
#Given Data:
m=1 #order
lamda=6*10**-7 #Wavelength of light
a=12*10**-7 #width of slit
#Calculations:
#We know, a*sin(theta)=m*lamda
theta=math.asin(m*lamda/a)*180/math.pi #angular position in first minima
print"Half angular width of first maxima is =",theta,"Degrees"
```

In [19]:

```
import math
#Given Data:
lamda=6*10**-7 #Wavelength of light
a=0.02*10**-2 #width of slit (a=d)
f=2 #distance between screen and slit
#Calculations:
#We know, a*sin(theta)=m*lamda, here m=1
theta=math.asin(lamda/a)*180*60/math.pi #angular position in first minima (1 degree=60 minutes)
print"Total angular width is =",2*theta,"minutes"
x=f*lamda/a #separation between central maxima and first minima
print"Linear width is = ",2*x,"m"
```

In [20]:

```
import math
#Given Data:
a=0.14*10**-3 #width of slit
n=2 #order
y=1.6*10**-2 #separation between second dark band and central bright band
D=2 #distance between screen and slit
#Calculations:
theta=y/D #from diagram
#We know, a*sin(theta)=n*lamda
#here sin(theta)=theta
lamda=a*theta/n #wavelength of light
print"wavelength of light is =",lamda,"m"
```

In [21]:

```
import math
#Given Data:
lamda=6.328*10**-7 #Wavelength of light
N=1./6000*10**-2 #N=(a+b) grating element
#Calculations:
#We know, N*sin(theta)=m*lamda
theta1=math.asin(1*lamda/N)*180/math.pi #angular position in first order maxima,m=1
print"Angular position in first order maxima is =",theta1,"Degrees"
theta2=math.asin(2*lamda/N)*180/math.pi #angular position in second order maxima,m=2
print"Angular position in second order maxima is = ",theta2,"Degrees"
```

In [9]:

```
import math
#Given Data:
lamda1=6*10**-7 #wavelength of yellow light
lamda2=4.8*10**-7 #wavelength of blue light
theta=(math.asin(3/4)) #angle of diffraction
#Calculations:
#for consecutive bands, n*lamda1=(n+1)*lamda2. thus,
n=lamda2/(lamda1-lamda2) #order
#We know, (a+b)*sin(theta)=m*lamda
N=n*lamda1/(3./4) #N=(a+b) grating element
print"Grating element (a+b) is =",N,"m"
```

In [7]:

```
import math
#Given Data:
a=0.2*10**-3 #width of slit
n=1 #order
y=0.5*10**-2 #separation between first minima and central bright band
D=2 #distance between screen and slit
#Calculations:
theta=y/D #from diagram
#We know, a*sin(theta)=n*lamda
#here sin(theta)=theta
lamda=a*theta/n #wavelength of light
print"wavelength of light is = ",lamda,"m"
```

In [20]:

```
import math
#Given Data:
lamda1=5.4*10**-7 #Wavelength of light
lamda2=4.05*10**-7 #Wavelength of light
theta=30*math.pi/180 #angle of diffraction
#Calculations:
#We know, (a+b)*sin(theta)=n*lamda
#n*lamda1=(n+1)*lamda2, we get
n=3
N=math.sin(theta)/(n*lamda1)*10**-2 #Number of lines per m= 1/(a+b)*10^-2
print"Number of lines per cm is = ",N
```

In [21]:

```
import math
#Given Data:
GE=1./6000*10**-2 #GE=(a+b) grating element
lamda1=5.893*10**-7 #Wavelength of light
lamda2=5.896*10**-7 #Wavelength of light
m=2 #order
#Calculations:
theta1=math.asin(m*lamda1/GE)*180/math.pi #angular position in first minima
theta2=math.asin(m*lamda2/GE)*180/math.pi #angular position in second minima
a_s=(theta2-theta1) #Angular separation in minutes
print"Angular separation is =",a_s,"Degrees"
dlamda=lamda2-lamda1 #difference in wavelength
lamda=(lamda2+lamda1)/2 #Mean wavelength
#We know that R.P.=lamda/dlamda=m*N
N=lamda/dlamda/m #Number of lines on grating for first order
print"Number of lines on grating for first order is =",N
print"But, number of lines per cm on grating is 6000. \n Which is greater than number of lines per cm needed for resolution."
print"Hence, both lines will be well resolved in 2nd order."
```

In [26]:

```
import math
#Given Data:
d=0.04*10**-2 #Separation between slits
D=1.7 #distance between screen and slit
B=0.25*10**-2 #Fringe spacing
#Calculations:
#We know,B=D*lamda/d
lamda=B*d/D #Wavelength of light
print"Wavelength of light is = ",lamda,"m"
#The condition for missing order is,
#(a+b)/a = m/n
b=0.04*10**-2 #Separation in slits
a=0.08*10**-3 #Slit width
n=(a+b)/a #missing orders for m=1,2,3
n1=1*n
n2=2*n
n3=3*n
print"Missing orders are =",n1,",",n2,",",n3
```

In [2]:

```
import math
#Given Data:
N=2.54/2620*10**-2 #N=(a+b) grating element
lamda=5*10**-7 #Wavelength of red light
#Calculations:
#We know, (a+b)*sin(theta)=n*lamda
#maximum value of sin(theta)=1
n=N/lamda #Maximum number of orders visible
print"Maximum number of orders visible is =",n
```

In [5]:

```
import math
#Given Data:
N=1./4000*10**-2 #N=(a+b) grating element
lamda1=5*10**-7 #Wavelength of light
lamda2=7.5*10**-7 #Wavelength of light
#Calculations:
#We know, (a+b)*sin(theta)=n*lamda
#maximum value of sin(theta)=1
n1=N/lamda1 #Maximum number of orders visible
n2=N/lamda2 #Maximum number of orders visible
print"The observed number of orders range between =",n2,"to",n1
```

In [6]:

```
import math
#Given Data:
n=5 #order
lamda=6*10**-7 #Wavelength of light
#Calculations:
#We know, a*sin(theta)=n*lamda
#n*lamda=n1*lamda1
lamda1=n*lamda/4 #for n1=4
print"For n1=4 wavelength is =",lamda1,"m"
lamda2=n*lamda/5 #for n1=5
print"For n1=5 wavelength is =",lamda2,"m"
lamda3=n*lamda/6 #for n1=6
print"For n1=5 wavelength is =",lamda3,"m"
lamda4=n*lamda/7 #for n1=7
print"For n1=5 wavelength is =",lamda4,"m"
lamda5=n*lamda/8 #for n1=8
print"For n1=5 wavelength is =",lamda5,"m"
print"So,in the grating spectrum spectrum lines with wavelengths n1=6 and n1=7 will coincide with fifth order line of 6*10^-7 m"
```

In [13]:

```
import math
#Given Data:
GE=18000*10**-10 #GE=(a+b) grating element
lamda=5*10**-7 #Wavelength of red light
#Calculations:
DP1=1./sqrt(GE**2-lamda**2)*10**-10 #Dispersive power
print"Dispersive power for first order is =",DP1,"rad/Angstrom"
m=3
DP2=1/sqrt((GE/m)**2-lamda**2)*10**-10 #Dispersive power
print"Dispersive power for second order is =",DP2,"rad/Angstrom"
```

In [15]:

```
import math
#Given Data:
N=2.54/15000*10**-2 #N=(a+b) grating element
lamda=5.9*10**-7 #Wavelength of light
m=2 #order
f=25*10**-2 #focal length of lens
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
theta=math.asin(m*lamda/N) #angular position in first minima
Ad=m/N/cos(theta) #angular dispersion
ld=f*Ad*10**-8 #linear dispersion (dx/dl) in cm/angstrom
print"Linear dispersion in spectrograph is =",ld,"cm/angstrom"
dlamda=(5896-5890) #difference in wavelength
dx=ld*dlamda*10**-2 #separation between spectral lines in meter
print"Separation between spectral lines is =",dx,"m"
```

In [16]:

```
import math
#Given Data:
m=1 #order
lamda1=5.89*10**-7 #Wavelength of light
lamda2=5.896*10**-7 #Wavelength of light
#Calculations:
dlamda=lamda2-lamda1 #difference in wavelength
lamda=(lamda2+lamda1)/2 #Mean wavelength
#We know that R.P.=m*N=lamda/dlamda
N=lamda/dlamda/m #minimum number of lines which will just resolve
print"Minimum number of lines which will just resolve is =",N
```

In [19]:

```
import math
#Given Data:
N=5*5000 #N=W/(a+b) Number of lines on grating
m=2 #order
lamda=6*10**-7 #Wavelength of light
#Calculations:
#(i)
RP=m*N #Resolving power
print"(i)Resolving power is =",RP
#(ii)
#We know that R.P.=lamda/dlamda
dlamda=lamda/RP #Smallest wavelength which can be resolved
print"(ii)Smallest wavelength which can be resolved is =",dlamda,"m"
```

In [22]:

```
import math
#Given Data:
GE=1./4000*10**-2 #GE=(a+b) grating element
lamda=5*10**-7 #Wavelength of red light
m=3 #order
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
theta=math.asin(m*lamda/GE) #ngular position in first minima
DP=m/(GE*math.cos(theta))*10**-2 #Dispersive power
print"Dispersive power is =",DP
```

In [23]:

```
import math
#Given Data:
m=2 #order
lamda=6*10**-7 #Wavelength of light
dlamda=6*10**-10 #difference in wavelength
W=2*10**-2 #Width of surface
#Calculations:
#We know that R.P.=lamda/dlamda=m*N
N=lamda/dlamda/m #Number of lines on grating
GE=W/N #Grating element=(a+b)
print"Grating element is =",GE,"cm"
```

In [25]:

```
import math
#Given Data:
m=2 #order
lamda1=5.77*10**-7 #Wavelength of light
lamda2=5.791*10**-7 #Wavelength of light
GE=1./6000*10**-2 #GE=(a+b) grating element
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
theta1=math.asin(m*lamda1/GE)*180/math.pi #angular position in first minima
theta2=math.asin(m*lamda2/GE)*180/math.pi #angular position in second minima
a_s=(theta2-theta1)*60 #Angular separation in minutes
print"Angular separation is = ",a_s,"minutes"
```

In [26]:

```
import math
#Given Data:
n=1 #order
lam=5.89*10**-7 #Wavelength of light
a=0.3*10**-3 #width of slit
#Calculations:
#We know, a*sin(theta)=n*lamda
theta1=math.asin(n*lamda/a)*180/math.pi*60 #angular position in first dark band in minutes
print"Angular position in first dark band is = ",theta1,"mimutes"
#We know,for bright band a*sin(theta)=(2n+1)*lamda/2
theta2=math.asin(1.5*lamda/a)*180/math.pi*60 #angular position in first bright band in minutes
print"Angular position in first bright band is =",theta2,"minutes"
```

In [28]:

```
import math
#Given Data:
GE=2.54/16000*10**-2 #GE=(a+b) grating element
lamda=6*10**-7 #Wavelength of light
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
#maximum value of sin(theta)=1
m=GE/lamda #Maximum order of spectra
print"Maximum order of spectra is =",m
```

In [29]:

```
import math
#Given Data:
GE=1./5000*10**-2 #GE=(a+b) grating element
lamda=5.89*10**-7 #Wavelength of light
N=3*5000 #N=W/(a+b) Number of lines on grating
#Calculations:
#We know, (a+b)*sin(theta)=m*lamda
#maximum value of sin(theta)=1
m=GE/lamda #Maximum order of spectra
print"Maximum order of spectra is =",m
RP=3*N #Resolving power (round of m to 3)
print"Resolving power is =",RP
```

In [30]:

```
import math
#Given Data:
lamda1=5.89*10**-7 #Wavelength of light
lamda2=5.896*10**-7 #Wavelength of light
#Calculations:
dlamda=lamda2-lamda1 #difference in wavelength
lamda=(lamda2+lamda1)/2 #Mean wavelength
#(i)
m1=1 #first order
#We know that R.P.=lamda/dlamda=m*N
N1=lamda/dlamda/m1 #Number of lines on grating
print"(i)Number of lines on grating for first order is =",N1
#(ii)
m2=2 #second order
#We know that R.P.=lamda/dlamda=m*N
N2=lamda/dlamda/m2 #Number of lines on grating
print"(ii)Number of lines on grating for second order is =",N2
```

In [31]:

```
import math
#Given Data:
m=1 #order
lamda=6.553*10**-7 #Wavelength of light
dlamda=1.8*10**-10 #difference in wavelength
#Calculations:
#We know that R.P.=lam/dlam=m*N
N=lamda/dlamda/m #Number of lines on grating
print"Number of lines on grating is =",N
```

In [32]:

```
import math
#Given Data:
lamda1=5.14034*10**-7 #Wavelength of light
lamda2=5.14085*10**-7 #Wavelength of light
#Calculations:
dlamda=lamda2-lamda1 #difference in wavelength
lamda=(lamda2+lamda1)/2 #Mean wavelength
#We know that R.P.=lamda/dlamda=m*N
N=lamda/dlamda/1 #Number of lines on grating
print"Number of lines on grating for first order is =",N
#Hence R.P. for second order should be
RP1=2*N
print"Resolving power in second order should be is= ",RP1
#But here,
lamda3=8.03720*10**-7 #Wavelength of light
lamda4=8.03750*10**-7 #Wavelength of light
dlamda2=lamda4-lamda3 #difference in wavelength
lamda2=(lamda4+lamda3)/2 #Mean wavelength
RP2=lamda2/dlamda2
print"Resolving power in second order is= ",RP2
print"So, the grating will not be able to resolve 8.0372*10^-7 and 8.03750*10^-7 in second order."
print"Because Resolving power is greter than actual Resolving power."
```

In [33]:

```
import math
#For grating , Condition of maxima is (a+b)sin(theta)=n*lamda
#Given (a+b) < 2*lamda
#For maximum order, sin(90)=1
#So, n must be less than 2
#i.e. only first order possible if width of grating element is less than twice the wavelength
print"Hence, Only first order possible if width of grating element is less than twice the wavelength."
```

In [35]:

```
import math
#Given Data:
n=1 #order
lamda=5.89*10**-7 #Wavelength of light
a=0.3*10**-3 #width of slit
#Calculations:
#We know, a*sin(theta)=n*lamda
theta1=math.asin(n*lam/a)*180/math.pi #angular position in first dark band
print"Angular position in first dark band is =",theta1,"Degrees"
#We know,for bright band a*sin(theta)=(2n+1)*lamda/2
theta2=math.asin(1.5*lamda/a)*180/math.pi #angular position in first bright band
print"Angular position in first bright band is =",theta2,"Degrees"
```