A subplot of these notes is to show how a reader with regular access to Mathematica can store, in just three select files, the most useful Mathematica commands for surface theory. These are commands too lengthy for for constant retyping, but typed or copied--just once--into these Save files, they can be used immediately in all later work.
Errors are annoying; please report any you notice to bon@math.ucla.edu.
Contents
1. Fundamentals
2. Surfaces
3. Gaussian
Curvature
4. Isometries
5. Plots
References
[G] Gray, Alfred, "Modern Differential Geometry of Curves and Surfaces"
(first or second edition), CRC Press, ~1000 pages. Organized as a
geometry course, it contains an immense number of Mathematica
commands.
[D] Don, Eugene, "Schaum's Outline of Mathematica",
Prentice-Hall, ~350 pages. Elementary and explicit.
[W] Wolfram, Stephen, "The Mathematica Book" (versions 3,4,5),
Wolfram Media, ~1400+ pages. A detailed account of how
Mathematica works and what it can do.
Starting Up
A few details, notably how to start using
Mathematica, depend on your particular computer system and
are best learned locally--from documentation or other users.
Help
Our use of Mathematica code is limited and should not involve
many problems. Mathematica's online help is quite good: For
common terms, ?term will produce a description. Searching
the Help menu will usually produce examples as well as more details.
In addition, Mathematica has excellent error notification, often useful in correcting bad typing.
f[x_] := x^3-2x+1 or g[u_,v_] := u*Cos[v]-u^2*Sin[v]
Here, as always, an underscore ( _ ) following a letter (or string) makes it a variable. Thus the function f defined above can be evaluated on u or 3.14 or a2+b2, etc.
Derivatives (including partial derivatives) by D[f[x],x] or D[g[u,v],v].
Definite Integrals by Int[f[x], {x,a,b}]. For numerical integration, replace Int by NInt.
Mathematica describes a matrix as a list of lists, the latter being its rows. For example, {{a,b},{c,d}} is a matrix and is treated as such in all contexts. To show it in the usual 2 × 2 form, apply the command MatrixForm.
The determinant of a square matrix m is given by Det[m].
The full power of the dot operator (.) appears only when matrices are involved. First, if p and q are properly sized matrices, then p.q is their product. Next, if m is an m × n matrix and v is an n-vector, then m .v gives the usual operation of m on v. Taking m=n=3 for example, if m1, m2, m3 are the rows of m and v={v1,v2,v3}, then Mathematica defines
m .v to be {m1.v, m2.v, m3.v}
This can be seen to be the result of m (in 3 × 3 form) matrix-multiplying the column-vector corresponding to v, with the resulting column-vector restated as a n-tuple. In this sense, Mathematica obeys the "column-vector convention."
c[t_] := {2*Cos[t], 2*Sin[t], 3t}
gives a helix in R3. Then the vector derivative (i.e., velocity) is returned by D[c[t],t] and the second derivative by D[c[t],t,t], and so on.
x[u_,v_] := {2u*Cos[v],2u*Sin[v],3v}
gives a helicoid in R3.
Surfaces with parameters. A more general helicoid is defined by
helicoid[a_,b_][u_,v_] := [a*u*Cos[v],a*u*Sin[v],b*v].
Then helicoid[2,3] is the special case above.
For any parametrization x : D
M, the metric components are defined to be
E = xu
xu,
F = xu
xv,
G = xv
xv
These functions describe the way x distorts the Euclidean geometry of the plane region D in applying it to M. Specifically,
E measures stretching (or
compression) in the u-direction,
F measures the change in
angle between the u- and v-directions,
G measures stretching (or
compression) in the v-direction.
The metric components are expressed as follows by Mathematica:
ee[x_][u_,v_] := Simplify[D[x[uu,vv],uu].D[x[uu,vv],uu]] /.{uu->,vv->v}
ff[x_][u_,v_] := Simplify[D[x[uu,vv],uu].D[x[uu,vv],vv]] /.{uu->,vv->v}
gg[x_][u_,v_] := Simplify[D[x[uu,vv],vv].D[x[uu,vv],vv]] /.{uu->,vv->v}
The dummy variables uu and vv are needed here to make
ee[x], for instance, a real-valued function on D (note the
dash-dot "/," substitution). Otherwise it would only be an expression
in the specific variables u and v.
We usually represent capital letters (E) by double lower case
letters (ee) since many capitals have special meaning for Mathematica.
These commands are probably the most frequently used throughout the geometry of surfaces. So instead of retyping them whenever they're needed, it's a good idea to save them in a dot-m file efg.m. Then in any later Mathematica session, input this file by: << efg.m and all three commands (though not displayed) will be installed, ready for use.
Here's how to build the dot-m file:
A frequently occuring combination of the metric components is W = (EG-F2)1/2, which Mathematica renders as
ww[x_][u_,v_] := Sqrt[Simplify[ee[x][u,v]*gg[x][u,v]-ff[x][u,v]^2]]
In the special case of a parametrized surface in R3, there is second set of functions, analogous to the metric components, but involving the second derivatives of x. In fact, L, M, and N are the normal components of xuu, xuv, and xvv, respectively, that is,
L =
xuu
U,
M =
xuv
U,
N =
xvv
U,
where U is the (unique up to sign) unit normal vector field of the surface. These functions describe, near each point, the shape of the surface in R3.
To express L, M, and N in Mathematica, note first that U is the unit vector in the direction of the cross product xu× xv. By a well known vector identity, the length of this cross product is just W=(EG-F2)1/2, as above
Another vector identity asserts that the triple scalar product U.(V x W) equals the determinant of the matrix whose rows are U,V,W. Thus, writing ll (double el) for L,
ll[x_][u_,v_] := Simplify[
Det[{D[x[uu,vv],uu,uu],D[x[uu,vv],uu],D[x[uu,vv],vv]}] /
ww[x][uu,vv]] /. {uu->u,vv->v}
The formulas for mm=M and nn=N are the same except that the double derivative uu,uu is replaced by uu,vv and vv,vv respectively.
The procedure for building a dot-m file efgwlmn.m follows same pattern as that given above for efg.m, but with seven commands instead of three. It's economical to include ee, ff, gg since they're likely to be used whenever ll, mm, nn are.
We give three commands for Gaussian curvature. The first, gaussK, is the fastest, but applies only to surfaces in R3. The second, tensorK, works for surfaces in any Rn. The third, superK, is a simple extension of tensorK.
For a parametrized surface in R3, Gaussian curvature K is given by a standard formula:
K=(LN- M2)/(EG-F2),
The command gaussK results when Mathematica's expressions for E,F,G,L,M,N are substituted.
To describe the command gaussK we use a Module.
This creates an enclave where local definitions can be made that cannot
escape to the outside, so the desired formula can be expressed more
simply.
In the module below, the names of the local variables are listed
within braces {...}, next these variables are defined (each definition
followed by a semicolon), then the formula for the command is given.
gaussK[x_][u_,v_] := Module[{xu,xv,xuu,xuv,xvv},
xu=D[x[uu,vv],uu]; xv=D[x[uu,vv],vv];
xuu=D[x[uu,vv],uu,uu];
xuv=D[x[uu,vv],uu,vv];
xvv=D[x[uu,vv],vv,vv];
Simplify[(Det[{xuu,xu,xv}]*Det[{xvv,xu,xv}]-Det[{xuv,xu,xv}]^2)/
(xu.xu*xv.xv-(xu.xv)^2)^2]]/.{uu->u,vv->v}
This a variant of the construction of efg.m described in Section 2.
Again, in any future Mathematica session, input the dot-m file
by: << gaussK.m and the command (though not
displayed) will be installed, ready to use.
Note. Of course, instead of copy-and-paste as above, one
can always just type in the command.
This command computes Gaussian curvature solely in terms of
the metric components E, F, G. Thus it is the computational
expression of Gauss's theorema egregium, which initiated
modern differential geometry.
Again we use a module:
tensorK[ee_,ff_,gg_][u_,v_] := Module[{w,e,f,g},
e=ee[uu,vv]; f=ff[uu,vv]; g=gg[uu,vv];
w=Simplify[Sqrt[e*g-f^2]];
Simplify[(1/(2w))*
(D[(f*D[e,vv] - e*D[g,uu])/(e*w),uu] +
D[(2e*D[f,uu] - f*D[e,uu] - e*D[e,vv])/
(e*w),vv])]] /.{uu->u,vv->v}
Wait to save tensorK till we reach an associated command.
Combining the four previous commands gives a command that
finds the Gaussian curvature of any parametrization
x: D
Rn.
superK[x_][u_,v_] := tensorK[ee[x],ff[x],gg[x]][u,v]
The command superK is meaningful in a Mathematica session only when tensorK is already installed--as well as the
commands for ee, ff, gg given in Section 2.
Thus the simplest plan is to build a dot-m file containing all five:
ee, ff, gg, tensorK, superK. This can be done as for the
previous dot-m files, with tensorK and superK copied,
but ee, ff, gg perhaps just typed in. (They are included to avoid
having to remember to install them separately.)
We call the resulting file tensorsuperK.m, following
Mathematica's style of long but descriptive names.
One of the examples in "Surfaces in R4+" involves the following mapping of R3 into R6:
H(x,y,z) := {x^2/Sqrt[2], y^2/Sqrt[2], z^2/Sqrt[2], x*y, y*z, z*x}
Restricting this map to the unit sphere in R3 leads to this parametrization of a surface in R6:
x[u_,v_] := H[x,y,z]/. {x->Cos[v]*Cos[u], y->Cos[v]*Sin[u], z->Sin[v]}
In context, we expect this surface to have Gaussian curvature +1, hence here we expect superK[x][u,v] to give +1.
A test of tensorK requires a detour.
<U,U> = E, <U,V> = F, <V,V> = G,
where U and V are the unit vector fields in the u- and v-directions, respectively.
For example, on the disk D: r< 2 in R2, define:
eeh[u_,v_] := 1/(1-(u^2+v^2)/4)^2
ffh[u_,v_] := 0
ggh[u_,v_] := 1/(1-(u^2+v^2)/4)^2
These functions turn D into the hyperbolic plane (Poincaré disk model). To find its Gaussian curvature, neither gaussK or superK will work, since D does not derive its metric from a containing Euclidean space. But if all is well, tensorK[eeh,ffh,ggh][u,v] will give -1.
Historical Note: This model of the hyperbolic plane was
found by Poincaré in the late 1800s. It may seem to be just
a clever little artifact, but it served two important purposes:
First, it pointed the way to
Riemannian manifolds, the central objects of study in
differential geometry. In such a manifold, the geometric structure is
axiomatized without reference to any containing Euclidean space.
Second, it presented a simple
case of a difficult question: can the hyperbolic plane (or an isometric
copy of it) be found in some Euclidean space? This question remained
unanswered until 1956, when John Nash (of "A Beautiful Mind") proved
that every Riemannian manifold can be found in a Euclidean
spaceof sufficiently high dimension.
Then an imbedding of the hyperbolic plane in R6 was
soon found by Blanusa.
A one-to-one differentiable mapping F: M
M' is an isometry provided (*) each pair
of tangent vectors v,w at a point of M is carried to tangent vectors
v',w' on M' with the same inner product.
It follows that if c is a curve in M, then F(c) has the same length in M', and if G is a region in M then F(G) has the same area as G, and so on. When such an isometry exists, the surface M and M' are said to be isometric and to have the same intrinsic geometry. Gauss's theorema egregium asserts that Gaussian curvature is preserved by isometries and thus belongs to the intrinsic geometry of surfaces.
Intuitively, this geometry of M is what is observed by its inhabitants, who have no conception of the shape of M in any surrounding Euclidean space.
To find a computational expression of the (*) condition above, let
x: D
M be a coordinate patch. Then the
coordinate vector fields xu, xv at any point
of x(D) form a basis for all the tangent vectors at that point.
Now let y=F(x). Then xu and xv are carried to yu and yv. So
the (*) criterion holds for all tangent vectors <=> the (*) criterion holds for xu and xv <=> E=E', F=F', G=G'.
There are four basic types:
Plot[f[x]//Evaluate, {x,a,b}]
Plot3D[g[x,y]//Evaluate, {x,a,b}, {y,c,d}]
R3 is defined on the rectangle D:
0
u
1,
0
v
, then its image is plotted by
ParametricPlot3D[x[u,v]//Evaluate, {u,0,1},
{v,0,
}]
Plots can be refined in many, many ways by specifying values for various options. The form is option->value. For example, in
Plot[f[x]//Evaluate, {x,a,b}, AspectRatio->Automatic]
Mathematica is ordered to use the same scale on both axes, and in
ParametricPlot3D[x[u,v]//Evaluate, {u,0,1},
{v,0,
}, Boxed->False]
the box ordinarily containing the figure does not appear.
The options available for a given command cmd, along
with their default values, are listed by Options[cmd]. Then
?opt will give a description of the option.
Previously drawn (and named) plots can be shown on the same page by
Show[plot1, plot2,plot3]