In [4]:

```
import math
#to calculate angular width and linear width
lamda=6*10**-5
e=0.01 #width of slit in cm
#position of minima is given by
sintheta=lamda/e #sintheta=m*lamda/e ,where m=1,2,3,......
print "sintheta=","{:.1e}".format(sintheta)," m"
#since theta is very small,so sintheta is approximately equal to theta
theta=sintheta
theta1=2*theta
print "total angular width of central maximum is theta1=","{:.1e}".format(theta1)," radians "
d=100 #distance in cm
Y=theta*d
Y1=2*Y
print "linear width of central maximum on the screen is Y1=",Y1,"cm"
print "values of m =1,2,3,............ gives the directions of first, second .............minima"
```

In [5]:

```
import math
#to calculate wavelength of light
#in a diffraction pattern due to single slit, minima is given by e*sintheta=m*lamda
#since theta is very small, sintheta is approximately equal to theta
#theta=Y/d
e=0.014 #width of slit in cm
d=200 #distance in cm
m=2.0
Y=1.6 #in cm
lamda=Y*e/(d*m)
print "wavelength of light is lamda=",lamda*1e8,"angstrom"
```

In [6]:

```
import math
#to calculate width of slit
#direction of minima in fraunhofer diffraction due to single slit is given by math.pi/lamda*e*siuntheta=+m*math.pi,where m=1,2,3
#angular spread of the central maximum on either side of the incident light is sintheta=lamda/e,where m=1,position of first minima
lamda=5000*10**-8
e=lamda/math.sin(math.pi/6)
print "width of slit is e=","{:.1e}".format(e),"cm"
```

In [6]:

```
import math
#to calculate wavelength of incident light
#direction of minima is given by e*sintheta=+m*lamda
#for first minima m=1,i.e. e*sintheta=lamda,sintheta is approximately equal to theta,then we can write it as e*theta=lamda ...........eq(1)
#theta=Y/d........................eq(2)
e=0.02 #in cm
Y=0.5 #position of first minima from the central maxima in cm
d=200 #distance of screen from the slit in cm
#from eq(1) and eq(2),we get
lamda=e*Y/d
print "wavelength of incident light is lamda=",lamda*1e8,"angstrom"
```

In [7]:

```
import math
#to calculate values of lamda1 and lamda2
#in fraunhofer diffraction pattern ,the direction of minima is given by e*sintheta=+m*lamda,where m=1,2,.......
#direction of fourth minima (m=4) for wavelength lamda1 is given by e*sintheta1=4*lamda1..........eq(1)
#similarly, e*sintheta2=5*lamda2..........eq(2)
#from eq(1) and eq(2),we get e*sintheta=4*lamda1=5*lamda2....eq(3)
y=0.5 #in cm
f=100 #in cm
theta=y/f #in radian
sintheta=theta #theta is very small
e=0.05 #width of slit in cm
lamda1=e*sintheta/4
print "lamda1=",lamda1*1e8,"angstrom"
#from eq(3) we get,
lamda2=4*lamda1/5
print "lamda2=",lamda2*1e8,"angstrom"
```

In [11]:

```
import math
#to calculate half angular width
e=1.2*10**-4 #width of slit in cm
y=6*10**-5 #wavelength of monochromatic light in cm
theta=y/e
print "half angular width of central bright maxima is theta=",theta,"radian"
```

In [17]:

```
import math
#to calculate angle
lamda=6000.0*10**-8 #wavelength of light in cm
e=0.03 #width of slit in cm
#e*sintheta=m*lamda,where m=1
theta=math.degrees(math.asin(lamda/e))
print "angle at which the first dark band are formed in the fraunhofer diffraction pattern is theta=",round(theta,3),"degree"
theta1=math.degrees(math.sin(3*lamda/(2*e)))
print "angle at which the next bright band are formed in the fraunhofer diffraction pattern is theta1=",round(theta1,3),"degree"
```

In [7]:

```
import math
#to calculate distances of first dark band and of next bright band on either side of the central maximum
#formula is e*sintheta=m*lamda,where m=1
lamda=5890.0*10**-8 #wavelength of light in cm
e=0.03 #width of slit in cm
sintheta=lamda/e
theta=sintheta #becoz theta is very small,so sintheta is approximately equal to theta
f=50.0
y=f*theta
print "linear distance of first minimum from the central maximum is y=",round(y,4),"cm"
sintheta1=3*lamda/(2*e)
theta1=sintheta1
y1=f*theta1
print "linear distance of first secondary maxima is y1=",round(y1,4),"cm"
```

