% Book: Laser Electronics by Verdeyen
% Problem: Chapter 3 problem 20a
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_Ch3_Pr20a
figure(1);true;
axis([-2 2 -2 2]);
[X,Y] = meshgrid(-2:.2:2);
R2 = X.^2+Y.^2
DX=X.*(2.0*Y.^2-1).*exp(-R2);
DY=exp(-R2);

DX=(2.0*X.^2-1).*(2.0*Y.^2-1).*exp(-R2);
DY=(2.0*Y.^2-1).*(2.0*X.^2-1).*exp(-R2);

Z = DX.^2+DY.^2;
contour(X,Y,Z)
hold on
quiver(X,Y,DX,DY)
colormap hsv
grid off
hold off
