Plotting Diffraction Patterns 

> restart: with(plots):  
 

Fresnel-Kirchoff Formula - Fresnel Approximation 

> F:=(ax,cx,ay,cy,k,d)->-I/lambda*exp(I*k*d)*exp(I*(k/2/d*(x^2+y^2)))*int(int(exp(I*k/2/d*(u^2+v^2))*exp(I*k/d*(x*u+y*v)),u=ax..cx),v = ay..cy);
 

proc (ax, cx, ay, cy, k, d) options operator, arrow; `+`(`-`(`/`(`*`(`+`(I), `*`(exp(`*`(I, `*`(k, `*`(d)))), `*`(exp(`/`(`*`(`*`(`/`(1, 2), `*`(I)), `*`(k, `*`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)))))),... (1)
 

Fresnel-Kirchoff Formula - Fraunhofer Approximation 

> G:=(ax,cx,ay,cy,k,d)->-I/lambda*exp(I*k*d)*exp(I*(k/2/d*(x^2+y^2)))*int(int(exp(I*k/d*(x*u+y*v)),u=ax..cx),v = ay..cy);
 

proc (ax, cx, ay, cy, k, d) options operator, arrow; `+`(`-`(`/`(`*`(`+`(I), `*`(exp(`*`(I, `*`(k, `*`(d)))), `*`(exp(`/`(`*`(`*`(`/`(1, 2), `*`(I)), `*`(k, `*`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)))))),... (2)
 

Narrow Slit Intensities 

Fresnel Approximation 

> lambda:=5: M:=10: L:=1: EE:=F(-L/2,L/2,-M/2,M/2,2*Pi/lambda,10):
 

> Intensity1:=abs(EE):
 

> plot(subs(y=0.001,Intensity1),x=-50*lambda..50*lambda);
 

Plot_2d
 

Fraunhofer Approximation 

> EE:=G(-L/2,L/2,-M/2,M/2,2*Pi/lambda,10):
 

> Intensity2:=abs(EE):
 

> plot(subs(y=0.001,Intensity2),x=-50*lambda..50*lambda);
 

Plot_2d
 

Comparison of Approximations 

> plot({subs(y=0.001,Intensity1),subs(y=0.001,Intensity2)},x=-50*lambda..50*lambda,color=[black,blue]);
 

Plot_2d
 

Fraunhofer Condition: Need d >> k/2 (aperture area). d above is 10. But 

> 2*Pi/lambda/2*L*M;
 

`+`(`*`(2, `*`(Pi))) (3)
 

Special Functions 

Sinc Function - Single Slit 

> sinc:=x->sin(x)/x:
 

> plot(sinc(x)^2,x=-10..10);
 

Plot_2d
 

Bessel Functions 

> plot(BesselJ(1,x),x=0..30);
 

Plot_2d
 

Zeros of Bessel Functions 

> BesselJZeros(0.,1..5);
 

2.404825558, 5.520078110, 8.653727913, 11.79153444, 14.93091771 (4)
 

> BesselJZeros(1.,1..5);
 

3.831705970, 7.015586670, 10.17346814, 13.32369194, 16.47063005 (5)
 

Jinc Function 

> Jinc:=x->(2*BesselJ(1,x)/x): plot(Jinc(x),x=0..30);
 

Plot_2d
 

Fresnel Integrals and the Cornu Spiral 

> plot([FresnelC(x),FresnelS(x),x=-10..10]);
 

Plot_2d
 

>
 

Simple Diffraction Patterns 

Narrow Slit: I = `*`(I[0], `*`(`^`(sinc(x), 2))) 

> densityplot(sqrt(sqrt(sinc(x)^2)),x=-20..20,y=-5..5,axes=frame,style=PATCHNOGRID,grid=[50,50],color=red,scaling=constrained);
 

Plot_2d
 

Rectangular Aperture: I = `*`(I[0], `*`(`^`(sinc(x), 2), `*`(`^`(sinc(y), 2))))  

> densityplot(sqrt(sqrt(sinc(x)^2*sinc(2*y)^2)),x=-20..20,y=-20..20,axes=frame,style=PATCHNOGRID,grid=[100,100],color=red,scaling=constrained);
 

Plot_2d
 

Circular Aperture: I = `*`(I[0], `*`(`^`(Jinc(r), 2))) 

> densityplot(sqrt(sqrt(Jinc((sqrt(x^2+y^2)))^2)),x=-10..10,y=-10..10,axes=frame,style=PATCHNOGRID,grid=[70,70],color=red,scaling=constrained);
 

Plot_2d
 

Resolving Peaks 

> c:=3.8: plot({Jinc(x)^2+Jinc(x-c)^2,Jinc(x)^2,Jinc(x-c)^2},x=-30..30,color=[red,blue,black]);
 

Plot_2d
 

> plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `-`(c)), 2)), `*`(`^`(y, 2))))), 2))))))), x = -10 .. 10, y = -10 .. ...
plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `-`(c)), 2)), `*`(`^`(y, 2))))), 2))))))), x = -10 .. 10, y = -10 .. ...
 

