# Chapter 4 - Diffraction¶

## Example 4 - pg 101¶

In :
#pg 101
#calculate the no. of interference minima
#Given :
import math
d = 8.8*10**-2 ; # slit width in mm
b = 0.7;# seperation between slits in mm
lambd = 6328. ; #Wavelength in A
#First diffraction minima is possible, when  d*sin(theta) = lambd
# 1 A = 1.0*10**-7 mm
#cakculations and results
theta = math.asin((lambd*10**-7)/d)*57.3; # angle in degrees
print"theta (degrees) =  ",round(theta,3)
#interference minima is possible , when sin(theta) = ((p + 1/2)*lambd)/b
for p in range  (0,10):
#1 A = 1.0*10**-7 mm
theta1 = math.asin((p + 1/2.)*(lambd*10**-7/b))*57.3; # angle in degrees
print"When p = ",p
print"theta (degrees) = ",round(theta1,3)
if(theta1 > theta):
print" When p >=",p,",  theta >",theta,"degrees .\n\nBetween the first two diffraction minima ,",2*p,"interference minima are possible."
break;

theta (degrees) =   0.412
When p =  0
theta (degrees) =  0.026
When p =  1
theta (degrees) =  0.078
When p =  2
theta (degrees) =  0.129
When p =  3
theta (degrees) =  0.181
When p =  4
theta (degrees) =  0.233
When p =  5
theta (degrees) =  0.285
When p =  6
theta (degrees) =  0.337
When p =  7
theta (degrees) =  0.388
When p =  8
theta (degrees) =  0.44
When p >= 8 ,  theta > 0.412042642025 degrees .

Between the first two diffraction minima , 16 interference minima are possible.


## Example 6 - pg 111¶

In :
#pg 111
#calculate the angles requried
#Given :
import math
# a+b = (2.54/N)cm
N = 15000.;#grating has 15000 lines
#calculations and results
a_plus_b = 2.54/N ; # grating element in cm
#Grating equation, (a+b)*sin(theta_n) = n*lambda, we get :  theta_n = asind((n*lamba)/(a+b))
print"For line D1  and Wavelength 5890 A: "
print" Angles at which first order and second order maxima will be observed are : "
lambda1 = 5890.; #Wavelength in A
for n in range(1,3): # First and second order maxima
# 1 A = 1.0*10**-7 mm
theta1_n = math.asin((n*lambda1*10**-8)/a_plus_b)*57.3;# angle in degrees
print" Order :",n,",",round(theta1_n,3),"degrees "

print"For line D2 and Wavelength 5895.9 A : "
print" Angles at which first order and second order maxima will be observed are : "
lambda2 = 5895.9 ; #Wavelength in A
for n1 in range(1,3): #First and second order maxima
# 1 A = 1.0*10**-7 mm
theta2_n = math.asin((n1*lambda2*10**-8)/a_plus_b)*57.3;# angle in degrees
print"Order :",n1,",",round(theta2_n,3),"degrees "

print" When n = 3,  sin(theta)= ((n*lambda*10**-8)/a_plus_b)>1 , which falls outside the sine range, hence third order maximum is not visible"

For line D1  and Wavelength 5890 A:
Angles at which first order and second order maxima will be observed are :
Order : 1 , 20.356 degrees
Order : 2 , 44.084 degrees
For line D2 and Wavelength 5895.9 A :
Angles at which first order and second order maxima will be observed are :
Order : 1 , 20.378 degrees
Order : 2 , 44.139 degrees
When n = 3,  sin(theta)= ((n*lambda*10**-8)/a_plus_b)>1 , which falls outside the sine range, hence third order maximum is not visible


## Example 8 - pg 112¶

In :
#pg 112
#calculate the dispersion and resolving power
# Given :
#(a) 15000 lines per inch
import math
N1 = 15000.; #15000 lines per inch
a1_plus_b1 = (2.54/N1)*10**8 ; #grating element in A
lambda1 = 5890.; #Wavelength in A
lambda2 = 5895.9 ; # Wavelength in A
#calculations
deltalambda1 = lambda2-lambda1; #in A
#For first order
n =1.;
theta1 = 20.355; # in degrees
deltatheta1 = ((n*deltalambda1)/((a1_plus_b1)*math.cos(theta1/57.3)));# dispersion in degrees/A
rp1 = n*N1; # resolving power

#(b)15000 lines per cm
# 1 cm = 0.393701 inches, so We have 15000 lines per 0.393701 inches.
#Therefore, For 1 inch we have 15000/0.393701 = 38099.979 or 38100 lines
N2 = 38100 ; #38100 lines per inch
a2_plus_b2 = (2.54/N2)*10**8 ; #grating element in A
#For first order
theta_1 = math.asin((n*lambda1)/(a2_plus_b2))*57.3;# in degrees
deltatheta_1 = ((n*deltalambda1)/((a2_plus_b2)*math.cos(theta_1/57.3)));#  dispersion in degrees/A
rp2 = n*15000; # resolving power

