Geodesics connecting two points on a torus
> 
with(VariationalCalculus):

The parametric equation of a torus with major and minor radii of and .
> 
< (a+b*cos(v))*cos(u), (a+b*cos(v))*sin(u), b*sin(v) >;
x := unapply(%, u, v):

Calculate the coefficients , , and of the first fundamental form:
> 
xu := diff(x(u,v),u):
xv := diff(x(u,v),v):
E := unapply(simplify(xu^+ . xu), u, v);
F := unapply(simplify(xu^+ . xv), u, v);
G := unapply(simplify(xv^+ . xv), u, v);

Look for geodesics of the form . These account for all geodesics with the exception
of those corresponding to constant. The latter are plain circles so we don't need Maple
to calculate them.
From differential geometry, the length of any curve of the form
is given by where:
> 
Upsilon := sqrt(E(u, v(u)) + 2*F(u, v(u))*diff(v(u),u) + G(u,v(u))*(diff(v(u),u))^2);

The minimum length is obtained with the help from the EulerLagrange equation
which leads to a second order nonlinear differential equation in :
> 
EulerLagrange(Upsilon, u, v(u)):
remove(type, %, equation)[]:
isolate(%, diff(v(u), u, u)):
de := simplify(%);

Pick numbers for the torus's radii:
> 
torus := plot3d(x(u,v), u=Pi..Pi, v=Pi..Pi,
scaling=constrained, color="khaki", style=surface);


Example 1


Calculate a geodesic from to , :
> 
bc1 := v(0)=0, v(Pi/2)=Pi/2;

> 
dsol1 := dsolve({de, bc1}, numeric, output=operator);

> 
display(
torus,
tubeplot([seq(eval(x(u, v(u)), dsol1))], u=0..Pi/2, color=red, radius=0.1),
pointplot3d(eval([x(0,v(0)),x(Pi/2,v(Pi/2))], dsol1), symbol=solidsphere, symbolsize=20, color="Orange"),
lightmodel=light4, thickness=5, orientation=[5,75,0], size=[700,400],
style=surface, axes=none);



Example 2


> 
bc2 := v(0)=0, v(Pi/2)=Pi;

> 
dsol2 := dsolve({de, bc2}, numeric, output=operator);

> 
display(
torus,
tubeplot([seq(eval(x(u, v(u)), dsol2))], u=0..Pi/2, color=red, radius=0.1),
pointplot3d(eval([x(0,v(0)),x(Pi/2,v(Pi/2))], dsol2), symbol=solidsphere, symbolsize=20, color="Orange"),
lightmodel=light4, thickness=5, orientation=[65,65,0], size=[700,400],
style=surface, axes=none);



Example 3


The end points in this example are identical to those of Example 1 but the new geodesic,
drawn in cyan, is different. In fact, there are infinitely many geodesics that connect
those two points.
> 
bc3 := v(0)=0, v(Pi/2)=5*Pi/2;

> 
dsol3 := dsolve({de, bc3}, numeric, output=operator);

> 
display(
torus,
tubeplot([seq(eval(x(u, v(u)), dsol1))], u=0..Pi/2, color=red, radius=0.1),
tubeplot([seq(eval(x(u, v(u)), dsol3))], u=0..Pi/2, color=cyan, radius=0.1),
pointplot3d(eval([x(0,v(0)),x(Pi/2,v(Pi/2))], dsol3), symbol=solidsphere, symbolsize=20, color="Orange"),
lightmodel=light4, thickness=5, orientation=[65,45,0], size=[700,400],
style=surface, axes=none, viewpoint=circleright);


