%% ----------------------------------------------------------------
clf;
rotate3d on;
hold on;

%% ----------------------------------------------------------------
%n = 4;
n = 20;
%n = 100;

xlo = -4.0;
xhi =  4.0;
nx  =  n;
dx  = (xhi - xlo) / nx;

ylo = -4.0;
yhi =  4.0;
ny  =  n;
dy  = (yhi - ylo) / ny;

[x,y] = meshgrid(xlo:dx:xhi, ylo:dy:yhi);

%% ----------------------------------------------------------------
%  w = y^2 dx + x^2 dy
% dw = (2x - 2y) dx ^ dy

%  w = y^2 dx - x^2 dy
% dw = (-2x - 2y) dx ^ dy

 sign =  1;
%sign = -1;

wx = y.^2;
wy = x.^2 * sign;

dw = sign*2*x - 2*y;

quiver(x,y,wx,wy);
figure; % Open up a second window
contour(dw);