#(c)5906 lines per cm
# 1 cm = 0.393701 inches, so We have 5906 lines per 0.393701 inches.
#Therefore, For 1 inch we have 5906/0.393701 =  15001.232  or 15001 lines
N3 = 15001; #15001 lines per inch
a3_plus_b3 = (2.54/N3)*10**8; #grating element in A
#For first order
theta__1 = math.asin((n*lambda1)/(a3_plus_b3))*57.3; # in degrees
deltatheta__1 = ((n*deltalambda1)/((a3_plus_b3)*math.cos(theta__1/57.3))); #  dispersion in degrees/A
rp3 = n*5906; # resolving power
#results
print" Number of lines \tGrating element (in A)\t Angle of diffraction(degrees)\t Dispersion (degrees/A) \t Resolving Power"
print N1,"/inch\t\t\t",round(a1_plus_b1,2),"\t\t",round(theta1,2),"\t\t\t\t",deltatheta1*10**3,"x 10**-3\t\t\t",rp1
print 15000.,"/cm\t\t\t",round(a2_plus_b2,2),"\t\t",round(theta_1,2)," \t\t\t\t",deltatheta_1*1000.," x 10**-3\t\t\t",rp2
print 5906.,"/cm\t\t\t",round(a3_plus_b3,2),"\t\t",round(theta__1,2)," \t\t\t\t",deltatheta__1*1000.," x 10**-3\t\t\t",rp3
print "Error in textbook for dispersion values . Error in decimal point placement ."

 Number of lines 	Grating element (in A)	 Angle of diffraction(degrees)	 Dispersion (degrees/A) 	 Resolving Power
15000.0 /inch			16933.33 		20.36 				0.371627947644 x 10**-3			15000.0
15000.0 /cm			6666.67 		62.07  				1.88928508374  x 10**-3			15000.0
5906.0 /cm			16932.2 		20.36  				0.371659571465  x 10**-3			5906.0
Error in textbook for dispersion values . Error in decimal point placement .


## Example 9 - pg 114¶

In :
#pg 114
#calculate the Wavelength and spacing, angle
#Given:
#Wavelength
import math
from math import sin
n=1; # first order diffraction
lambda1 = 4680. ;# Wavelength in A
lambda2 = 4800.; #Wavelength in A
lambda3 = 5770. ; # Wave;ength in A
# First order diffraction angle
theta1 = 28.0/57.3; # angle in radians
theta2 = 28.7/57.3; # angle in radians
theta3 = 35.5/57.3; #angle in radians
#calculations
#Grating equation : (a+b) = n*lambda/sin(theta)
a1_plus_b1 = (n*lambda1)/sin(theta1); #spacing in A
a2_plus_b2 = (n*lambda2)/sin(theta2); #spacing in A
a3_plus_b3 = (n*lambda3)/sin(theta3); #spacing  in A
mean_spacing = (a1_plus_b1 + a2_plus_b2 + a3_plus_b3)/3; # mean spacing in A
#results
print"(a)Wavelength :",lambda1," A \n Angle of 1st order Diffraction :",round(theta1*57.3,1),"degrees \n Spacing =",round(a1_plus_b1,1),"A"
print"(a)Wavelength :",lambda2," A \n Angle of 1st order Diffraction :",round(theta2*57.3,1),"degrees \n Spacing =",round(a2_plus_b2,1),"A"
print"(a)Wavelength :",lambda3," A \n Angle of 1st order Diffraction :",round(theta3*57.3,1),"degrees \n Spacing =",round(a3_plus_b3,1),"A"
print"Mean Spacing (A) = ",mean_spacing

(a)Wavelength : 4680.0  A
Angle of 1st order Diffraction : 28.0 degrees
Spacing = 9969.3 A
(a)Wavelength : 4800.0  A
Angle of 1st order Diffraction : 28.7 degrees
Spacing = 9996.0 A
(a)Wavelength : 5770.0  A
Angle of 1st order Diffraction : 35.5 degrees
Spacing = 9936.9 A
Mean Spacing (A) =  9967.40613803


## Example 10 - pg 115¶

In :
#pg 115
#calculate the first order maximum
#Given:
import math
N = 15000.;#Number of lines per inch
a_plus_b = (2.54/N)*10**8 ;#Grating period in A
lambd = 1 ; #Wavelength in A
#Grating equation :(a+b)*sin(theta_n) = n*lambd
#First order maximum
#calculations
theta1 = math.asin(lambd/a_plus_b)*57.3; # angle in degrees
#results
print "The first order maximum will be obtained at (degrees) = ",round(theta1,3)

The first order maximum will be obtained at (degrees) =  0.003


## Example 11 - pg 118¶

In :
#pg 118
#calculate the Maximum value for L
#Given:
import math
lambd = 6000.; #Wwavelength in A
mu = 1.33; #Refractive index for cornea
D = 2.; #Diameter of pupil in mm
#calculations
#Yellow light wavelength in eye:
lambd1 = lambd/mu ; #Wavelength in A
#The angular resolution
#1 A = 1.0*10^-7 mm
theta_c = (1.22*lambd1*10**-7)/D; # angle in rad
#Maximum value for L
L = 1/math.tan(theta_c); # in mm
#results
print "Maximum value for L should be (mm) = ",round(L,1)

Maximum value for L should be (mm) =  3633.9