Python code
If you would like to experiment yourself with the software used to make the graphs then here it is.
from math import pi, sin, radians
import matplotlib.pyplot as plt
def get_intensity(a, _lambda, theta):
'''
This function is based on the formula found on the UNSW website:
"https://www.animations.physics.unsw.edu.au/jw/light/single-slit-diffraction.html".
Their formula is I = Io(sin@ / @)^2 where @ = (pi a sinx) / lambda.
In other resources the formula is written as I = Io (sinc @)^2 where sinc @ = (sin @) / @
:param theta:
:return:
'''
alpha = pi * a * sin(radians(theta)) / _lambda
try:
I = (sin(alpha) / alpha) ** 2
except ZeroDivisionError:
I = 1 # There is a zero theta that causes alpha to go to zero.
return I
x = [i for i in range(-90, 90, 1)]
y = []
a = 1
_lambda = 1
for x_value in x:
y.append(get_intensity(a, _lambda, abs(x_value)))
# plot graph
plt.plot(x, y)
plt.ylim(0, 1.1)
plt.xlabel('Angle')
plt.ylabel('Intensity')
plt.show()
Last modified: 10 June 2024