In [8]:

```
import math
#to calculate wavelength of light and missing orders
omega=0.25 #fringe width in cm
D=170 #distance in cm
twod=0.04 # distance in cm
lamda=omega*twod/D
print "wavelength of light is lamda=","{:.3e}".format(lamda),"cm"
e=0.08 #width of slit in mm
d=0.4 #in mm
m=1
n=m*(e+d)/e
print "missing order is n=",n,"unitless"
#we can also find order for m=2,3,....
```

In [16]:

```
import math
#to calculate wavelength
n=2.0 #order of spectrum
theta=math.pi/6 #in radians
E=1.0/5000 #let (e+d)=E
lamda=E*math.sin(math.pi/6)/n
print "the wavelength of the spectral line is lamda=",lamda,"cm"
```

In [15]:

```
import math
#to calculate difference in deviations
lamda=5*10**-5 #wavelength of light in cm
eplusd=1/6000.0 #where eplusd=e+d
theta1=math.degrees(math.asin(lamda/eplusd)) #for first order spectrum
theta3=math.degrees(math.asin(3*lamda/eplusd)) #for second order spectrum
difference=theta3-theta1
print "difference in deviations in first and third order spectra is difference =",round(difference,1),"degree"
```

In [9]:

```
import math
#to calculate orders
#let E=(e+d)
#formula is (e+d)*sin thita=n*lamda
#for maximum order to be possible thita=90 degree
#sin theta=1
E=2.54/2620 #in cm
lamda=5*10**-5 #wavelength of the incident light in cm
n=E/lamda
print "the orders will be visible is n=",round(n),"unitless"
```

In [10]:

```
import math
#to calculate number of lines in the grating
#theta1=theta2=30 degree
#sin theta1=sin theta2=1/2
lamda1=6*10**-5
#wavelength in cm
lamda2=4.5*10**-5
#let (e+d)=E
#formula is (e+d)*sin theta1=n*lamda1----------eq(1)
#(e+d)*sin theta2=(n+1)*lamda2----------eq(2)
#we get,
n=lamda2/(lamda1-lamda2) #order of spectrum
E=n*lamda1/math.sin(math.pi/6)
number=1/E
print "number of lines is number=",round(number),"unitless"
```

In [11]:

```
import math
#to calculate order when visible light of wavelength in the range 4000 to 7500 angstrom
#let E=(e+d)
E=1.0/4000 #in cm
lamda1=4*10**-5
#wavelength in cm
lamda2=7.5*10**-5
n1=E*math.sin(math.pi/2)/lamda1
n2=E*math.sin(math.pi/2)/lamda2
print "order when wavelength of 4000 angstrom is n1=",n1,"unitless"
print "order when wavelength of 7500 angstrom is n2=",round(n2,2),"unitless"
```

In [21]:

```
import math
#to calculate angle of diffraction
n=1 #order
lamda=5000*10**-8 #wavelength of light in cm
eplusd=1/5000.0 # in cm
theta=math.degrees(math.asin(n*lamda/(eplusd)))
minu=(theta-int(theta))*60 # minute
print "angle of diffraction for maximum intensity in the first order is theta=",int(theta),"degree",round(minu),"minutes"
```

In [23]:

```
import math
#to calculate number of lines in one centimeter of the grating
#let E=(e+d)
#formula for grating equation for principal maxima is (e+d)*sin theta=n*lamda
n=2 #order of spectrum
lamda=5*10**-5 #wavelength in cm
E=n*lamda/math.sin(math.pi/6)
number=1/E
print "number of lines is number=",number,"unitless"
#answer is given wrong in the book ,number of lines=1000
```

In [24]:

```
import math
#to calculate which spectral line in 5th order will overlap with 4th order line of 5890 angstrom
#the grating equation for principal maxima is (e+d)*sin theta =n*lamda
n1=5
#order of spectrum
n2=4
lamda2=5890*10**-8 #wavelength of 4th order spectrum in cm
#(e+d)*sin theta=5*lamda-------------eq(1)
#(e+d)*sin theta=4*5890*10**-8-----------------eq(2)
#from eq(1) and eq(2) ,we get
lamda1=n2*lamda2/n1
print "wavelength of 5th order spectrum is lamda1=",lamda1,"cm"
```

