

disp('                       DIVERGENCE       ')
disp(' ')

disp('              Accelerated Flow     ')  
disp('        F(x,y) = ( u(x,y), v(x,y)) = ( exp(-x^2),0 )  ')
disp('           divg(F) = -2x exp(-x^2)   ')

 x = linspace(-2,2,51);
 [X,Y]= meshgrid(x,x);
 pcolor(X,Y,-2*X.*exp(-X.^2)); shading interp;
 map = jet;
 myjet = map(33:64, :);
 colormap(myjet);
 colorbar
 
 hold on
 
 xx = linspace(-1.7,1.7, 11);
 [XX,YY] = meshgrid(xx,xx);
 U = exp(-XX.^2); V = 0*XX;
 quiver(XX,YY,U,V)
 pause
 close
 
 disp(' ')
 disp('                 Radial vector field  ')
 disp( '      F(x,y) = (u(x,y), v(x,y)) = (x/r, y/r)  ')
 disp('                   div(F) = 1/r  ')
 clear U V
 
 R = sqrt(X.^2 + Y.^2)+eps;
 
 Z = (1./R);
 Z = (Z<5).*(Z -5) +5;
 pcolor(X,Y,Z); shading interp;
 map = jet;
 myjet = map(33:64,:);
 colormap(myjet);
 colorbar
 
 hold on
 
 
 clear U V
 RR = sqrt(XX.^2 + YY.^2)+eps;
 U = XX./RR; V = YY./RR;
 quiver(XX,YY, U,V)
 pause
 close
 
 
 clear U V RR
 disp('              Divergence of vector field ')
 disp('    F(x,y) = (u(x,y), v(x,y)) = .5*(x^2 , y^3)  ')
 disp('  ')
 pcolor(X,Y, X+1.5*Y.^2 );shading interp;
 map = jet;
 myjet = map(33:64, :);
 colormap(myjet); colorbar
 hold on
 U = .5*XX.^2; V = .5*YY.^3;
 quiver(XX,YY,U,V)
 pause
 close

 
