import numpy as np
import matplotlib.pyplot as plt
# Constants
wl = 500e-9 # wavelength of light
d = 1 # distance between slits
# Create an array of angles
theta = np.linspace(-np.pi / 10e5, np.pi / 10e5, 500)
# Calculate beta
beta = np.pi * d * np.sin(theta) / wl
# Calculate the intensity
I = (np.cos(beta / 2)**2) * (np.sinc(beta / np.pi)**2) # np.sinc(x) = sin(pi*x)/(pi*x)
plt.figure(figsize=(8, 6))
plt.plot(theta, I, color='green')
plt.title('Intensity of Double Slit Experiment')
plt.xlabel('Theta (rad)')
plt.ylabel('Intensity')
plt.grid()
plt.show()
To embed this program on your website, copy the following code and paste it into your website's HTML: