*Article* **Using the Theory of Functional Connections to Solve Boundary Value Geodesic Problems**

**Daniele Mortari**

Aerospace Engineering, Texas A&M University, 3141 TAMU, College Station, TX 77843, USA; mortari@tamu.edu

**Abstract:** This study provides a least-squares-based numerical approach to estimate the boundary value geodesic trajectory and associated parametric velocity on curved surfaces. The approach is based on the Theory of Functional Connections, an analytical framework to perform functional interpolation. Numerical examples are provided for a set of two-dimensional quadrics, including ellipsoid, elliptic hyperboloid, elliptic paraboloid, hyperbolic paraboloid, torus, one-sheeted hyperboloid, Moëbius strips, as well as on a generic surface. The estimated geodesic solutions for the tested surfaces are obtained with residuals at the machine-error level. In principle, the proposed approach can be applied to solve boundary value problems in more complex scenarios, such as on Riemannian manifolds.

**Keywords:** functional interpolation; ordinary differential equations; numerical methods

#### **1. Introduction**

Geodesic trajectories represent the paths on a curved surface, whose acceleration has no component on the local tangent plane to the surface. In many common scenarios, a geodesic represents the straightest path between two points. In particular, in a Riemannian manifold, geodesics are characterized by the property of having no geodesic curvature [1,2].

Most of the general studies on geodesics' trajectories are provided as initial value problems, while most of the boundary value problems are related to the biaxial and triaxial ellipsoid. In [3], the boundary value problem on an ellipsoid with boundary (Dirichlet) conditions is replaced by an initial value problem with Dirichlet and Neumann conditions. In particular, the Neumann condition is obtained iteratively by numerically integrating a system of four first-order differential equations. Triaxial ellipsoids are considered in [4,5], while [6] has provided an analytical approach to solve this boundary value problem with symmetry. Reference [7] contains, because of its importance to terrestrial geodesy, a rich literature survey on the geodesic equations for low eccentric ellipsoid in both Cartesian and polar coordinates. Since the problem of fitting ellipsoid is important in geodesy (all geodetic calculations are performed on a reference ellipsoid), Refs. [5,8] analyzes the computational differences in the fitting ellipsoid using biaxial ellipsoid instead of triaxial ellipsoid and by performing least-squares ellipsoid fitting. Noteworthy, Reference [7] has improved (in terms of computational time) the existing solutions using differential equations in Cartesian coordinates and Taylor series expansions by simplifying previous formulations.

In this study, the geodesic boundary value problem is numerically investigated for *any* curved surface using the general geodesic equations from differential geometry. These geodesic equations are then solved by nonlinear least-squares using the method that the Theory of Functional Connections [9] (TFC) has introduced to solve differential equations [10,11]. The existence of a solution for the geodesic boundary value problem (boundary value problems, in general, may have a unique solution, no solution, or infinite solutions) is guaranteed by the Hopf–Rinow theorem [12,13]:

*If a length-metric space* (*M*, *d*) *is complete and compact then any two points,* (*p*1, *p*<sup>2</sup> ∈ *M*)*, can be connected by a minimizing geodesic*.

**Citation:** Mortari, D. Using the Theory of Functional Connections to Solve Boundary Value Geodesic Problems. *Math. Comput. Appl.* **2022**, *27*, 64. https://doi.org/10.3390/ mca27040064

Academic Editor: Nicholas Fantuzzi

Received: 12 July 2022 Accepted: 25 July 2022 Published: 27 July 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

In this theorem, *M* indicates a manifold and *d* the metric distance. Roughly speaking, *complete* indicates a space where there are no "points missing" from it (inside or at the boundary), while *compact* indicates a space that is *closed* (space bounds included) and *bounded* (distance between any two points limited).

Motivated by this theorem, this study proposes a general numerical and accurate approach to solve boundary value geodesic problems in curved surfaces. First, this study briefly provides the geodesic equations for the general Riemannian spaces, followed by a short background on TFC. Then, it shows how to apply TFC to solve boundary value geodesic problems by nonlinear least-squares. In particular, an ad hoc algorithm to avoid local minima is presented.

The proposed approach is then numerically tested on various quadric surfaces, such as triaxial ellipsoid, elliptic hyperboloid, elliptic paraboloid, hyperbolic paraboloid, torus, one-sheeted hyperboloid, Moëbius strip, and on a generic surface. In all these tests, machine error estimation of the geodesic trajectory is obtained along with the indirect numerical proof that the associated parametric velocity is constant.

#### **2. Background on Geodesics Equations on Riemannian Manifold**

A Riemannian manifold is a smooth curved space in which the infinitesimal distance, d*s*, satisfies

$$\mathbf{ds}^2 = \mathbf{g}\_{ij} \, \mathbf{dx}^i \, \mathbf{dx}^j \tag{1}$$

where *gij* is the covariant metric tensor of the space and where Einstein's notation has been used in Equation (1).

The metric tensor is the fundamental tool used in differential geometry to study curved spaces. Specifically, for Euclidean spaces, the metric tensor is diagonal (*gij* = 0 if *i* = *j*) and, in particular, is the identity, *gij* = *δij*, for the Cartesian metric tensor. The metric tensor, *gij*, is the matrix composed by all inner products between all partials of the vector defining the Riemannian surface, *p*(*x*1, *x*2,..., *xn*)

$$\mathbf{g}\_{ij} = \left(\frac{\partial p}{\partial x\_i}\right)^\top \frac{\partial p}{\partial x\_j}$$

In Riemannian geometry, geodesics are not the same as "shortest curves" between two points, though the two concepts are closely related. The difference is that geodesics are only locally the shortest distance between points. Going the "long way round" on a great circle between two points on a sphere is a geodesic but not the shortest path between the points. In addition, geodesic paths need not be unique.

On a curved surface, the length of a parametric trajectory, defined by the coordinates *x<sup>i</sup>* = *x<sup>i</sup>* (*t*) and connecting the position vectors, *p*(*t*0) and *p*(*tf*), respectively, is,

$$L = \int\_{t\_0}^{t\_f} \, \mathrm{d}s = \int\_{t\_0}^{t\_f} \sqrt{g\_{ij} \frac{\mathrm{d}x^i}{\mathrm{d}t} \, \frac{\mathrm{d}x^j}{\mathrm{d}t}} \, \mathrm{d}t \tag{2}$$

This parametric trajectory has no normal acceleration if it satisfies the following *n* differential equations [1,2,14],

$$\frac{\mathrm{d}^2 \mathrm{x}^i}{\mathrm{d}t^2} + \Gamma^i\_{jk} \frac{\mathrm{d} \mathrm{x}^j}{\mathrm{d}t} \xrightarrow[\mathrm{d} \mathrm{f}]{} \frac{\mathrm{d} \mathrm{x}^k}{\mathrm{d}t} = 0. \tag{3}$$

These *n* second-order ordinary differential equations are the *geodesic equations*. They define the geodesic trajectories on a manifold with metric tensor, *gij*. In Equation (3), the Γ*<sup>i</sup> jk* terms are the Christoffel symbols of second kind, defined as,

$$\Gamma^i\_{jk} = \frac{1}{2} g^{mi} \left( \frac{\partial \mathcal{g}\_{km}}{\partial \mathbf{x}^j} + \frac{\partial \mathcal{g}\_{mj}}{\partial \mathbf{x}^k} - \frac{\partial \mathcal{g}\_{jk}}{\partial \mathbf{x}^m} \right) \tag{4}$$

where *gmi* is the controvariant inverse of the covariant metric tensor (or conjugate or dual metric),

$$\mathbf{g}^{mi} = (\mathbf{g}\_{mi})^{-1}$$

Note that the Christoffel symbols satisfy the relationship, Γ*<sup>i</sup> jk* = <sup>Γ</sup>*<sup>i</sup> kj* and are related to the Christoffel symbols of the first kind, [*m*, *jk*], by the relationship, [*m*, *jk*] = *gmi* Γ*<sup>i</sup> jk*.

#### *Geodetic (Parametric) Velocity*

*A curve on a surface is called geodesic if, at every point, the acceleration is either zero or parallel to the normal. A geodesic trajectory*, *p*(*t*), on a curved surface has constant parametric speed. The proof is immediate,

$$\frac{\mathbf{d}\dot{p}^2}{\mathbf{d}t} = \frac{\mathbf{d}(\dot{p}^\tau \dot{p})}{\mathbf{d}t} = 2\dot{p}^\tau \dot{p} = 0.$$

The word "velocity," here, is not the instantaneous ratio between distance and time, but the instantaneous ratio between distance and the parameter *t* selected to describe the trajectory (which can also be the time).

Let us consider a two-dimensional surface in a three-dimensional space. Let the surface be described by the parametic equations,

$$x = f\_x(\mu, v), \qquad y = f\_y(\mu, v) \quad \text{and} \quad z = f\_z(\mu, v),$$

then, by computing,

