I like Hans Dolhaine's example. He does his calculation entirely in a vector notation. There is an alternative method using differential forms that is somewhat easier to follow. I decided to use Hans' example to illustrate the differential form method.
Two spaces have been defined, an xyz-Space that the vector field and the resulting scalar potential field exist in and a 1-dimensional t-space that maps to a straight line in xyz-Space and is used to calculate the potential. We can instantly switch between them with the commands setxyzSpace and settSpace whose definition I'm not showing because it's kind of boiler plate.
Several of the expressions are in graphics form because their formatting is part of the niceness of the GrassmannCalculus application I'm using.The following starts with Hans` gradient field in vector form. We then convert it to a differential form, which is equivalent to 'lowering the index' in tensor calculus.
setxyzSpace
gradVector =
gradForm = gradVector /. VectorToForm
giving
-((dz (x^2 + y^2))/z^2) + (2 dx x)/z + (2 dy y)/z
The check for integrability is very simple: the exterior derivative of the gradForm must be zero.
ExteriorDerivative[gradForm] // EvaluateExteriorDerivatives
giving
0
To obtain the potential function we integrate a line integral on the vector field from a fixed point to the generic point {x, y, z}. I picked the origin as the fixed point. The actual integration is done in the 1-dimensional t-space.
We define a line as a function of t that maps {x, y, z} onto points in the line. We will need rules on how the coordinates are pulled back to points on the line.
lineFunction := Function[t, t {x, y, z}]
xyzPullback = Thread[{x, y, z} -> lineFunction[t]]
giving
{x -> t x, y -> t y, z -> t z}
To do the integral along the line we simply pull back the gradForm to t-space to obtain a differential form on the line parameterization.
tForm = gradForm // PullbackForms[setxyzSpace, settSpace, xyzPullback]
giving
(dt (x^2 + y^2))/z
This is a trivial integral but we do it formally to show the steps.
settSpace; domain = {t, 0, 1};
FormIntegral[{domain}, tForm] + constant
potential = % // EvaluateFormIntegrals
giving
constant + (x^2 + y^2)/z
Which is the potential. To check we take the exterior derivative of the potential to recover the gradForm. If we want it expressed in a vector basis instead of the form basis we just 'raise the index' using the metric.
setxyzSpace
ExteriorDerivative[potential] // EvaluateExteriorDerivatives
% /. FormToVector
giving
-((dz (x^2 + y^2))/z^2) + (2 dx x)/z + (2 dy y)/z
These routines are part of a GrassmannCalculus Mathematica application that is an extension of John Browne's axiomatization of Grassmann Algebra. It would be very nice for teaching modern physics with modern mathematics.Anyone like to help?