Physics 4321
Homework 2

Setup:

Clear["Global`*"];
Off[ General::spell ];
Off[ General::spell1];
Off[Clear::wrsym];

Load Packages:

Needs["LinearAlgebra`Orthogonalization`"]
Needs["Calculus`VectorAnalysis`"]
Needs["Graphics`PlotField`"]
Needs["Graphics`PlotField3D`"]
Needs["Graphics`ParametricPlot3D`"]

Unit Vectors in Polar Coordinates:

The r-Unit Vector:

PlotVectorField[{x,y}/Sqrt[x^2+y^2], {x,-1,1},{y,-1,1},PlotPoints->9];

The phi-Unit Vector:

PlotVectorField[{-y,+x}/Sqrt[x^2+y^2], {x,-1,1},{y,-1,1},PlotPoints->9];

Example 1: Cylindrical Coordinates:
You do it in Spherical

Clear["Global`*"]

Coordinates[Cartesian]

Coordinates[Cylindrical]

CoordinatesFromCartesian[{x,y,z},Cylindrical]

CoordinatesToCartesian[{r, theta, z},Cylindrical]

x2rRule = Thread[ {x,y,z} -> CoordinatesToCartesian[{r, theta, z},Cylindrical] ]
x2rRule = x2rRule //Drop[#,-1]&

r2xRule = Thread[ {r, theta, z} -> CoordinatesFromCartesian[{x,y,z},Cylindrical] ]
r2xRule = r2xRule //Drop[#,-1]&

JacobianDeterminant[{x,y,z},Cartesian]

JacobianDeterminant[{r,theta,z},Cylindrical]

Integrate[ 1 JacobianDeterminant[{r,theta,z},Cylindrical]
   ,{theta,0, 2 Pi}
   ,{z,0,h}
   ]

Integrate[ 1 JacobianDeterminant[{r,theta,z},Cylindrical]
   ,{r,0,R}
   ,{theta,0, 2 Pi}
   ,{z,0,h}
   ]

Example 2:

Clear["Global`*"]

v={y,-x,0};

x2rRule = Thread[ {x,y,z} -> CoordinatesToCartesian[{r, theta, z},Cylindrical] ]
x2rRule = x2rRule //Drop[#,-1]&

rUnit={ x,y,0}/Sqrt[x^2+y^2];
phiUnit={-y,x,0}/Sqrt[x^2+y^2];
  zUnit={ 0,0,1};

vr= {rUnit,phiUnit,zUnit}.v  /.x2rRule //Simplify //PowerExpand

PlotVectorField[ v[[{1,2}]] ,{x,-1,1},{y,-1,1},PlotPoints->4];

{Div[v,Cartesian],Div[vr,Cylindrical]}

{Curl[v,Cartesian],Curl[vr,Cylindrical]}