$$\dot{p}\_x = \frac{\partial f\_x}{\partial u}\dot{u} + \frac{\partial f\_x}{\partial v}\dot{v}, \qquad \dot{p}\_y = \frac{\partial f\_y}{\partial u}\dot{u} + \frac{\partial f\_y}{\partial v}\dot{v}, \quad \text{and} \quad \dot{p}\_z = \frac{\partial f\_z}{\partial u}\dot{u} + \frac{\partial f\_z}{\partial v}\dot{v},$$

the velocity in a trajectory defined by *p*˙(*u*(*t*), *v*(*t*)), is provided by *p*˙ <sup>2</sup> = *p*˙ 2 *<sup>x</sup>* + *p*˙ 2 *<sup>y</sup>* + *p*˙ 2 *z*. To give a trivial example, the parametric description of a unit-radius sphere is provided by,

> *p*<sup>T</sup> = \$ sin *u* cos *v*, sin *u* sin *v*, cos *u* %

where *u* ∈ [0, *π*] and *v* ∈ [0, 2*π*). The covariant metric tensor and the geodesic equations for the sphere are,

$$\mathcal{R}\_{ij} = \begin{bmatrix} 1 & 0 \\ 0 & \sin^2 u \end{bmatrix} \quad \text{and} \quad \begin{cases} \mathcal{L}\_u = \vec{u} - \vec{v}^2 \sin u \cos u = 0 \\ \mathcal{L}\_v = \vec{v} + 2\vec{u} \,\vec{v} \cot u = 0 \end{cases} \quad \text{and} \quad \vec{\omega} = \vec{0}$$

respectively, and the geodetic parametric velocity on the sphere is,

$$
\vec{p}^2 = 2\vec{u}^2\cos^2 u + \vec{v}^2\sin^2 u.
$$

Note that *u* = 0 and *u* = *π* make singular the *gij* matrix and, consequently, make singular the geodesic equations. This singularity changes location if another set of polar coordinates is selected to describe a sphere.

#### **3. Background on the Theory of Functional Connections**

The Theory of Functional Connections (TFC) is a mathematical framework to perform *functional interpolation* [9,15]. This is performed by analytically deriving some functionals, called *constrained expressions*, representing *all* functions satisfying a set of linear constraints in *n*-dimensional space. This way, constrained optimization problems subject to linear constraints, such as differential equations, are transformed into unconstrained problems. The optimization problem consists then of deriving the expression of an unconstrained *free function*, *g*(*x*) (Note that *g*(*x*) can be discontinuous, partially defined, and even the Dirac delta function, as long as it is defined on where the constraints are defined.).

In general, for a univariate function, *y*(*x*), subject to *n* linear constraints (e.g., points, derivatives, integrals, and any linear combination of them), two equivalent definitions of constrained expressions can be introduced [15–17],

$$g(\mathbf{x}, \mathbf{g}(\mathbf{x})) = \mathbf{g}(\mathbf{x}) + \sum\_{k=1}^{n} \eta\_k(\mathbf{x}, \mathbf{g}(\mathbf{x})) \, s\_k(\mathbf{x}) \tag{5}$$

$$g(\mathbf{x}, \mathbf{g}(\mathbf{x})) = \mathbf{g}(\mathbf{x}) + \sum\_{k=1}^{n} \rho\_k(\mathbf{x}, \mathbf{g}(\mathbf{x})) \, \boldsymbol{\phi}\_k(\mathbf{x}, \mathbf{s}(\mathbf{x})) \tag{6}$$

In the formal definition of Equation (5), the *ηk*(*x*, *g*(*x*)) are *functional coefficients* whose expressions are derived by imposing the *n* constraints on (5), and the *sk*(*x*) are a set of *n* user-defined linearly independent *support functions*. In Equation (6), the *φk*(*x*, *s*(*x*)) are *switching functions* which imply changing between the constraints, and the *ρk*(*x*, *g*(*x*)) are *projection functionals*, which project the free function *g*(*x*) to the *k*th constraint. See Ref. [9] for a complete and detailed explanation of these terms.

For example, consider a function *y*(*x*) subject to the constraints

$$
\left.\frac{\mathrm{d}y}{\mathrm{d}x}\right|\_{x\_1} = \dot{y}\_1 \quad \text{and} \quad \left.\frac{\mathrm{d}y}{\mathrm{d}x}\right|\_{x\_2} = \dot{y}\_2. \tag{7}
$$

Using the form given in Equation (5) with *s*1(*x*) = *x* and *s*2(*x*) = *x*2, the constraints in Equation (7) can be expressed as

$$g(\mathbf{x}, \mathbf{g}(\mathbf{x})) = \mathbf{g}(\mathbf{x}) + \eta\_1 s\_1(\mathbf{x}) + \eta\_2 s\_2(\mathbf{x}) = \mathbf{g}(\mathbf{x}) + \eta\_1 \mathbf{x} + \eta\_2 \mathbf{x}^2 \tag{8}$$

where the two constants *η*<sup>1</sup> and *η*<sup>2</sup> are computed from Equations (7) and (8) as follows:

$$\begin{Bmatrix} \dot{\mathcal{Y}}\_1 - \dot{\mathcal{Y}}\_1\\ \dot{\mathcal{Y}}\_2 - \dot{\mathcal{Y}}\_2 \end{Bmatrix} = \begin{bmatrix} \dot{s}\_1(\mathbf{x}\_1) & \dot{s}\_2(\mathbf{x}\_1)\\ \dot{s}\_1(\mathbf{x}\_2) & \dot{s}\_2(\mathbf{x}\_2) \end{bmatrix} \begin{Bmatrix} \eta\_1\\ \eta\_2 \end{Bmatrix} \quad \rightarrow \quad \begin{Bmatrix} \eta\_1\\ \eta\_2 \end{Bmatrix} = \begin{bmatrix} 1 & 2\mathbf{x}\_1\\ 1 & 2\mathbf{x}\_2 \end{bmatrix}^{-1} \begin{Bmatrix} \dot{\mathcal{Y}}\_1 - \dot{\mathcal{Y}}\_1\\ \dot{\mathcal{Y}}\_2 - \dot{\mathcal{Y}}\_2 \end{Bmatrix}$$

from which,

$$\begin{Bmatrix} \eta\_1\\ \eta\_2 \end{Bmatrix} = \frac{1}{x\_2 - x\_1} \begin{Bmatrix} x\_2(\dot{y}\_1 - \dot{y}\_1) - x\_1(\dot{y}\_2 - \dot{y}\_2) \\ -(\dot{y}\_1 - \dot{y}\_1) + (\dot{y}\_2 - \dot{y}\_2) \end{Bmatrix} \cdot \vec{k}$$

Substituting the *η*<sup>1</sup> and *η*<sup>2</sup> expressions into Equation (8), the following *constrained expression*,

$$g(\mathbf{x}, \mathbf{g}(\mathbf{x})) = \mathbf{g}(\mathbf{x}) + \underbrace{\frac{\mathbf{x} \left(2\mathbf{x}\_2 - \mathbf{x}\right)}{2\left(\mathbf{x}\_2 - \mathbf{x}\_1\right)}}\_{\phi\_1(\mathbf{x}, \mathbf{s}(\mathbf{x}))} \underbrace{\frac{\dot{\mathbf{y}}\_1 - \dot{\mathbf{y}}\_1}{\rho\_1(\mathbf{x}, \mathbf{g}(\mathbf{x}))}}\_{\phi\_2(\mathbf{x}, \mathbf{s}(\mathbf{x}))} + \underbrace{\frac{\mathbf{x}\left(\mathbf{x} - 2\mathbf{x}\_1\right)}{2\left(\mathbf{x}\_2 - \mathbf{x}\_1\right)}}\_{\phi\_2(\mathbf{x}, \mathbf{s}(\mathbf{x}))} \underbrace{\frac{\dot{\mathbf{y}}\_2 - \dot{\mathbf{y}}\_2}{\rho\_2(\mathbf{x}, \mathbf{g}(\mathbf{x}))}}\_{\rho\_2(\mathbf{x}, \mathbf{g}(\mathbf{x}))}\tag{9}$$

is obtained for the constraints given in Equation (7). Equation (9) satisfies the constraints (7), *no matter what the free function g*(*x*) *is*. Moreover, Equation (9) indicates the expressions of the switching functions, *φk*(*x*, *s*(*x*)), and the projection functionals, *ρk*(*x*, *g*(*x*)). Here, the meaning of the switching functions becomes more clear: when the first constraint, *y*˙(*x*1) = *y*˙1, holds then *φ*˙ <sup>1</sup>(*x*1) = 1 and *φ*˙ <sup>2</sup>(*x*1) = 0; when the second constraint, *y*˙(*x*2) = *y*˙2, holds then *φ*˙ <sup>1</sup>(*x*2) = 0 and *φ*˙ <sup>2</sup>(*x*2) = 1. The projection functionals are scalars in this univariate case, but they become functionals in the multivariate case (see [9] for full explanation).

The multivariate TFC [9,16] extends the original univariate theory [15] to *n* dimensions and to any linear (boundary and/or internal) constraints. This extension can be summarized by the expression,

$$g(\mathfrak{x}, \mathfrak{g}(\mathfrak{x})) = h(\mathfrak{c}(\mathfrak{x})) + \mathfrak{g}(\mathfrak{x}) - h(\mathfrak{g}(\mathfrak{x})),$$