Plot
 

> densityplot(sqrt(sqrt(Jinc(sqrt((x+c/2)^2+y^2))^2+Jinc(sqrt((x-c/2)^2+y^2))^2)),x=-10..10,y=-10..10,axes=frame,style=PATCHNOGRID,grid=[70,70],color=red,scaling=constrained);
 

Plot_2d
 

> for k to 20 do `:=`(c, `+`(20, `-`(k))); `:=`(P[k], plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `*`(`/`(1, 2), `*`(c))), 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`...
for k to 20 do `:=`(c, `+`(20, `-`(k))); `:=`(P[k], plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `*`(`/`(1, 2), `*`(c))), 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`...
for k to 20 do `:=`(c, `+`(20, `-`(k))); `:=`(P[k], plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `*`(`/`(1, 2), `*`(c))), 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`...
for k to 20 do `:=`(c, `+`(20, `-`(k))); `:=`(P[k], plot3d(`+`(`*`(10, `*`(sqrt(`+`(`*`(`^`(Jinc(sqrt(`+`(`*`(`^`(`+`(x, `*`(`/`(1, 2), `*`(c))), 2)), `*`(`^`(y, 2))))), 2)), `*`(`^`(Jinc(sqrt(`+`(`*`...
 

> display(seq(P[k], k = 1 .. 20), insequence = true); 1
 

Plot
 

Double Slit - width b, separation a with a>b. 

I = `+`(`*`(4, `*`(I[0], `*`(`^`(cos(`+`(`*`(`/`(1, 2), `*`(k, `*`(a, `*`(sin(theta))))))), 2), `*`(`^`(sinc(`+`(`*`(`/`(1, 2), `*`(k, `*`(b, `*`(sin(theta))))))), 2)))))) 

> beta:=a/2*sin(x): alpha:=b/2*sin(x):
 

> Intensity:=(a,b)->4*cos(a/2*sin(x))^2*sinc(b/2*sin(x))^2:
 

> plot(Intensity(20,5),x=-5..5);
 

Plot_2d
 

> densityplot(sqrt(sqrt(Intensity(20,5))),x=-5..5,y=-1..1,axes=frame,style=PATCHNOGRID,grid=[50,50],color=red,scaling=constrained);
 

Plot_2d
 

> lambda:=5: a:=20: b:=19: L:=1:  EE:=G(-L/2,L/2,(a-b)/2,(a+b)/2,2*Pi/lambda,10)+G(-L/2,L/2,-(a+b)/2,-(a-b)/2,2*Pi/lambda,10):
 

> Intensity:=abs(EE):
 

> plot(subs(x=0.001,Intensity),y=-5..5,numpoints=200);
 

Plot_2d
 

> densityplot(sqrt(sqrt(subs(x=0.001,Intensity))),y=-5..5,x=-1..1,axes=frame,style=PATCHNOGRID,grid=[50,50],color=red);
 

Plot_2d
 

N Slits I = `*`(I[0], `*`(`^`(sinc(beta), 2), `*`(`^`(`/`(`*`(sin(`*`(N, `*`(alpha)))), `*`(sin(alpha))), 2)))) 

> beta:=a/2*sin(x): alpha:=b/2*sin(x):
 

> Intensity:=(a,b)->sin(a*N/2*sin(x))^2*sinc(b/2*sin(x))^2/sin(a/2*sin(x))^2;
 

proc (a, b) options operator, arrow; `/`(`*`(`^`(sin(`+`(`*`(`/`(1, 2), `*`(a, `*`(N, `*`(sin(x))))))), 2), `*`(`^`(sinc(`+`(`*`(`/`(1, 2), `*`(b, `*`(sin(x)))))), 2))), `*`(`^`(sin(`+`(`*`(`/`(1, 2),... (6)
 

> N:=2:plot(Intensity(20,19),x=-5..5,numpoints=200);
 

Plot_2d
 

> densityplot(sqrt(sqrt(Intensity(20,19))),x=-5..5,y=-1..1,axes=frame,style=PATCHNOGRID,grid=[50,50],color=red);
 

Plot_2d
 

> N:=4:plot(Intensity(20,19),x=-5..5,numpoints=200);
 

Plot_2d
 

> densityplot(sqrt(sqrt(Intensity(20, 19))), x = -5 .. 5, y = -1 .. 1, axes = frame, style = PATCHNOGRID, grid = [50, 50], color = red, scaling = constrained); 1
densityplot(sqrt(sqrt(Intensity(20, 19))), x = -5 .. 5, y = -1 .. 1, axes = frame, style = PATCHNOGRID, grid = [50, 50], color = red, scaling = constrained); 1
 

Plot_2d
 

> with(plots); -1
 

>