
3.2. VECTORS: CURVILINEAR COORDINATES 99
The arrow operator H is introduced to calculate the scale factor and simplify it
for a given input coordinate u.
>
H:=u->simplify(sqrt(diff(x,u)ˆ2+diff(y,u)ˆ2+diff(z,u)ˆ2),
symbolic):
The relations between the Cartesian coordinates (x, y, z)and(r, θ, φ)are
entered. Then the spherical polar scale factors h
r
, h
θ
,andh
φ
are calculated.
>
x:=r*cos(p)*sin(t); y:=r*sin(p)*sin(t); z:=r*cos(t);
x := r cos(φ)sin(θ) y := r sin(φ)sin(θ) z := r cos(θ)
>
h[r]:=H(r); h[t]:=H(t); h[p]:=H(p);
h
r
:= 1 h
θ
:= rh
φ
:= r sin(θ)
With all the scale factors now determined, the volume of a sphere of radius R
is given by V =
2π
0
π
0
R
0
h
r
h
θ
h
φ
dr dθ dφ.Thisintegralisnowentered,
>
V:=Int(Int(Int(h[r]*h[t]*h[p],r=0..R),t=0..Pi),p=0..2*Pi);
V :=
2 π
0
π
0
R
0
r
2
sin(θ) dr dθ dφ
andevaluatedwiththevalue command.
>
Volume:=value(V);
Volume :=
4 R
3
π
3
The well-known formula for the volume of a sphere results.
A functional operator g is formed for calculating the gradient of a general
function f(u, v, w) for arbitrary input coordinates u, v,andw.
>
g:=(u,v,w)->e[u]*diff(f(u,v,w),u)/h[u]
+e[v]*diff(f(u,v,w),v)/h[v]+e[w]*diff(f(u,v,w),w)/h[w];
g := (u, v, w) →
e
u
diff(f(u, v, w),u)
h
u
+
e
v
diff(f(u, v, w),v)
h
v
+
e
w
diff(f(u, v, w),w)
h
w
Similarly, arrow operators d and c are created for calculating the diver-
gence and curl of a general vector field
A= A
u
(u, v, w)ˆe
u
+ A
v
(u, v, w)ˆe
v
+
A
w
(u, v, w)ˆe
w
for arbitrary coordinates u, v,andw.
>
d:=(u,v,w)->(diff(A[u](u,v,w)*h[v]*h[w],u)
+ diff(A[v](u,v,w)*h[u]*h[w],v)
+ diff(A[w](u,v,w)*h[u]*h[v],w))/(h[u]*h[v]*h[w]):
>
c:=(u,v,w)-> (1/(h[u]*h[v]*h[w]))*
(h[u]*e[u]*(diff(h[w]*A[w](u,v,w),v)-diff(h[v]*A[v](u,v,w),w))
+h[v]*e[v]*(diff(h[u]*A[u](u,v,w),w)-diff(h[w]*A[w](u,v,w),u))
+h[w]*e[w]*(diff(h[v]*A[v](u,v,w),u)-diff(h[u]*A[u](u,v,w),v))):
Finally, here’s an operator L for calculating the Laplacian of f(u, v, w).
>
L:=(u,v,w)->(diff(h[v]*h[w]*diff(f(u,v,w),u)/h[u],u)
+diff(h[u]*h[w]*diff(f(u,v,w),v)/h[v],v)
+diff(h[u]*h[v]*diff(f(u,v,w),w)/h[w],w))/(h[u]*h[v]*h[w]):