where *x* = (*x*1, *x*1, ... , *xn*)<sup>T</sup> is the vector of *n* coordinates, *c*(*x*) is a function specifying the linear constraints, *h*(*c*(*x*)) is *any* interpolating function satisfying the linear constraints, and *g*(*x*) is the free function. Several examples on how to derive constrained expressions can be found in [9,17,18].

The Theory of Functional Connections has been developed for points, derivatives, integrals, infinite, component constraints, and any linear combination of them for univariate functions [15] as well as multivariate functions [16] in rectangular domains, while in generic domains some initial results have been obtained via domain mapping [19]. The main feature of these functionals (constrained expressions) is that they allow for restricting the whole function space of a constrained optimization problems to just the space of its feasible solutions, fully satisfying the constraints. This way, a large number of constrained optimization problems can be transformed into unconstrained ones, which can be solved by more simple, efficient, robust, reliable, fast, and accurate methods.

The first application of TFC was in solving linear [10] and nonlinear [11] ODEs. This has been conducted by expanding the free function *g*(*x*) in terms of a set of basis functions (e.g., orthogonal polynomials, Fourier, neural networks, etc.). Linear or nonlinear leastsquares method is then used to find the coefficients of the expansion. This TFC approach for solving ODEs has many advantages over traditional methods: (1) it consists of a unified framework to solve IVP, BVP, or multi-valued problems, (2) it provides an analytically approximated solution that can be used for subsequent manipulation (derivatives, integrals), (3) the solution is usually obtained in millisecond and at machine error accuracy, (4) the procedure is numerically robust (small condition number), and (5) it can solve differential equations subject to a variety of different constraint types. Additionally, TFC has been also applied to solve other mathematical optimization problems [20] such as in: homotopy continuation for control problems [21], epidemiological models [22], radiative transfer problems [23], rarefied-gas dynamics [24], Timoshenko-Ehrenfest beam [25], hybrid systems [26], machine learning [27–30], quadratic and nonlinear programming problems subject to linear equality constraints [31], orbit transfer and propagation [18,32,33], optimal control problems via indirect methods, relative motion [34], landing on small and large planetary bodies [35], and intercept problems [30].

#### **4. Solving the Geodesic Equations Using the Theory of Functional Connections**

Any trajectory on a two-dimensional surface in three-dimensional space can always be described by two coordinates, [*u*(*t*), *v*(*t*)], depending on a parameter *t*. Specifically, let us consider a trajectory from an initial point [*u*0, *v*0] to a final point [*uf* , *vf* ], while the parameter range is *t* ∈ [−1, +1].

All possible trajectories, [*u*(*t*), *v*(*t*)], connecting [*u*0, *v*0] to [*uf* , *vf* ], can be represented by the following two functionals (constrained expressions) [9]

$$\begin{cases} u(t, \mathcal{g}\_u(t)) = \mathcal{g}\_u(t) + \frac{1-t}{2} (u\_0 - \mathcal{g}\_{u0}) + \frac{1+t}{2} (u\_f - \mathcal{g}\_{uf}) \\ v(t, \mathcal{g}\_v(t)) = \mathcal{g}\_v(t) + \frac{1-t}{2} (v\_0 - \mathcal{g}\_{v0}) + \frac{1+t}{2} (v\_f - \mathcal{g}\_{vf}) \end{cases} \tag{10}$$

where *gu*(*t*) and *gv*(*t*) are two free functions and where it has been set *gu*<sup>0</sup> = *gu*(−1), *gv*<sup>0</sup> = *gv*(−1), *gu f* = *gu*(+1), and *gv f* = *gv*(+1). *No matter what the functions, gu*(*t*) *and gu*(*t*) *are*, the Equation (10) always generate trajectories moving from [*u*0, *v*0] to [*uf* , *vf* ], as *t* increases from *t* = −1 to *t* = +1.

The parametric derivatives of Equation (10) are,

$$\begin{cases} \dot{u}(t, \mathcal{g}\_{\boldsymbol{u}}(t)) = \dot{\mathcal{g}}\_{\boldsymbol{u}}(t) - \frac{1}{2} (\boldsymbol{u}\_{0} - \mathcal{g}\_{\boldsymbol{u}0}) + \frac{1}{2} (\boldsymbol{u}\_{f} - \mathcal{g}\_{\boldsymbol{u}f}) \\ \dot{u}(t, \mathcal{g}\_{\boldsymbol{u}}(t)) = \ddot{\mathcal{g}}\_{\boldsymbol{u}}(t) \\ \dot{v}(t, \mathcal{g}\_{\boldsymbol{v}}(t)) = \dot{\mathcal{g}}\_{\boldsymbol{v}}(t) - \frac{1}{2} (\boldsymbol{v}\_{0} - \mathcal{g}\_{\boldsymbol{v}0}) + \frac{1}{2} (\boldsymbol{v}\_{f} - \mathcal{g}\_{\boldsymbol{v}f}) \\ \ddot{v}(t, \mathcal{g}\_{\boldsymbol{v}}(t)) = \ddot{\mathcal{g}}\_{\boldsymbol{v}}(t) \end{cases} \tag{11}$$

Let us express the free functions, *gu*(*t*) and *gv*(*t*), as a linear combination of linearly independent basis functions, *h*(*t*), (e.g., orthogonal polynomials). Then,

$$\begin{cases} \mathbf{g}\_{u}(t) = \mathbf{f}\_{u}^{\mathrm{r}} h(t) \\ \mathbf{g}\_{v}(t) = \mathbf{f}\_{v}^{\mathrm{r}} h(t), \end{cases} \qquad \begin{cases} \dot{\mathbf{g}}\_{u}(t) = \mathbf{f}\_{u}^{\mathrm{r}} \dot{h}(t) \\ \dot{\mathbf{g}}\_{v}(t) = \mathbf{f}\_{v}^{\mathrm{r}} h(t), \end{cases} \quad \text{and} \quad \begin{cases} \ddot{\mathbf{g}}\_{u}(t) = \mathbf{f}\_{u}^{\mathrm{r}} \ddot{h}(t) \\ \ddot{\mathbf{g}}\_{v}(t) = \mathbf{f}\_{v}^{\mathrm{r}} \ddot{h}(t). \end{cases} .\tag{12}$$

The geodesic equations provided in Equation (3) can be solved using the expressions given in Equations (10) and (11), with the free functions expanded as in Equation (12), and by discretizing the parameter *t* from *t* = −1 to *t* = +1. (When expressing the free functions in terms orthogonal polynomial, the best discretization of *t* for the least-squares problem is obtained by the Chebyshev–Gauss–Lobatto points distribution.) The resulting equations are two nonlinear algebraic equations in the unknown coefficient vectors, *ξ<sup>u</sup>* and *ξv*, that can be solved by nonlinear least-squares,

$$
\begin{Bmatrix} \mathfrak{F}\_{\boldsymbol{u}} \\ \mathfrak{F}\_{\boldsymbol{v}\boldsymbol{v}} \end{Bmatrix}\_{k+1} = \begin{Bmatrix} \mathfrak{F}\_{\boldsymbol{u}} \\ \mathfrak{F}\_{\boldsymbol{v}\boldsymbol{v}} \end{Bmatrix}\_{k} - (\mathcal{J}\_{k}^{\mathrm{r}} \mathcal{J}\_{k})^{-1} \mathcal{J}\_{k}^{\mathrm{r}} \begin{Bmatrix} \mathcal{L}\_{\boldsymbol{u}} \\ \mathcal{L}\_{\boldsymbol{v}} \end{Bmatrix}\_{k} \quad \text{where} \quad \mathcal{J}\_{k} = \begin{bmatrix} \frac{\partial \mathcal{L}\_{\boldsymbol{u}}}{\partial \mathfrak{F}\_{\boldsymbol{u}}}, & \frac{\partial \mathcal{L}\_{\boldsymbol{u}}}{\partial \mathfrak{F}\_{\boldsymbol{v}}} \\ \frac{\partial \mathcal{L}\_{\boldsymbol{v}}}{\partial \mathfrak{F}\_{\boldsymbol{u}}}, & \frac{\partial \mathcal{L}\_{\boldsymbol{v}}}{\partial \mathfrak{F}\_{\boldsymbol{v}}} \end{Bmatrix}\_{k} \tag{13}
$$

is the Jacobian of the system.

Note that, the constrained expressions given in Equation (10) are derived using constant and linear terms of support functions. This implies that the set of basis functions adopted in the least-squares process for the free functions, *gu*(*t*) and *gv*(*t*), cannot include both the constant and the linear terms. For instance, if Chebyshev orthogonal polynomials are selected as support functions, then *T*<sup>0</sup> = 1 and *T*<sup>1</sup> = *t* must be excluded, otherwise the matrix to invert in the least-squares process becomes singular. This is because a leastsquares process of a linear combination of functions is singular if not all the functions are linearly independent.

#### *Initial Guess and the Local Minima Problem*

Since the constrained expressions provide trajectories always satisfying the constraints (for any expression of the free functions), then the most natural (and simplest) initial guess is to start the iterative least-squares solving Equation (13) by setting *ξ<sup>u</sup>* = *ξ<sup>v</sup>* = **0**. This is equivalent to initially select *gu*(*t*) = *gv*(*t*) = 0 and, consequently—see Equation (10)—, selecting an initial linear variation of the parametric variables, *u* and *v*, from the initials (*u*0, *v*0) to the final values (*uf* , *vf*).

Nonlinear least-squares applied to find the geodesic trajectory is, unfortunately, a process affected by local minima. Typically, when an iterative procedure enters into the convergence phase, then each following step is smaller than the previous,

$$L\_2(\Delta \mathbf{f}\_{k+1}) < L\_2(\Delta \mathbf{f}\_k) \qquad \text{where} \qquad \Delta \mathbf{f}\_k = \begin{Bmatrix} \Delta \mathbf{f}\_u \\ \Delta \mathbf{f}\_v \end{Bmatrix}\_k \tag{14}$$

This convergence criteria has two interesting aspects: (1) it can be used to push the convergence to the maximum accuracy and (2) no tolerance is needed to stop the iterations. In fact, when the convergence reaches the maximum accuracy, the procedure cannot anymore improve the estimation of Δ*ξ<sup>k</sup>* and the inequality, *L*<sup>2</sup> Δ*ξk*+<sup>1</sup> > *L*<sup>2</sup> Δ*ξ<sup>k</sup>* , happens because of numerical errors (convergence saturation).

Figure 1 shows the flowchart of the algorithm adopted to avoid local minima. Starting with *ξ*<sup>0</sup> = **0**, the least-squares iterations continue until Equation (14) is verified for *N* consecutive times (initial convergence loop). During this sequence, if the least-squares diverges, then the algorithm restarts with a new random initial guess. If Equation (14) is verified for *N* consecutive times, then the algorithm enters into the convergence loop and exits when *L*<sup>2</sup> Δ*ξk*+<sup>1</sup> > *L*<sup>2</sup> Δ*ξ<sup>k</sup>* is experienced. Then, the *L*<sup>2</sup> norm of the residuals

is computed. The *L*<sup>2</sup> norm of the residuals allows one to discriminate local minima and global minima (associated with the geodesic trajectory) using a small tolerance, such as *ε* = 10−15. If *L*<sup>2</sup> *rk* > *ε* then the algorithm restarts with a new random initial guess.

**Figure 1.** Local minima avoidance algorithm flowchart.

#### **5. Numerical Validations**

In this section, some boundary value geodesic problems are numerically solved to validate the proposed methodology on 2-dimensional surfaces, for visualization purposes. The proposed approach has been tested on eight different kind of surfaces: triaxial ellipsoid, elliptic hyperboloid, elliptic paraboloid, hyperbolic paraboloid, one-sheeted hyperboloid, torus, Moëbius strip, and a generic surface. Six of them are shown in Figure 2.

**Figure 2.** Examples of six tested surfaces.

#### *5.1. Triaxial Ellipsoid*

A (non-oriented) triaxial ellipsoid is described by,

*p*<sup>T</sup> = \$ *a* sin *u* cos *v*, *b* sin *u* sin *v*, *c* cos *u* % where *u* ∈ [0, *π*] and *v* ∈ [0, 2*π*), and (*a*, *b*, *c*) are the three ellipsoid semi-major axes. The covariant metric tensor for the ellipsoid is,

$$\mathcal{G}\_{ij} = \begin{bmatrix} \cos^2 u (a^2 \cos^2 v + b^2 \sin^2 v) + c^2 \sin^2 u & -\frac{\sin(2u)\sin(2v)}{4}(a^2 - b^2) \\ -\frac{\sin(2u)\sin(2v)}{4}(a^2 - b^2) & \sin^2 u \left[ \sin^2 v (a^2 - b^2) + b^2 \right] \end{bmatrix}.$$

Since the ellipsoid is an affine image of the unit sphere, it is affected by the same singularity problem, occurring for *u* = 0 and *u* = *π*.

By setting *a* = 2, *b* = 3, and *c* = 1, the geodesic equations for this ellipsoid are [36],

$$\begin{cases} \begin{aligned} \ddot{u} + \frac{(5\cos^2 v - 32)\cos u \sin u}{\sin^2 u (5\cos^2 v - 32) + 36} \dot{u}^2 - \frac{36 \cos u \sin u}{\sin^2 u (5\cos^2 v - 32) + 36} \dot{v}^2 &= 0 \\ \ddot{v} - \frac{5 \cos v \sin v}{\sin^2 u (5\cos^2 v - 32) + 36} \dot{u}^2 + \frac{2 \cos u}{\sin u} \dot{u} \dot{v} - \frac{5 \sin^2 u \cos v \sin v}{\sin^2 u (5\cos^2 v - 32) + 36} \dot{v}^2 &= 0 \end{aligned} \end{cases}$$

To solve these differential equations using nonlinear least-squares, the following partials must be evaluated to compute the Jacobian of the system,

$$\begin{cases} \frac{\partial \mathcal{L}\_u}{\partial \mathcal{L}\_u} = \frac{\partial \mathcal{L}\_u}{\partial u} \cdot \frac{\text{d}\underline{u}}{\text{d}\underline{\mathcal{L}}\_u} + \frac{\partial \mathcal{L}\_u}{\partial \dot{u}} \cdot \frac{\text{d}\dot{u}}{\text{d}\underline{\mathcal{L}}\_u} + \frac{\partial \mathcal{L}\_u}{\partial \ddot{u}} \cdot \frac{\text{d}\ddot{u}}{\text{d}\underline{\mathcal{L}}\_u} \\ \frac{\partial \mathcal{L}\_u}{\partial \dot{\mathcal{L}}\_v} = \frac{\partial \mathcal{L}\_u}{\partial v} \cdot \frac{\text{d}\underline{v}}{\text{d}\underline{\mathcal{L}}\_v} + \frac{\partial \mathcal{L}\_u}{\partial \dot{v}} \cdot \frac{\text{d}\dot{v}}{\text{d}\underline{\mathcal{L}}\_v} \\ \frac{\partial \mathcal{L}\_v}{\partial \dot{\mathcal{L}}\_u} = \frac{\partial \mathcal{L}\_v}{\partial u} \cdot \frac{\text{d}\underline{u}}{\text{d}\underline{\mathcal{L}}\_u} + \frac{\partial \mathcal{L}\_v}{\partial \dot{u}} \cdot \frac{\text{d}\dot{u}}{\text{d}\underline{\mathcal{L}}\_u} \\ \frac{\partial \mathcal{L}\_v}{\partial \dot{\mathcal{L}}\_v} = \frac{\partial \mathcal{L}\_v}{\partial v} \cdot \frac{\text{d}\underline{v}}{\text{d}\underline{\mathcal{L}}\_v} + \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} \cdot \frac{\text{d}\dot{v}}{\text{d}\underline{\mathcal{L}}\_v} + \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} \cdot \frac{\text{d}\dot{v}}{\text{d}\underline{\mathcal{L}}\_v} \end{cases} (15)$$

Figure 3 shows the numerical results using 40 basis functions (Legendre orthogonal polynomials) to describe the free functions and 200 discretization points. This test validates the approach in terms of fast convergence (just six iterations using a noisy initial guess) and in terms of finding constant the parametric velocity.

The geodetic velocity on a generic triaxial ellipsoid has components,

$$\dot{p} = \begin{cases} a(\dot{u}\cos\iota\cos\upsilon - \dot{\upsilon}\sin\iota\sin\upsilon) \\ b(\dot{u}\cos\iota\sin\upsilon + \dot{\upsilon}\sin\iota\cos\upsilon) \\ -c\dot{\iota}\sin\iota \end{cases} \right> $$

#### *5.2. Elliptic Paraboloid*

For the elliptic paraboloid, the geodesic equations and the TFC solution procedure are provided. The parametric equations of the elliptic paraboloid, *z* = *x*<sup>2</sup> + *y*2, can be described by the vector,

$$p^\top = \begin{Bmatrix} u, & v, & u^2 + v^2 \end{Bmatrix}$$

where *u* ∈ [*u*min, *u*max] and *v* ∈ [*v*min, *v*max]. The partials of the generic point, *p*, are

$$\frac{\partial p}{\partial u} = p\_{\mathbb{II}} = \begin{Bmatrix} 1 \\ 0 \\ 2u \end{Bmatrix} \quad \text{and} \quad \frac{\partial p}{\partial v} = p\_{\mathbb{U}} = \begin{Bmatrix} 0 \\ 1 \\ 2v \end{Bmatrix}$$

from which the metric tensor,

$$\begin{aligned} \prescript{}{}{g}\_{ij} &= \begin{bmatrix} p\_{\mu}^{\top} p\_{\mu} & p\_{\mu}^{\top} p\_{\upsilon} \\ p\_{\upsilon}^{\top} p\_{\mu} & p\_{\upsilon}^{\top} p\_{\upsilon} \end{bmatrix} = \begin{bmatrix} 1 + 4\mu^2 & 4\mu\upsilon \\ 4\iota\upsilon & 1 + 4\upsilon^2 \end{bmatrix} \end{aligned}$$