In [14]:

```
import math
#to calculate grating element
#grating equation for principal maxima is given by (e+d)*sintheta=n*lamda
#let nth order spectrum for yellow line (lamda=6000 angstrom) coincide with (n+1)th order spectrum for blue line (lamda=4800 angstrom)
#(e+d)*sintheta=n*6000*10**-8..eq(1)
#(e+d)*sintheta=(n+1)*4800*10**-8.....eq(2)
#from eq(1) and eq(2),we get n=4
n=4
lamda=6000*10**-8 #wavelength in cm
sintheta=3.0/4
eplusd=n*lamda/sintheta
print "grating element is eplusd=","{:.1e}".format(eplusd),"cm"
```

In [24]:

```
import math
#to calculate angle of diffraction for third order spectrum and absent spectra if any
n=3
lamda=6000*10**-8
eplusd=1/200.0
theta=math.degrees(math.asin(n*lamda/eplusd))
minu=(theta-int(theta))*60 # minute
print "angle of refraction is theta=",int(theta),"degree",round(minu),"minutes"
d=0.0025
e=eplusd-d #width of wire in cm
m=1
n=eplusd*m/e
print "order of absent spectrum is n=",n,"unitless"
print "here,m=1 is considered because the higher values of m result the order of absent spectrum more than the given order 3"
```

In [2]:

```
import math
#to calculate difference in the two wavelengths
#grating equation for principal maxima is (e+d)*sintheta=n*lamda...............eq(1)
#differentiate both sides ,we get dtheta=n*dlamda/((e+d)*costheta)...........eq(2)
lamda=5000 #mean value of wavelengths in angstrom
cottheta=1.732 #cot30degree=1.732
dtheta=0.01 #in radian
#put the value of n from eq(2),we can write eq(2)
dlamda=lamda*dtheta*cottheta
print "difference in two wavelengths is dlamda=",dlamda,"angstrom"
```

In [27]:

```
import math
#to calculate dispersive power
#differentiate grating equation ,we get dtheta/dlamda=n/((e+d)*costheta)
n=2 #order
eplusd=1/4000.0
lamda=5000.0*10**-8 #wavelength in cm
sintheta=n*lamda/(eplusd)
costheta=math.sqrt(1-(sintheta)**2)
dtheta=n/((eplusd)*costheta) #where dispersive power dtheta/dlamda=dtheta
print "dispersive power of grating in the second order spectrum is dtheta=",int(dtheta),"unitless"
# answer is slightly different due to approximation
```

In [30]:

```
import math
#to calculate orders
eplusd=1/4000.0
lamda1=5*10.0**-5 #wavelengh in cm
lamda2=7.5*10**-5
nmax1=eplusd/lamda1
nmax2=eplusd/lamda2
print "orders will be observed by a grating ,if it is illuminated by light of wavelength of 5000 angstrom is nmax1=",nmax1,"unitless "
print "orders will be observed ,if it is illuminated by light of wavelength of 7500 angstrom is nmax2=",round(nmax2,1),"unitless"
```

In [18]:

```
import math
#to calculate difference in wavelengths of two lines
#let E=(e+d)=1/5000
#we get
E=2*10**-4 #in cm
n=2 #order of spectrum
lamda=5893*10**-8 #wavelength in cm
#dtheta=2.5'=(2.5/60)*(3.14/180),we get
dtheta=7.27*10**-4 #in radian
dlamda=math.sqrt(((E/n)**2)-lamda**2)*dtheta
print "the difference in wavelengths of two lines is dlamda=","{:.2e}".format(dlamda),"cm"
```

In [6]:

```
import math
#to calculate aperture of the objective of a telescope
lamda=6*10**-5 #wavelength of light in cm
dtheta=4.88*10**-6 # in radians
a=1.22*lamda/dtheta
print "the aperture of the objective of a telescope is a=",a,"cm"
```

In [7]:

```
import math
#to calculate separation of two points on the moon
lamda=5.5*10**-5 #wavelength of light in cm
a=500 #diameter in cm
dtheta=1.22*lamda/a #limit of resolution of telescope in radians
R=3.8*10**8 #distance between earth and moon in m
X=R*dtheta
print "the separation of two points on the moon is X=",X,"m"
```

In [19]:

```
import math
#to calculate numerical aperture of the objective
lamda=5.461*10**-5 #wavelength in cm
S=5.55*10**-5 #distance in cm
NA=1.22*lamda/(2*S)
print "the numerical aperture of the objective is NA=",round(NA,1),"unitless"
```

In [9]:

```
import math
#to calculate resolving power of microscope
NA=0.12 #numerical aperture
lamda=6*10**-5 #wavelength of light in cm
RP=2*NA/lamda #RP=resolving power
print "the resolving power of microscope is RP=",RP,"unitless"
```

In [10]:

```
import math
#to calculate maximum resolving power
lamda=5*10**-5 #wavelength of light in cm
N=40000 #total number of lines on grating
#(e+d)=12.5*10**-5 cm
#formula is nmax=(e+d)/lamda
#we get
nmax=2 #order of spectrum
RP=nmax*N #RP=resolving power
print "the maximum resolving power is RP=",RP,"unitless"
```

In [11]:

```
import math
#to calculate minimum number of lines in a grating
lamda1=5890
#wavelengh in angstrom
lamda2=5896
dlamda=6 #smallest wavelength difference in angstrom
n=2 #order of spectrum
lamda=(lamda1+lamda2)/2 #average wavelength in angstrom
RP=lamda/dlamda #RP=resolving power
N=RP/n
print "minimum number of lines in a grating is N=",N,"unitless"
```

In [21]:

```
import math
#will the telescope be able to observe the wiremesh
a=3 #aperture in cm
lamda=5.5*10**-5 #wavelength of light in cm
#limit of resolution of telescope is given by
theta=1.22*lamda/a
#alpha=spacing of wire-mesh/distance of objective from wire-mesh
alpha=0.2/(80*10**2)
print "theta=","{:.3e}".format(theta),"radian"
print "alpha=",alpha,"radian"
print "if alpha>theta then telescope will be able to observe the wire-mesh"
#value of alpha is given wrong in the book 2.25*10**-5 radian
```

In [22]:

```
import math
#distance between the centres of images of two stars
lamda=5500*10**-8 #wavelength of light in cm
f=4*10**2 #focal length of telescope objective in cm
a=0.01*10**2 #diameter in cm
X=1.22*lamda*f/a
print "distance between the centres of images of two stars is X=","{:.2e}".format(X),"cm "
```

In [23]:

```
import math
#to calculate diameter of a telescope
lamda=5.0*10**-5 #wavelength in cm
theta=(math.pi/180)*(1.0/1000) #in radians
a=1.22*lamda/theta
print "the diameter of a telescope is a=",round(a,1),"cm"
```

In [25]:

```
import math
#to calculate smallest angle between two stars
lamda=5*10**-5 #wavelength in cm
a=100*2.54 #diameter in cm
theta=1.22*lamda/a
print "the smallest angle between two stars is theta=","{:.2e}".format(theta),"radians"
```

In [26]:

```
import math
#to calculate limit of resolution of the telescope
lamda=5890*10**-8 #wavelength in cm
a=1 #diameter in cm
theta=1.22*lamda/a
print "the limit of resolution of the telescope is theta=","{:.3e}".format(theta),"radians "
```

In [20]:

```
import math
#to calculate resolving limit of microscope
lamda=5.5*10**-5 #wavelengh in cm
theta=math.pi/6 #in radians
s=1.22*lamda/(2*math.sin(math.pi/6))
print "resolving limit of microscope is s=",s,"cm"
```

In [19]:

```
import math
#to calculate resolving power of grating
N=15000 #total number of lines on grating
lamda=6*10**-5 #wavelength in cm
n=2 #order of spectrum
RP=n*N
print "resolving power is RP =",RP,"unitless"
#to calculate smallest wavelength difference that can be resolved with a light of wavelength 6000angstrom in the second order
dlamda=lamda/(n*N)
print "smallest wavelength difference dlamda=",dlamda,"cm"
```

In [28]:

```
import math
#to calculate resolving power in the second order
N=6*10**4 #N=total number of lines on grating
n=2 #order of spectrum
RP=n*N #RP=resoling power
print "the resolving power is RP=","{:.1e}".format(RP),"unitless"
#to calculate smallest wavelength
lamda=6000*10**-8 #wavelength in cm
n=3 #order of spectrum
dlamda=lamda/(n*N)
print "smallest wavelength that can be resolved in the third order in 6000angstrom wavelength region is dlamda=","{:.2e}".format(dlamda),"cm"
```