PHY103A : Gradient, divergence, and curl

(*     Lecture # 2   *)

Gradient of a Scalar Function

range=10;
Plot3D[(Sqrt[(x^2)+(y^2)]),{x,-range,range}, {y,-range,range}, PlotRange->All]
VectorPlot[{ (x/(Sqrt[(x^2)+(y^2)])), (y/(Sqrt[(x^2)+(y^2)]))},{x,-range,range},{y, -range, range}]

h[x_, y_]:= Exp[-((((x^2)+(y^2)))/2)]
range=3;
Plot3D[h[x,y],{x,-range,range},{y, -range,range}]
VectorPlot[{ -x h[x,y], -y h[x,y]},{x,-range,range},{y, -range, range}]

h[x_, y_]:= (x^2) Exp[-((((x^2)+(y^2)))/2)]
range=3;
Plot3D[h[x,y],{x,-range,range},{y, -range,range}]
VectorPlot[{ (2 x-(x^3)) h[x,y], (-(x^2)y) h[x,y]},{x,-range,range},{y, -range, range}]

Divergence of a Vector Function

range=2;
VectorPlot[{(x^2), (y^3)},{x,-range,range},{y, -range, range}]

range=2;
VectorPlot[{0, 1},{x,-range,range},{y, -range, range}]

range=2;
VectorPlot[{x, x},{x,-range,range},{y, -range, range}]

range=2;
VectorPlot[{-y, x},{x,-range,range},{y, -range, range}]
Div[{-y,x,0},Cartesian[x,y,z]]

range=2;
VectorPlot[{(x^2), (y^2)},{x,-range,range},{y, -range, range}]
Div[{(x^2),(y^2),0},Cartesian[x,y,z]]

Curl of a Vector Function

VectorPlot[{-y, x},{x,-range,range},{y, -range, range}]

VectorPlot[{x, y},{x,-range,range},{y, -range, range}]

VectorPlot[{0, x},{x,-range,range},{y, -range, range}]

VectorPlot[{-(y^2), (x^4)},{x,-range,range},{y, -range, range}]