and its inverse,

$$\mathbf{g}^{ij} = \left(\mathbf{g}\_{ij}\right)^{-1} = \frac{1}{4(\mu^2 + v^2) + 1} \begin{bmatrix} 1 + 4v^2 & -4uv \\ -4uv & 1 + 4u^2 \end{bmatrix}$$

are derived. The non-null Christoffel symbols are derived using Equation (4),

$$\begin{aligned} \Gamma^1\_{11} &= \frac{4\,\,u}{4(u^2+v^2)+1}, \qquad \Gamma^1\_{22} = \frac{4\,\,u}{4(u^2+v^2)+1},\\ \Gamma^2\_{11} &= \frac{4\,\,v}{4(u^2+v^2)+1}, \qquad \text{and} \qquad \Gamma^2\_{22} = \frac{4\,\,v}{4(u^2+v^2)+1}. \end{aligned}$$

The geodesic equations, given in Equation (3), become

$$\begin{cases} \ddot{\boldsymbol{u}} + \Gamma^1\_{11} \dot{\boldsymbol{u}}^2 + \Gamma^1\_{22} \dot{\boldsymbol{v}}^2 = 0 \\\\ \ddot{\boldsymbol{v}} + \Gamma^2\_{11} \dot{\boldsymbol{u}}^2 + \Gamma^2\_{22} \dot{\boldsymbol{v}}^2 = 0 \end{cases}$$

After substituting the Christoffel symbols and rearranging the equations, the geodesic equations for the elliptic paraboloid become,

$$\begin{cases} \mathcal{L}\_u = (4u^2 + 4v^2 + 1)\ddot{u} + 4u\,\dot{u}^2 + 4u\,\dot{v}^2 = 0\\ \mathcal{L}\_v = (4u^2 + 4v^2 + 1)\ddot{v} + 4v\,\dot{u}^2 + 4v\,\dot{v}^2 = 0 \end{cases} \tag{16}$$

**Figure 3.** Numerical validation test on triaxial ellipsoid.

To solve these differential equations using nonlinear least-squares, the same structure of partials provided in Equation (15) must be evaluated to compute the Jacobian of the system, where

$$\begin{cases} \frac{\partial \mathcal{L}\_u}{\partial u} = 8u\vec{u}i + 4(\dot{u}^2 + \dot{v}^2), & \frac{\partial \mathcal{L}\_u}{\partial \dot{u}} = 8u\dot{u}, \quad \frac{\partial \mathcal{L}\_u}{\partial \dot{u}} = \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} = 4(u^2 + v^2) + 1, \\\frac{\partial \mathcal{L}\_u}{\partial v} = 8u\dot{v}, & \frac{\partial \mathcal{L}\_v}{\partial u} = 8u\dot{v}, \quad \frac{\partial \mathcal{L}\_v}{\partial \dot{u}} = 8v\dot{u}, \\\frac{\partial \mathcal{L}\_v}{\partial v} = 8v\dot{v} + 4(\dot{u}^2 + \dot{v}^2), & \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} = 8v\dot{v}, \quad \frac{\partial \mathcal{L}\_u}{\partial v} = 8v\dot{u}, \end{cases}$$

Note that, the elliptic paraboloid can also be expressed by, *<sup>p</sup>* <sup>=</sup> {*<sup>u</sup>* sin *<sup>v</sup>*, *<sup>u</sup>* cos *<sup>v</sup>*, *<sup>u</sup>*2}<sup>T</sup> , where *u* and *v* are angles. In this case, the geodesic equations provided in Equation (16) can be rewritten as,

$$\begin{cases} \mathcal{L}\_{\boldsymbol{u}} = \left(4\boldsymbol{\mu}^{2} + 1\right)\ddot{\boldsymbol{u}} + 4\boldsymbol{\mu}\,\dot{\boldsymbol{u}}^{2} - \boldsymbol{\mu}\,\dot{\boldsymbol{v}}^{2} = 0\\ \mathcal{L}\_{\boldsymbol{v}} = \boldsymbol{\mu}\,\ddot{\boldsymbol{v}} + 2\boldsymbol{\mu}\,\dot{\boldsymbol{v}} = 0 \end{cases}$$

and the following partials must be computed to solve the boundary value problem,

$$\begin{aligned} \frac{\partial \mathcal{L}\_{u}}{\partial \mathcal{L}\_{u}} &= \frac{\partial \mathcal{L}\_{u}}{\partial u} \cdot \frac{\mathrm{d}u}{\mathrm{d}\mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{u}}{\partial \dot{u}} \cdot \frac{\mathrm{d}\dot{u}}{\mathrm{d}\mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{u}}{\partial \dot{u}} \cdot \frac{\mathrm{d}\ddot{u}}{\mathrm{d}\mathcal{L}\_{u}}\\ \frac{\partial \mathcal{L}\_{u}}{\partial \mathcal{L}\_{v}} &= \frac{\partial \mathcal{L}\_{u}}{\partial \dot{v}} \cdot \frac{\mathrm{d}\dot{v}}{\mathrm{d}\mathcal{L}\_{v}}\\ \frac{\partial \mathcal{L}\_{v}}{\partial \mathcal{L}\_{u}} &= \frac{\partial \mathcal{L}\_{v}}{\partial u} \cdot \frac{\mathrm{d}u}{\mathrm{d}\mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{v}}{\partial \dot{u}} \cdot \frac{\mathrm{d}\dot{u}}{\mathrm{d}\mathcal{L}\_{u}}\\ \frac{\partial \mathcal{L}\_{v}}{\partial \mathcal{L}\_{v}} &= \frac{\partial \mathcal{L}\_{v}}{\partial \dot{v}} \cdot \frac{\mathrm{d}\dot{v}}{\mathrm{d}\mathcal{L}\_{v}} + \frac{\partial \mathcal{L}\_{v}}{\partial \dot{v}} \cdot \frac{\mathrm{d}\ddot{v}}{\mathrm{d}\mathcal{L}\_{v}} \end{aligned}$$

where,

$$\begin{cases} \frac{\partial \mathcal{L}\_u}{\partial u} = 8u\ddot{u} + 4\dot{u}^2 - \dot{v}^2, & \frac{\partial \mathcal{L}\_u}{\partial \dot{u}} = 8u\dot{u}, \quad \frac{\partial \mathcal{L}\_u}{\partial \ddot{u}} = 4u^2 + 1, \quad \frac{\partial \mathcal{L}\_u}{\partial \dot{v}} = -2u\dot{v}, \\\frac{\partial \mathcal{L}\_v}{\partial u} = \ddot{v}, & \frac{\partial \mathcal{L}\_v}{\partial \dot{u}} = 2\dot{v}, \quad \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} = 2\dot{u}, \quad \frac{\partial \mathcal{L}\_v}{\partial \dot{v}} = u, \end{cases}$$

and,

$$\begin{aligned} \frac{\partial \boldsymbol{u}}{\partial \xi\_{\boldsymbol{u}}} &= \frac{\partial \boldsymbol{v}}{\partial \xi\_{\boldsymbol{v}}} = \boldsymbol{h} - \frac{1-t}{2} \boldsymbol{h}\_{0} - \frac{t+1}{2} \boldsymbol{h}\_{f'},\\ \frac{\partial \dot{\boldsymbol{u}}}{\partial \xi\_{\boldsymbol{u}}} &= \frac{\partial \dot{\boldsymbol{v}}}{\partial \xi\_{\boldsymbol{v}}} = \dot{\boldsymbol{h}} + \frac{1}{2} \boldsymbol{h}\_{0} - \frac{1}{2} \boldsymbol{h}\_{f'},\\ \frac{\partial \ddot{\boldsymbol{u}}}{\partial \xi\_{\boldsymbol{u}}} &= \frac{\partial \ddot{\boldsymbol{v}}}{\partial \xi\_{\boldsymbol{v}}} = \ddot{\boldsymbol{h}}, \end{aligned}$$

This second parametrization of the elliptic paraboloid is provided because a particular attention must be given to the boundary value of angles to avoid discontinuous angle evolution. For example, if the absolute difference between the two angles is |*v*<sup>0</sup> − *vf* | > *π*, then the value of the smallest of these two angles is increased by 2*π*. This avoids the discontinuity at *v* = 0 while unchanging the problem. For instance, if *v*<sup>0</sup> = 3*π*/2 and *vf* = *π*/4, then the value of *vf* is set as *vf* = *π*/4 + 2*π* = 9*π*/4.

Geodesic (Parametric) Velocity on an Elliptic Paraboloid

The derivative of the position vector is,

$$
\dot{p}^\dagger = \begin{Bmatrix} \dot{p}\_{x\prime} & \dot{p}\_{y\prime} & \dot{p}\_z \end{Bmatrix} = \begin{Bmatrix} \dot{u}\_{\prime} & \dot{v}\_{\prime} & 2u\dot{u} + 2v\dot{v} \end{Bmatrix},
$$

Therefore, the velocity is provided by,

$$
\dot{p}(t) = \sqrt{\dot{u}^2 + u^2 + 4\left(u\dot{u} + v\dot{v}\right)^2}
$$

Since the velocity on a geodesic is constant, then the (instantaneous) value *p*˙(*t*) for a geodesic is not a function of *t* and, therefore, the expression of *p*˙(*t*) must coincide with the average value of the velocity which, in turn, can be computed using Equation (2),

$$\bar{p} = \frac{L}{t\_f - t\_0} = \frac{1}{t\_f - t\_0} \int\_{t\_0}^{t\_f} \sqrt{\left(v^2 + 1\right)\dot{u}^2 + 2uv\dot{u}\dot{v} + \left(u^2 + 1\right)\dot{v}^2} \,\mathrm{d}t$$

therefore, for a geodesic trajectory on the elliptic paraboloid, we have a closed form expression for the integral,

$$\int\_{t\_0}^{t\_f} \sqrt{(v^2+1)\dot{u}^2 + 2uv\dot{u}\dot{v} + \left(u^2+1\right)\dot{v}^2} \,\mathrm{d}t = \left(t\_f - t\_0\right)\sqrt{\dot{u}^2 + u^2 + 4(u\dot{u} + v\dot{v})} \,\mathrm{d}t$$

#### *5.3. Elliptic Hyperboloid*

The parametric description of the elliptic hyperboloid is,

*p*<sup>T</sup> = \$ *a* sinh *u* cos *v*, *b* sinh *u* sin *v*, *c* cosh *u* %

and his covariant metric tensor is,

$$\mathcal{G}\_{\vec{\mathcal{V}}} = \begin{bmatrix} \cosh^2 u (a^2 \cos^2 v + b^2 \sin^2 v) + c^2 \sinh^2 u & -\sinh(2u)\sin(2v)\frac{a^2 - b^2}{4} \\ -\sinh(2u)\sin(2v)\frac{a^2 - b^2}{4} & \sinh^2 u ((a^2 - b^2)\sin^2 v + b^2) \end{bmatrix}$$

By setting *a* = 1, *b* = 2, and *c* = 3, the geodesic equations are,

$$\begin{aligned} \ddot{u} + \frac{\cosh u \; \sinh u \left(13 + 27 \cos^2 v\right)}{27 \cosh^2 u \; \cos^2 v + 13 \cosh^2 u - 9 - 27 \cos^2 v} \dot{u}^2 + \\ \frac{4 \cosh u \; \sinh u}{27 \cosh^2 u \; \cos^2 v + 13 \cosh^2 u - 9 - 27 \cos^2 v} \dot{v}^2 &= 0 \\ \ddot{v} - \frac{27 \cos v \; \sin v}{27 \cosh^2 u \; \cos^2 v + 13 \cosh^2 u - 9 - 27 \cos^2 v} \dot{u}^2 + \\ + \frac{2 \cosh u}{\sinh u} \dot{u} \; \dot{v} - \frac{27 \cos v \; \sin v \left(\cosh^2 u - 1\right)}{27 \cosh^2 u \; \cos^2 v + 13 \cosh^2 u - 9 - 27 \cos^2 v} \dot{v}^2 &= 0 \end{aligned}$$

The geodesic velocity components on the elliptic hyperboloid are,

$$\begin{cases} \dot{p}\_{\mathcal{X}} = a \left( \dot{u} \cosh u \cos v - \dot{v} \sinh u \sin v \right) \\ \dot{p}\_{\mathcal{Y}} = b \left( \dot{u} \cosh u \sin v + \dot{v} \sinh u \cos v \right) \\ \dot{p}\_{\mathcal{z}} = c \dot{u} \sinh u \end{cases}$$

Figure 4 provides detailed information of the test results using 40 basis functions (for the free functions) and 300 points discretization. In this case, a very noisy initial guess is selected (black trajectory on the left/top figure), instead of the simple, *ξ*<sup>0</sup> = **0**. The right/top figure shows, for subsequent iterations, the *L*<sup>2</sup> norm of the error. The procedure entered into the convergence phase after about 35 iterations. The convergence loop pushed the accuracy to the limit, when *L*<sup>2</sup> Δ*ξk*+<sup>1</sup> > *L*<sup>2</sup> Δ*ξ<sup>k</sup>* occurred. The final solution residuals are shown in the left/bottom figure, while the central/bottom figure shows the initial and final solutions for *u*(*t*) and *v*(*t*). Finally, the right/bottom figure gives the parametric velocity of the initial guess (black) and of the final (red) solution (geodesic trajectory). This validates the parametric velocity with a constant value. For this example, no local minima were ever experienced (convex problem).

**Figure 4.** Elliptic paraboloid test results.

#### *5.4. Hyperbolic Paraboloid*

The parametric description of the hyperbolic paraboloid is,

$$p^\tau = \begin{Bmatrix} u, & v, & u \, v \end{Bmatrix}$$

the covariant metric tensor for the hyperbolic paraboloid is

$$g\_{ij} = \begin{bmatrix} v^2 + 1 & uv \\ uv & u^2 + 1 \end{bmatrix}$$

and the Christoffel symbols are, Γ<sup>2</sup> <sup>11</sup> <sup>=</sup> *<sup>v</sup> u*<sup>2</sup> + *v*<sup>2</sup> + 1 , Γ<sup>1</sup> <sup>12</sup> <sup>=</sup> *<sup>v</sup> u*<sup>2</sup> + *v*<sup>2</sup> + 1 , Γ<sup>2</sup> <sup>21</sup> <sup>=</sup> *<sup>u</sup> u*<sup>2</sup> + *v*<sup>2</sup> + 1 , and Γ<sup>1</sup> <sup>22</sup> <sup>=</sup> *<sup>u</sup> u*<sup>2</sup> + *v*<sup>2</sup> + 1 , while the geodesic equations are,

$$\begin{cases} \mathcal{L}\_{\tt t} = \left(1 + \mu^2 + \upsilon^2\right)\vec{u} + 2\upsilon\,\vec{u}\,\vec{\nu} = 0\\ \mathcal{L}\_{\vec{v}} = \left(1 + \mu^2 + \upsilon^2\right)\vec{v} + 2\mu\,\vec{u}\,\vec{\nu} = 0 \end{cases}$$

The expression of the geodesic velocity on hyperbolic paraboloid is,

$$
\dot{p}^2 = \dot{u}^2 + \dot{v}^2 + (v\dot{u} + u\dot{v})^2.
$$

Figure 5 contains the results obtained on hyperbolic paraboloid (same meaning than those provided for the elliptic paraboloid), while Table 1 shows the *L*<sup>2</sup> norm of the error step, *L*<sup>2</sup> Δ*ξ<sup>k</sup>* , and the associated *L*<sup>2</sup> norm of the differential equations residuals, *L*<sup>2</sup> *rk* , for the first 8 iterations.


**Table 1.** First eight iterations for the hyperbolic paraboloid.

**Figure 5.** Hyperbolic paraboloid test results.

#### *5.5. Generic Surface*

Let us consider the surface identified by,

$$p^\tau = \begin{Bmatrix} \mu\_\prime & \upsilon\_\prime & \mu \cos \upsilon - \upsilon \sin \mu \end{Bmatrix}$$

in the range *u*, *v* ∈ [−5, +5]. By setting, *α* = sin *u* + *u* sin *v* and *β* = cos *v* − *v* cos *u*, the metric tensor and its inverse for this surface are,

$$g\_{i\bar{j}} = \begin{bmatrix} \beta^2 + 1 & -a\beta \\ -a\beta & a^2 + 1 \end{bmatrix} \quad \text{and} \quad g^{i\bar{j}} = \frac{1}{a^2 + \beta^2 + 1} \begin{bmatrix} a^2 + 1 & a\beta \\ a\beta & \beta^2 + 1 \end{bmatrix}$$

and the nonzero Christoffel symbols are,

$$\begin{aligned} \Gamma^1\_{11} &= \frac{v \sin u}{a^2 + \beta^2 + 1} \beta, \quad \Gamma^1\_{12} = \Gamma^1\_{21} = -\frac{\cos u + \sin v}{a^2 + \beta^2 + 1} \beta, \quad \Gamma^1\_{22} = -\frac{u \cos v}{a^2 + \beta^2 + 1} \beta, \\\Gamma^2\_{11} &= -\frac{v \sin u}{a^2 + \beta^2 + 1} a, \quad \Gamma^2\_{12} = \Gamma^2\_{21} = \frac{\cos u + \sin v}{a^2 + \beta^2 + 1} a, \quad \Gamma^2\_{22} = \frac{u \cos v}{a^2 + \beta^2 + 1} a \end{aligned}$$

The geodesic equations can be written in the compact form,

$$\begin{cases} \mathcal{L}\_u = p \not\equiv \not\equiv 0\\ \mathcal{L}\_v = p \not\equiv -a \not\equiv 0 \end{cases}$$

where,

$$p = a^2 + \beta^2 + 1 \quad \text{and} \quad q = (v\sin u)\dot{u}^2 - 2(\cos u + \sin v)\dot{u}\dot{v} - (u\cos v)\dot{v}^2$$

The partials forming the Jacobian matrix in the least-squares process are,

$$\begin{split} \frac{\partial\mathcal{L}\_{u}}{\partial\xi\_{u}} &= \dot{u}\frac{\partial p}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} + p\frac{\partial\ddot{u}}{\partial\xi\_{u}} + \beta\left(\frac{\partial q}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} + \frac{\partial q}{\partial\dot{u}}\cdot\frac{\partial\ddot{u}}{\partial\xi\_{x}}\right) + q\frac{\partial\beta}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} \\ \frac{\partial\mathcal{L}\_{u}}{\partial\xi\_{v}} &= \dot{u}\frac{\partial p}{\partial v}\cdot\frac{\partial v}{\partial\xi\_{v}} + \beta\left(\frac{\partial q}{\partial v}\cdot\frac{\partial v}{\partial\xi\_{v}} + \frac{\partial q}{\partial\dot{v}}\cdot\frac{\partial\dot{v}}{\partial\xi\_{v}}\right) + q\frac{\partial\beta}{\partial v}\cdot\frac{\partial v}{\partial\xi\_{v}} \\ \frac{\partial\mathcal{L}\_{v}}{\partial\xi\_{u}} &= \dot{v}\frac{\partial p}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} - \kappa\left(\frac{\partial q}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} + \frac{\partial q}{\partial\dot{u}}\cdot\frac{\partial\dot{u}}{\partial\xi\_{u}}\right) - q\frac{\partial\alpha}{\partial u}\cdot\frac{\partial u}{\partial\xi\_{u}} \\ \frac{\partial\mathcal{L}\_{v}}{\partial\xi\_{v}} &= \dot{v}\frac{\partial p}{\partial v}\cdot\frac{\partial v}{\partial\xi\_{v}} + p\frac{\partial\overline{v}}{\partial\xi\_{v}} - \kappa\left(\frac{\partial q}{\partial v}\cdot\frac{\partial v}{\partial\xi\_{v}} + \frac{\partial q}{\partial\dot{v}}\cdot\frac{\partial\dot{v}}{\partial\$$

where,

$$\frac{\partial u}{\partial u} = \cos u + \sin v, \quad \frac{\partial u}{\partial v} = u \cos v, \quad \frac{\partial \beta}{\partial u} = v \sin u, \quad \text{and} \quad \frac{\partial \beta}{\partial v} = -\sin v - \cos \nu$$

and,

$$\frac{\partial p}{\partial u} = 2\alpha \frac{\partial \alpha}{\partial u} + 2\beta \frac{\partial \beta}{\partial u} \quad \text{and} \quad \frac{\partial p}{\partial v} = 2\beta \frac{\partial \beta}{\partial v} + 2\alpha \frac{\partial \alpha}{\partial v}$$

and,

$$\begin{aligned} \frac{\partial q}{\partial u} &= (v \cos u) \dot{u}^2 + 2(\sin u) \dot{u} \dot{v} - (\cos v) \dot{v}^2 \\ \frac{\partial q}{\partial v} &= (\sin u) \dot{u}^2 - 2(\cos v) \dot{u} \dot{v} + (u \sin v) \dot{v}^2 \\ \frac{\partial q}{\partial \dot{u}} &= 2(v \sin u) \dot{u} - 2(\cos u + \sin v) \dot{v} \\ \frac{\partial q}{\partial \dot{v}} &= -2(\cos u + \sin v) \dot{u} - 2(u \cos v) \dot{v} \end{aligned}$$

Figure 6 gives the results obtained for this specific generic surface. The convergence is obtained in just 8 iterations, using 30 basis functions for the free functions and a 300 point discretization. The constancy of the parametric velocity is an alternative way validating the solution as a geodesic trajectory.

**Figure 6.** Surface *p*<sup>T</sup> = 7 *u*, *v*, *u* cos *v* − *v* sin *u* 8 test results.

#### *5.6. One-Sheeted Hyperboloid*

This surface is described by the parametric vector,

$$p^\tau(\mu, v) = \left\{ \sqrt{1 + \mu^2} \cos v, \quad \sqrt{1 + \mu^2} \sin v, \quad 2\mu \right\}.$$

The covariant and the contravariant associated metric tensors are,

$$\mathbf{g}\_{ij} = \begin{bmatrix} 5\,\mu^2 + 4 & 0\\ \frac{\mu^2 + 1}{\mu^2 + 1} & 0\\ 0 & \mu^2 + 1 \end{bmatrix} \quad \text{and} \quad \mathbf{g}^{ij} = \begin{bmatrix} \frac{\mu^2 + 1}{5\,\mu^2 + 4} & 0\\ \frac{\mu^2 + 4}{\mu^2 + 1} & 1\\ 0 & \frac{1}{\mu^2 + 1} \end{bmatrix}$$

and the nonzero Christoffel symbols are,

$$\Gamma^1\_{11} = \frac{u}{(5u^2 + 4)(u^2 + 1)}, \quad \Gamma^1\_{22} = -\frac{u\left(u^2 + 1\right)}{5u^2 + 4}, \quad \text{and} \quad \Gamma^2\_{12} = \Gamma^2\_{21} = \frac{u}{u^2 + 1}$$

This implies the geodesic equations for one-sheeted hyperboloid,

$$\begin{cases} \mathcal{L}\_{\boldsymbol{u}} = \left(5\boldsymbol{u}^{2} + 4\right)\ddot{\boldsymbol{u}} + \frac{\boldsymbol{u}}{\boldsymbol{u}^{2} + 1}\dot{\boldsymbol{u}}^{2} - \boldsymbol{u}\left(\boldsymbol{u}^{2} + 1\right)\dot{\boldsymbol{v}}^{2} = 0\\ \mathcal{L}\_{\boldsymbol{v}} = \left(\boldsymbol{u}^{2} + 1\right)\ddot{\boldsymbol{v}} + 2\boldsymbol{u}\ \dot{\boldsymbol{v}} = 0 \end{cases}$$

To apply the nonlinear least-squares, the following partials must be computed,

$$\begin{split} \frac{\partial \mathcal{L}\_{u}}{\partial \mathcal{L}\_{u}} &= \frac{\partial \mathcal{L}\_{u}}{\partial \dot{u}} \cdot \frac{\partial \dot{u}}{\partial \mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{u}}{\partial \dot{u}} \cdot \frac{\partial \dot{u}}{\partial \mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{u}}{\partial u} \cdot \frac{\partial u}{\partial \mathcal{L}\_{u}} \\ \frac{\partial \mathcal{L}\_{u}}{\partial \mathcal{L}\_{v}} &= \frac{\partial \mathcal{L}\_{u}}{\partial \dot{v}} \cdot \frac{\partial \dot{v}}{\partial \mathcal{L}\_{v}} \\ \frac{\partial \mathcal{L}\_{v}}{\partial \mathcal{L}\_{u}} &= \frac{\partial \mathcal{L}\_{v}}{\partial \dot{u}} \cdot \frac{\partial \dot{u}}{\partial \mathcal{L}\_{u}} + \frac{\partial \mathcal{L}\_{v}}{\partial u} \cdot \frac{\partial u}{\partial \mathcal{L}\_{u}} \\ \frac{\partial \mathcal{L}\_{v}}{\partial \mathcal{L}\_{v}} &= \frac{\partial \mathcal{L}\_{v}}{\partial \dot{v}} \cdot \frac{\partial \dot{v}}{\partial \mathcal{L}\_{v}} + \frac{\partial \mathcal{L}\_{v}}{\partial \dot{v}} \cdot \frac{\partial \dot{v}}{\partial \mathcal{L}\_{v}} \end{split}$$

The expressions of these partials are,

$$\begin{aligned} \frac{\partial \mathcal{L}\_u}{\partial \vec{u}} &= 5u^2 + 4 & \frac{\partial \mathcal{L}\_u}{\partial \vec{u}} &= \frac{2u}{u^2 + 1}\dot{u} \\ \frac{\partial \mathcal{L}\_u}{\partial u} &= 10u^2 \ddot{u} + \frac{1 - u^2}{(u^2 + 1)^2}\dot{u}^2 - \left(3u^2 + 1\right)\dot{v}^2 & \frac{\partial \mathcal{L}\_u}{\partial \vec{v}} &= -2u\left(u^2 + 1\right)\dot{v} \\ \frac{\partial \mathcal{L}\_v}{\partial \vec{v}} &= u^2 + 1 & \frac{\partial \mathcal{L}\_v}{\partial \vec{v}} &= 2u\,\dot{u} \\ \frac{\partial \mathcal{L}\_v}{\partial \vec{u}} &= 2u\,\dot{v} & \frac{\partial \mathcal{L}\_v}{\partial u} &= 2u\,\vec{v} + 2\dot{u}\,\dot{v} \end{aligned}$$

The parametric velocity is given by

$$
\dot{p}^2 = \frac{\mu^2 \dot{u}^2}{1 + \mu^2} + 4\dot{u}^2 + (1 + \mu^2)\dot{v}.^2
$$

The results of the test conducted on the one-sheeted hyperboloid are reported in Figure 7 where the sub-figures provide full information of the least-squares process. The free functions were expanded by 40 basis functions (Legendre orthogonal polynomials) and the discretization was conducted by 300 points.

**Figure 7.** One-sheeted hyperboloid test results.

#### *5.7. Torus*

The implicit and parametric equation of the torus are,

*p*<sup>T</sup> = \$ (*R* + *r* cos *u*) cos *v*, (*R* + *r* cos *u*) sin *v*, *r* sin *u* %

where *R* and *r* are the two torus radii. The covariant metric tensor for the torus is,

$$\mathbf{g}\_{ij} = \begin{bmatrix} r^2 & 0\\ 0 & (R + r \cos \mu)^2 \end{bmatrix}$$

while the geodesic equations are,

$$\begin{cases} \mathcal{L}\_u = r \ddot{u} + \dot{v}^2 \left( R + r \cos u \right) \sin u = 0 \\ \mathcal{L}\_v = (R + r \cos u)\vec{v} - 2i \dot{v} \, r \sin u = 0 \end{cases}$$

The partials needed to populate the Jacobian are,

$$\begin{split} \frac{\partial \mathcal{L}\_{u}}{\partial \xi\_{u}} &= r \frac{\partial \bar{u}}{\partial \xi\_{u}} + \bar{\upsilon}^{2} \left[ (R + r \cos u) \cos u - r \sin^{2} u \right] \frac{\partial u}{\partial \xi\_{u}} \\ \frac{\partial \mathcal{L}\_{u}}{\partial \xi\_{v}} &= 2\bar{\upsilon} \frac{\partial \bar{\upsilon}}{\partial \xi\_{v}} (R + r \cos u) \sin u \\ \frac{\partial \mathcal{L}\_{v}}{\partial \xi\_{u}} &= - \left[ r \bar{\upsilon} \sin u + 2i \bar{\upsilon} \, r \cos u \right] \frac{\partial u}{\partial \xi\_{u}} - 2 \frac{\partial \bar{u}}{\partial \xi\_{u}} \bar{\upsilon} \, r \sin u \\ \frac{\partial \mathcal{L}\_{v}}{\partial \xi\_{v}} &= \left( R + r \cos u \right) \frac{\partial \bar{\upsilon}}{\partial \xi\_{v}} - 2i \frac{\partial \bar{\upsilon}}{\partial \xi\_{v}} \, r \sin u \end{split}$$

and the nonlinear least-squares can be performed using Equation (13). The geodetic parametric velocity on the torus is,

$$
\dot{v}^2 = r^2 \dot{u}^2 + (R + r \cos u)^2 \dot{v}^2
$$

The sub-figures given in Figure 8 show the details of the least-squares process to estimate the geodesic trajectory on the torus surface. The number of basis functions were 40 and the number of discretization points were 300. The constancy of the velocity as well as the machine-level *L*<sup>2</sup> norm of the differential equations residuals validate the estimated geodesic trajectory (in red).

**Figure 8.** Torus: test results.

#### *5.8. Moëbius Strip*

The last test of the proposed least-squares approach is performed on the Moëbius strip, which can be described by,

$$p^\tau = \left\{ \left[ 2 - \iota \sin\left(\frac{\upsilon}{2}\right) \right] \cos(\upsilon), \quad \left[ 2 - \iota \sin\left(\frac{\upsilon}{2}\right) \right] \sin(\upsilon), \quad \iota \cos\left(\frac{\upsilon}{2}\right) \right\}.$$

where *u* ∈ [−1, +1] and *v* ∈ [0, 2*π*). The metric tensor and its inverse for this surface can be given in a compact form by setting, *<sup>d</sup>*(*u*, *<sup>v</sup>*) = <sup>4</sup>*<sup>u</sup>* sin*v* 2 *<sup>u</sup>* sin*v* 2 − 4 + *u*<sup>2</sup> + 16,

$$\mathcal{g}\_{ij} = \begin{bmatrix} 1 & 0 \\ 0 & \frac{d(\mu, \upsilon)}{4} \end{bmatrix} \quad \text{and} \quad \mathcal{g}^{ij} = \begin{bmatrix} 1 & 0 \\ 0 & 4 \\ \overline{d(\mu, \upsilon)} \end{bmatrix}.$$

while the nonzero Christoffel symbols are,

$$\begin{aligned} \Gamma\_{22}^1 &= \sin\left(\frac{\upsilon}{2}\right) \left[2 - \mu \sin\left(\frac{\upsilon}{2}\right)\right] - \frac{\mu}{4} \\\Gamma\_{21}^2 &= \Gamma\_{12}^2 = \frac{\mu - 4 \sin\left(\frac{\upsilon}{2}\right) \left[2 - \mu \sin\left(\frac{\upsilon}{2}\right)\right]}{d(\mu, \upsilon)} \\\Gamma\_{22}^2 &= -\frac{2\mu \cos\left(\frac{\upsilon}{2}\right) \left[2 - \mu \sin\left(\frac{\upsilon}{2}\right)\right]}{d(\mu, \upsilon)} \end{aligned}$$

Hence, the geodesic equations of the Moëbius strip are,

$$
\ddot{\boldsymbol{\omega}} + \boldsymbol{\Gamma}\_{22}^1 \dot{\boldsymbol{\upsilon}}^2 = 0 \quad \text{and} \quad \ddot{\boldsymbol{\upsilon}} + 2\boldsymbol{\Gamma}\_{21}^2 \dot{\boldsymbol{\mu}} \dot{\boldsymbol{\upsilon}} + \boldsymbol{\Gamma}\_{22}^2 \dot{\boldsymbol{\upsilon}}^2 = 0
$$

which can be written as,

$$\begin{cases} \ddot{u} + c\_1(u,v)\,\dot{v}^2 = 0 \\\\ d(u,v)\,\dot{v} + c\_2(u,v)\,\dot{u}\,\dot{v} + c\_3(u,v)\,\dot{v}^2 = 0 \end{cases}$$

where

$$\begin{cases} c\_1(\boldsymbol{u}, \boldsymbol{v}) = 2\sin\left(\frac{\boldsymbol{v}}{2}\right) - \boldsymbol{u}\sin^2\left(\frac{\boldsymbol{v}}{2}\right) - \frac{\boldsymbol{u}}{4} \\ c\_2(\boldsymbol{u}, \boldsymbol{v}) = 2\boldsymbol{u} - 16\sin\left(\frac{\boldsymbol{v}}{2}\right) + 8\boldsymbol{u}\sin^2\left(\frac{\boldsymbol{v}}{2}\right) \\ c\_3(\boldsymbol{u}, \boldsymbol{v}) = -4\boldsymbol{u}\cos\left(\frac{\boldsymbol{v}}{2}\right) + 4\boldsymbol{u}^2\sin\boldsymbol{v} \end{cases}$$

Figure 9 provide all information about this last test validation case. Table 2 details the iterative results: the *L*<sup>2</sup> norm of the accuracy gain and the *L*<sup>2</sup> norm of the differential equation at each iteration. The iterative process ended because *L*<sup>2</sup> Δ*ξ*23 > *L*<sup>2</sup> Δ*ξ*22 , due to numerical convergence saturation.

**Figure 9.** Moëbius strip test results.


**Table 2.** Moëbius strip: convergence *L*<sup>2</sup> norms terms used in the least-squares approach.

#### *5.9. Discussions*

In this article, a new general method to numerical solve boundary value geodesic problems in curved surfaces is presented. The approach takes advantage of the ability to derive special functionals, called constrained expressions, which always satisfy assigned boundary conditions. The proposed approach has been validated by performing numerical tests on several two-dimensional surfaces. In theory, this approach can be extended to manifolds in higher Riemannian spaces. This will require more computational capability than that used for this article and, most likely, optimized and compiled code, instead of the MATLAB interpreter adopted.

The problem of finding the geodesic by least-squares introduces the risk of getting stuck on some local minima. A simple algorithm has been developed to mitigate this problem. Thanks to this algorithm, all boundary geodesic problems considered were quickly solved with machine-error level accuracy, which is an acceptable definition of an exact solution by engineers.

This article restricts the research on finding geodesic trajectories on surfaces that are continuous and differentiable. The problem of finding geodesic-type trajectories on discretized surfaces, which is solved by combinatorial/computational algorithms and methods, is not taken here into consideration. The performed tests have the only purpose to validate the least-squares approach. A complete analysis quantifying the responses of this methodology to various surface shapes, boundary conditions (e.g., singular boundary points for the Ellipsoid), as well as comparisons with competing approaches, will be the subject of future studies.

As for future research directions, it should be natural to derive the real velocity (instead of the parametric velocity) in geodesic problems of a mass particle, and to use the constancy of the velocity—in addition to or instead of—the geodesic equations. Another future research activity is to investigate what the optimal range of basis functions for the free functions is and to investigate the optimal number of discretization points. These two analyses will help the proposed least-squares solution approach to provide optimal performances. Topics more interesting in physics, such as using the Schwarzschild metric (uncharged, non-rotating black holes) or more general space metrics are welcome to be investigated by researchers with good knowledge on general relativity.

**Funding:** This research received no external funding.

**Conflicts of Interest:** The author declares no conflict of interest.

#### **Acronyms**

The following abbreviations are used in this manuscript:


#### **References**

