{'fraction_non_alphanumeric': 0.05987119058755802, 'fraction_numerical': 0.013042852516820783, 'mean_word_length': 3.732822477650064, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Second-order constrained variational problems on Lie algebroids: applications to optimal control

The aim of this work is to study, from an intrinsic and geometric point of view, second-order constrained variational problems on Lie algebroids, that is, optimization problems defined by a cost functional which depends on higher-order derivatives of admissible curves on a Lie algebroid. Extending the classical Skinner and Rusk formalism for the mechanics in the context of Lie algebroids, for second-order constrained mechanical systems, we derive the corresponding dynamical equations. We find a symplectic Lie subalgebroid where, under some mild regularity conditions, the second-order constrained variational problem, seen as a presymplectic Hamiltonian system, has a unique solution. We study the relationship of this formalism with the second-order constrained Euler-Poincar\'e and Lagrange-Poincar\'e equations, among others. Our study is applied to the optimal control of mechanical systems.


Introduction
Lie algebroids have deserved a lot of interest in recent years. Since a Lie algebroid is a concept which unifies tangent bundles and Lie algebras, one can suspect their relation with mechanics. More precisely, a Lie algebroid over a manifold Q is a vector bundle τE : E → Q over Q with a Lie algebra structure over the space Γ(τE) of sections of E and an application ρ : E → T Q called anchor map satisfying some compatibility conditions (see [51]). Examples of Lie algebroids are the tangent bundle over a manifold Q where the Lie bracket is the usual Lie bracket of vector fields and the anchor map is the identity function; a real finite dimensional Lie algebras as vector bundles over a point, where the anchor map is the null application; action Lie algebroids of the type pr1 : M × g → M where g is a Lie algebra acting infinitesimally over the manifold M with a Lie bracket over the space of sections induced by the Lie algebra structure and whose anchor map is the action of g over M ; and, the Lie-Atiyah algebroid τ T Q/G : T Q/G → M = Q/G associated with the G-principal bundle p : Q → M where the anchor map is induced by the tangent application of p, T p : T Q → T M [49,51,57,71].
In [71] Alan Weinstein developed a generalized theory of Lagrangian mechanics on Lie algebroids and he obtained the equations of motion using the linear Poisson structure on the dual of the Lie algebroid and the Legendre transformation associated with a regular Lagrangian L : E → R. In [71] also he asked about whether it is possible to develop a formalism similar on Lie algebroids to Klein's formalism [46] in Lagrangian mechanics. This task was obtained by Eduardo Martínez in [57]( see also [56]). The main notion is that of prolongation of a Lie algebroid over a mapping introduced by Higgins and Mackenzie in [51]. A more general situation, the prolongation of an anchored bundle τE : E → Q was also considered by Popescu in [65,66].
The importance of Lie algebroids in mathematics is beyond doubt and in the last years Lie algebroids has been a lot of applications in theoretical physics and other related sciences. More concretely in Classical Mechanics, Classical Field Theory and their applications. One of the main characteristic concerning that Lie algebroids are interesting in Classical Mechanics lie in the fact that there are many different situations that can be understand in a general framework using the theory of Lie algebroids as systems with symmetries, systems over semidirect products, Hamiltonian and Lagrangian systems, systems with constraints (nonholonomic and vakonomic) and Classical Fields theory [1,14,15,10,16,25,26,32,47,52,61].
In [49] M. de León, J.C Marrero and E. Martínez have developed a Hamiltonian description for the mechanics on Lie algebroids and they have shown that the dynamics is obtained solving an equation in the same way than in Classical Mechanics (see also [56] and [71]). Moreover, they shown that the Legendre transformation legL : E → E * associated to the Lagrangian L : E → R induces a Lie algebroid morphism and when the Lagrangian is regular both formalisms are equivalent.
Marrero and collaborators also have analyzed the case of non-holonomic mechanics on Lie algebroids [25]. In other direction, in [40] D. Iglesias, J.C. Marrero, D. Martín de Diego and D. Sosa have studied singular Lagrangian systems and vakonomic mechanics from the point of view of Lie algebroids obtained through the application of a constrained variational principle. They have developed a constraint algorithm for presymplectic Lie algebroids generalizing the well know constraint algorithm of Gotay, Nester and Hinds [36,37] and they also have established the Skinner and Rusk formalism on Lie algebroids. Some of the results given are as an extension of this framework for constrained second-order systems.
Our framework is based in the Skinner-Rusk formalism which combines simultaneously some features of the Lagrangian and Hamiltonian classical formalisms. The idea of this formulation was to obtain a common framework for both regular and singular dynamics, obtaining simultaneously the Hamiltonian and Lagrangian formulations of the dynamics. Over the years, however, Skinner and Rusk's framework was extended in many directions: It was originally developed for first-order autonomous mechanical systems [70], and later generalized to non-autonomous dynamical systems [2,24,68], control systems [4] and, more recently to classical field theories [12,28].
Briefly, in this formulation, one starts with a differentiable manifold Q as the configuration space, and the Whitney sum T Q ⊕ T * Q as the evolution space (with canonical projections π1 : T Q ⊕ T * Q −→ T Q and π2 : T Q ⊕ T * Q −→ T * Q). Define on T Q ⊕ T * Q the presymplectic 2-form Ω = π * 2 ωQ, where ωQ is the canonical symplectic form on T * Q, and observe that the rank of this presymplectic form is everywhere equal to 2n. If the dynamical system under consideration admits a Lagrangian description, with Lagrangian L ∈ C ∞ (T Q), then one can obtain a (presymplectic)-Hamiltonian representation on T Q ⊕ T * Q given by the presymplectic 2-form Ω and the Hamiltonian function H = π1, π2 − π * 1 L , where ·, · denotes the natural pairing between vectors and covectors on Q. In this Hamiltonian system the dynamics is given by vector fields X, which are solutions to the Hamiltonian equation iX Ω = dH. If L is regular, then there exists a unique vector field X solution to the previous equation, which is tangent to the graph of the Legendre map. In the singular case, it is necessary to develop a constraint algorithm in order to find a submanifold (if it exists) where there exists a well-defined dynamical vector field.
Recently, higher-order variational problems have been studied for their important applications in aeronautics, robotics, computer-aided design, air traffic control, trajectory planning, and in general, problems of interpolation and approximation of curves on Riemannian manifolds [6,11,39,45,50,62,60,63]. There are variational principles which involves higher-order derivatives by Gay Balmaz et.al., [29,30,31], (see also [48]) since from it one can obtain the equations of motion for Lagrangians where the configuration space is a higher-order tangent bundle. More recently, there have been an interest in study of the geometrical structures associated with higher order variational problems with the aim of a deepest understanding of those geometric sructures [20,23,67,58,42,43,44] as well the relation of higher-order mechanics and graded bundles, [8,9,10].
In this work, we study a geometric framework, based on the Skinner and Rusk formalism, for constrained second-order variational problems determined by a Lagrangian function, playing the role of cost function in an optimal control problem, which depends on derivatives of admissible curves on a Lie algebroid. The strategy is to apply the geometric procedure described above in combination with an extension of the constraint algorithm developed by Gotay, Nester and Hinds [36,37] in the setting of Lie algebroids [40]. Our work permits to obtain constrained second-order Euler-Lagrange equations, Euler-Poincaré, Lagrange-Poincaré equations in an unified framework and understand the geometric structures subjacent in second-order variational problems. We show how this study can be applied to the problem of finding necessary conditions for optimality in optimal control problems of mechanical system with symmetries, where trajectories are parameterized by the admissible controls and the necessary conditions for extremals in the optimal control problem are expressed using a pseudo-Hamiltonian formulation based on the Pontryagin maximun principle.
The paper is organized as follows. In Section 2 we introduce some known notions concerning Lie algebroids that are necessary for further developments in this work. In section 3 we will use the notion of Lie algebroid and prolongation of a Lie algebroid described in 2 to derive the Euler-Lagrange equations and Hamilton equations on Lie algebroids. Next, after introduce the constraint algorithm for presymplectic Lie algebroids and study vakonomic mechanics on Lie algebroids, we study the geometric formalism for second-order constrained variational problems using and adaptation of the classical Skinner-Rusk formalism for the second-order constrained systems on Lie algebroids. In section 4 we study optimal control problems of mechanical systems defined on Lie algebroids. Optimality conditions for the optimal control of the Elroy's Beanie are derived. Several examples show how to apply the techniques along all the work.

Lie algebroids and admissible elements
In this section, we introduce some known notions and develop new concepts concerning Lie algebroids that are necessary for further developments in this work. We illustrate the theory with several examples. We refer the reader to [13,51] for more details about Lie algebroids and their role in differential geometry. (1) The bracket [[·, ·]] satisfies the Jacobi identity, that is, (2) If we also denote by ρ : Γ(τE) → X(M ) the homomorphism of C ∞ (M )-modules induced by the anchor map then We will said that the triple (E, [[·, ·]], ρ) is a Lie algebroid over M . In this context, sections of τE, play the role of vector fields on M , and the sections of the dual bundle τE * : E * → M of 1-forms on M .
We may consider two type of distinguished functions: given f ∈ C ∞ (M ) one may define a functionf on E byf = f • τE, the basic functions. And, given a section θ of the dual bundle τE * : E * → M , may be regarded as a lineal functionθ on E asθ(e) = θ(τE(e)), e for all e ∈ E. In this sense, Γ(τE) is locally generated by the differential of basic and linear functions.
Conversely it is possible to recover the Lie algebroid structure of E from the existence of an exterior differential on Γ(Λ • τE * ). If f : M → R is a real smooth function, one can define the anchor map and the Lie bracket as follows: for all X, Y ∈ Γ(τE) and θ ∈ Γ(τE * ). Moreover, from the last equality, the section θ ∈ Γ(τE * ) is a 1-cocycle if and only if d E θ = 0, or, equivalently, We may also define the Lie derivative with respect to a section X ∈ Γ(τE) as the operator L E X : Γ( k τE * ) → Γ( k τE * ) given by is the A-th coordinate of e ∈ E in the given basis i.e., every e ∈ E is expressed as e = y 1 e1(τE(e)) + . . . + y n en(τE(e)).
Such coordinates determine the local functions ρ i A , C C AB on M which contain the local information of the Lie algebroid structure, and accordingly they are called structure functions of the Lie algebroid. These are given by These functions should satisfy the relations and cyclic(A,B,C) which are usually called the structure equations. , where {e A } is the dual basis of {eA}. If θ ∈ Γ(τE * ) and θ = θC e C it follows that In particular,

Examples of Lie algebroids.
Example 1. Given a finite dimensional real Lie algebra g and M = {m} be a unique point, we consider the vector bundle τg : g → M. The sections of this bundle can be identified with the elements of g and therefore we can consider as the Lie bracket the structure of the Lie algebra induced by g, and denoted by [·, ·]g. Since T M = {0} one may consider the anchor map ρ ≡ 0. The triple (g, [·, ·]g, 0) is a Lie algebroid over a point. Example 3. Let φ : M × G → M be an action of G on the manifold M where G is a Lie group. The induced anti-homomorphism between the Lie algebras g and X(M ) by the action is determined by Φ : g → X(M ), ξ → ξM , where ξM is the infinitesimal generator of the action for ξ ∈ g. The vector bundle τM×g : M × g → M is a Lie algebroid over M . The anchor map ρ : M × g → T M , is defined by ρ(m, ξ) = −ξM (m) and the Lie bracket of sections is given by the Lie algebra structure on Γ(τM×g) as The Lie bracket is defined on the space Γ(τ T M ) which is isomorphic to the Lie subalgebra of G-invariant vector fields, that is,  [17] for example).
We choose a local trivialization of the principal bundle π : M → M to be U × G, where U is an open subset of M . Suppose that e is the identity of G, (x i ) are local coordinates on U and {ξA} is a basis of g.
Denote by { ← − ξA} the corresponding left-invariant vector field on G, that is, for i, j ∈ {1, . . . , m} and x ∈ U, then the horizontal lift of the vector field ∂ ∂x i is the vector field on π −1 (U ) U × G given by Therefore, the vector fields on U × G being {c C AB } the constant structures of g with respect to the basis {ξA} (see [49] for more details). That is, Next, we introduce the notion of Lie subalgebroid associated with a Lie algebroid.
exists as a vector bundle, it will be a Lie subalgebroid of E over N, and will be called Lie algebroid restriction of E to N (see [51]). Example 7. Let g be a Lie algebra and h be a Lie subalgebra. If we consider the Lie algebroid induced by g and h over a point, then h is a Lie subalgebroid of g.
Example 8. Let M × g → M be an action Lie algebroid and let N be a submanifold of M. Let h be a Lie subalgebra of g such that the infinitesimal generators of the elements of h are tangent to N ; that is, the application 2.2. E-tangent bundle to a Lie algebroid E. We consider the prolongation over the canonical projection of the Lie algebroid E over M , that is, where T τE : T E → T M is the tangent map to τE.
In fact, T τ E E is a Lie algebroid of rank 2n over E where τ (1) If we denote by (e, e , ve) an element (e , ve) ∈ T τ E E where e ∈ E and where v is tangent; we rewrite the definition for the prolongation of the Lie algebroid as the subset of E × E × T E by Thus, if (e, e , ve) ∈ T τ E E; then ρ1(e, e , ve) = (e, ve) ∈ TeE, and τ (1) E (e, e , ve) = e ∈ E. Next, we introduce two canonical operations that we have on a Lie algebroid E. The first one is obtained using the Lie algebroid structure of E and the second one is a consequence of E being a vector bundle. On one hand, if f ∈ C ∞ (M ) we will denote by f c the complete lift to E of f defined by f c (e) = ρ(e)(f ) for all e ∈ E. Let X be a section of E then there exists a unique vector field X c on E, the complete lift of X, satisfying the two following conditions: (1) X c is τE-projectable on ρ(X) and (2) X c (α) = L E X α, for every α ∈ Γ(τE * ) (see [33]). Here, if β ∈ Γ(τE * ) thenβ is the linear function on E defined byβ (e) = β(τE(e)), e , for all e ∈ E.
We may introduce the complete lift X c of a section X ∈ Γ(τE) as the sections of τ (1) for all e ∈ E (see [57]). Given a section X ∈ Γ(τE) we define the vertical lift as the vector field X v ∈ X(E) given by X v (e) = X(τE(e)) v e , for e ∈ E, where v e : Eq → TeEq for q = τE(e) is the canonical isomorphism between the vector spaces Eq and TeEq.
Finally we may introduce the vertical lift X v of a section X ∈ Γ(τE) as a section of τ With these definitions we have the properties (see [33] and [57]) for all X, Y ∈ Γ(τE). If A (e) = e, 0, for e ∈ (τE) −1 (U ) with U an open subset of M (see [49] for more details). From this basis we have that the structure of Lie algebroid is determined by A (e)) = e, A , e A , e for all A, B and C; where C C AB are the structure functions of E determined by the Lie bracket [[·, ·]] with respect to the basis {eA}.
Using {e A } one may introduce local coordinates ( therefore the expression of V in terms of the basis {e A and the vector field ρ1(V ) ∈ X(E) has the expression .
A }, Example 10. In the case of E = T M one may identify T τ E E with T T M with the standard Lie algebroid structure over T M .
Example 11. Let g be a real Lie algebra of finite dimension. g is a Lie algebroid over a single point M = {q}. The anchor map of g is zero constant function, and from the anchor map we deduce that The vector bundle projection τ Let {eA} be a basis of the Lie algebra g, this basis induces local coordinates y A on g, that is, ξ = y A eA. Also, this basis induces a basis of sections of τ . Finally, the Lie algebroid structure on Example 12. We consider a Lie algebra g acting on a manifold M, that is, we have a Lie algebra homomorphism g → X(M ) mapping every element ξ of g to a vector field ξM on M. Then we can consider the action Lie algebroid E = M × g. Identifying T E = T M × T g = T M × 2g, an element of the prolongation Lie algebroid to E over the bundle projection is of the form (a, b, va) = ((x, ξ), (x, η), (vx, ξ, χ)) where x ∈ M , vx ∈ TxM and (ξ, η, χ) ∈ 3g. The condition T τg(v) = ρ(b) implies that vx = −ηM (x). Therefore we can identify the prolongation Lie algebroid with M × g × g × g with projection onto the first two factors (x, ξ) and anchor map ρ1(x, ξ, η, χ) = (−ηM (x), ξ, χ). Given a base {eA} of g the basis {e A (x, ξ)) = (x, 0, ξ, eA). Finally, the Lie bracket of two constant sections is given by Example 13. Let us describe the E-tangent bundle to E in the case of E being an Atiyah algebroid induced by a trivial principal G−bundle π : G × M → M. In such case, by left trivialization we get the Atiyah algebroid, the vector bundle τg×T M : g × T M → T M. If X ∈ X(M ) and ξ ∈ g then we may consider the section X ξ : Moreover, in this sense On the other hand, if (ξ, vq) ∈ g × TqM , then the fiber of This implies that T τ g×T M (ξ,vq ) (g × T M ) may be identified with the space 2g × Tv q (T M ). Thus, the Lie algebroid T τ g×T M (g × T M ) may be identified with the vector bundle g × 2g × T T M → g × T M whose vector bundle projection is (ξ, ((η,η), Xv q )) → (ξ, vq) for (ξ, ((η,η), Xv q )) ∈ g × 2g × T T M. Therefore, if (η,η) ∈ 2g and X ∈ X(T M ) then one may consider the section ((η,η), X) given by and the anchor map ρ1 : T τ E * E is a Lie algebroid over E * of rank 2n with vector bundle projection τ (1) As before, if we now denote by (µ, e, vµ) an element (e, vµ) ∈ T τ E * E where µ ∈ E * , we rewrite the definition of the prolongation Lie algebroid as the subset of E * × E × T E * by If (x i ) are local coordinates on an open subset U of M , {eA} is a basis of sections of the vector bundle (τE) −1 (U ) → U and {e A } is its dual basis, then {ẽ Here, (x i , pA) are the local coordinates on E * induced by the local coordinates (x i ) and the basis of sections of E * , {e A }.
Using the local basis {ẽ we have that Therefore, we have that the corresponding vector field ρ τ (1) Finally, the structure of the Lie algebroid ( . We refer to [49] for further details about the Lie algebroid structure of the E-tangent bundle of the dual bundle of a Lie algebroid. Example 15. Let g be a real Lie algebra of finite dimension. Then g is a Lie algebroid over a single point. Using that the anchor map is zero we have that T τ g * g may be identified with the vector bundle pr1 : g * × (g × g * ) → g * . Under this identification the anchor map is given by and the Lie bracket of two constant sections (ξ, α), (η, β) ∈ g × g * is the constant section ([ξ, η], 0).

Example 17.
Let us describe the A-tangent bundle to A in the case of A being an Atiyah algebroid induced by a trivial principal G−bundle π : G × M → M. In such case, by left trivialization we have that the Atiyah algebroid is the vector bundle τg×T M : g × T M → T M. If XX(M ) and ξ ∈ g then we may consider the section X ξ : Moreover, in this sence This implies that T for (µ, ((ξ, β), Xα q )) ∈ g * × (g × g * ) × T T * M. Therefore, if (ξ, β) ∈ g × g * and X ∈ X(T * M ) then one may consider the section ((ξ, β), X) given by and the anchor map ρ τ (1) 2.4. Symplectic Lie algebroids. In this subsection we will recall some results given in [49] about symplectic Lie algebroids.
, ρ) over a manifold M is said to be symplectic if it admits a symplectic section Ω, that is, Ω is a section of the vector bundle 2 E * → M such that: (1) For all x ∈ M, the 2-form Ωx : Ex × Ex → R in the vector space Ex is nondegenerate and (2) Ω is a 2-cocycle, that is, d E Ω = 0.
, ρ) be a Lie algebroid of rank n over a manifold M of dimension m and T τ E * E be the prolongation of E over the vector bundle projection τE * : E * → M. We may introduce a canonical section λE of (T τ E * E) * as follows. If µ ∈ E * and (e, vµ) is a point on the fibre of T τ E * E over µ then λE is called the Liouville section of T τ E * E. Now, in an analogous way that the canonical symplectic form is defined from the Liouville 1-form on the cotangent bundle, we introduce the 2-section ΩE on T τ E * E as Example 19. Let g be a finite dimensional Lie algebra. Then g is a Lie algebroid over a single point M = {q}. If ξ ∈ g and µ, α ∈ g * then is the Liouville 1-section on g * × (g × g * ). Thus, the symplectic section Ωg is Definition 2.5. A tangent vector v at the point e ∈ E is called admissible if ρ(e) = TeτE(v); and a curve on E is admissible if its tangent vectors are admissible. The set of admissible elements on E will be denote E (2) .
Notice that v is admissible if and only if (e, e, v) is in T τ E E. We will consider E (2) as the subset of the prolongation of E over τE, that is, E (2) ⊂ Eρ ×T τ E T E is given by Other authors call this set Adm(E) (see [14] and [57]).
A curve σ : We consider E (2) as the substitute of the second order tangent bundle in classical mechanics. If (x i ) are local coordinates on M and {eA} is a basis of sections of E then we denote (x i , y A ) the corresponding local coordinates on E and ( We denote the canonical inclusion of E (2) on the prolongation of E over τE as . . , m}. In this case, we have seen that the prolongation Lie algebroid over τT M is just the tangent bundle T (T M ) where the Lie algebroid structure of the vector bundle T (T M ) → T M is as we have described above as the tangent bundle of a manifold.
The set of admissible elements is given by and observe that this subset is just the second-order tangent bundle of a manifold M, that is, Example 21. Consider a Lie algebra g as a Lie algebroid over a point {e}. Given a basis of section {eA} and element ξ ∈ g can be written as ξ = eAξ A and given that the anchor map is given by ρ(ξ) ≡ 0, every curve ξ(t) ∈ g is an admisible curve. The set of admisible elements is described by the cartesian product of two copies of the Lie algebra, 2g. Local coordinates on 2g are determined by the basis of sections of g, {eA} and {e A }, the basis of the prolongation Lie algebroid introduced in Example 11. They are denoted by (ξ 1 , ξ 2 ) and also (ξ 1 , ξ 2 ) := (ξ(0),ξ(0)) ∈ 2g where ξ(t) is admissible.

Second-order variational problems on Lie algebroids
The geometric description of mechanics in terms of Lie algebroids gives a general framework to obtain all the relevant equations in mechanics (Euler-Lagrange, Euler-Poincaré, Lagrange-Poincaré,...). In this section we use the notion of Lie algebroid and prolongation of a Lie algebroid described in §2 to derive the Euler-Lagrange equations and Hamilton equations on Lie algebroids. Next, after introduce the constraint algorithm for presymplectic Lie algebroids and study vakonomic mechanics on Lie algebroids, we study the geometric formalism for second-order constrained variational problems using and adaptation of the classical Skinner-Rusk formalism for the second-order constrained systems on Lie algebroids.
3.1. Mechanics on Lie algebroids. In [57] (see also [49]) a geometric formalism for Lagrangian mechanics on Lie algebroids was introduced. It was developed in the prolongation T τ E E of a Lie algebroid E (see §2) over the vector bundle projection τE : E → M . The prolongation of the Lie algebroid is playing the same role as T T Q in the standard mechanics. We first introduce the canonical geometrical structures defined on T τ E E to derive the Euler-Lagrange equations on Lie algebroids.
Two canonical objects on T τ E E are the Euler section ∆ and the vertical endomorphism S. Considering the local basis of sections of T τ E E, {e A , e and S is the section of the vector bundle (T τ E E) ⊗ (T τ E E) * → E locally characterized by the following conditions: A , Se Finally, a section ξ of T τ E E → E is said to be a second order differential equation (SODE) on E if S(ξ) = ∆ or, alternatively, pr1(ξ(e)) = e, for all e ∈ E (for more details, see [49]). Given a Lagrangian function L ∈ C ∞ (E) we introduce the Cartan 1-section ΘL ∈ Γ((T τ E E) * ), the Cartan 2-section ωL ∈ Γ(∧ 2 (T τ E E) * ) and the Lagrangian energy EL ∈ C ∞ (E) as If (x i , y A ) are local fibred coordinates on E, (ρ i A , C C AB ) are the corresponding local structure functions on E and {e (1) A , e A } the corresponding local basis of sections of T τ E E then If c(t) = (x i (t), y A (t)) then c is a solution of the Euler-Lagrange equations for L if and only ifẋ Observe that, if E is the standard Lie algebroid T Q then the above equations are the classical Euler-Lagrange equations for L : T Q → R.
On the other hand, the Lagrangian function L is said to be regular if ωL is a symplectic section. In such a case, there exists a unique solution ξL verifying In addition, one can check that i Sξ L ωL = i∆ωL which implies that ξL is a SODE section. Thus, the integral curves of ξL (that is, the integral curves of the vector field ρ1(ξL)) are solutions of the Euler-Lagrange equations for L. ξL is called the Euler-Lagrange section associated with L.
From (15), we deduce that the Lagrangian L is regular if and only if the matrix is regular. Moreover, the local expression of ξL is where the functions f A satisfy the linear equations Another possibility is when the matrix (WAB) = ∂ 2 L ∂y A ∂y B is singular. This type of Lagrangian is called singular or degenerate Lagrangian. In such a case, ωL is not a symplectic section and Equation (18) has no solution, in general, and even if it exists it will not be unique. In the next subsection, we will give the extension of the classical Gotay-Nester-Hinds algorithm [37] for presymplectic systems on Lie algebroids given in [40], which in particular will be applied to optimal control problems.
For an arbitrary Lagrangian function L : E → R, we introduce the Legendre transformation associated with L as the smooth map legL : E → E * defined by for e, e ∈ Ex. Its local expression is The Legendre transformation induces a Lie algebroid morphism We have that (see [49] for details) where λE is the Liouville section indroduced in (11) and ΩE is the canonical symplectic section on T τ E * E.
On the other hand, from (19), it follows that the Lagrangian function L is regular if and only if legL : E → E * is a local diffeomorphism.
Next, we will assume that L is hyperregular, that is, legL : E → E * is a global diffeomorphism. Then, the pair (T legL, legL) is a Lie algebroid isomorphism. Moreover, we may consider the Hamiltonian function H : E * → R defined by H = EL • leg −1 L and the Hamiltonian section ξH ∈ Γ(T τ E * E) which is characterized by the condition The integral curves of the vector field ρ1(ξH ) on E * satisfy the Hamilton equations for for i ∈ {1, . . . , m} and A ∈ {1, . . . , n} (see [49]). In addition, the Euler-Lagrange section ξL associated with L and the Hamiltonian section ξH are (T legL, legL)-related, that is, where (x i , pi) are local coordinates on T * Q induced by the local coordinates (x i ) and the local basis {dx i } of T * Q (see [5] for example).
Example 24. Consider as a Lie algebroid the finite dimensional Lie algebra (g, [·, ·]g) over a point. If eA is a basis of g and C C AB are the structure constants of the Lie algebra, the structures constant of the Lie algebroid g with respect to the basis {eA} are C C AB = C C AB and ρ i A = 0. Denote by (y A ) and (µA) the local coordinates on g and g * respectively, induced by the basis {eA} and its dual basis {e A } respectively. Given a Lagrangian function L : g → R then the Euler-Lagrange equations for L are just the Euler-Poincaré equations d dt Given a Hamiltonian function H : g * → R the Hamilton equations on g * read as the Lie-Poisson equations for Hμ = ad * ∂H ∂µ µ (see [5] for example).
which are the Lagrange-Poincaré equations associated to a G-invariant Lagrangian L : T M → R (see [17] and [49] for example) where c C AB are the structure constants of the Lie algebra according to Example 4.

3.2.
Constraint algorithm for presymplectic Lie algebroids. In this section we introduce the constraint algorithm for presymplectic Lie algebroids given in [40] which generalizes the well-known Gotay-Nester-Hinds algorithm [37]. First we give a review of the Gotay-Nester-Hinds algorithm and then we introduce the construction given in [40] to the case of Lie algebroids.

The Gotay-Nester-Hinds algorithm of constraints.
In this subsection we will briefly review the constraint algorithm of constraints for presymplectic systems (see [36] and [37]).
Since we are not assuming that Ω is nondegenerate (that is, Ω is not, in general, symplectic) then Equation (21) has no solution in general, or the solutions are not defined everywhere.
In the most favorable case, Equation (21) admits a global (but not necessarily unique) solution X. In this case, we say that the system admits global dynamics. Otherwise, we select the subset of points of M , where such a solution exists. We denote by M2 this subset and we will assume that it is a submanifold of M = M1. Then the equations (21) admit a solution X defined at all points of M2, but X need not be tangent to M2, hence, does not necessarily induce a dynamics on M2. So we impose an additional tangency condition, and we obtain a new submanifold M3 along which there exists a solution X, but, however, such X needs to be tangent to M3. Continuing this process, we obtain a sequence of submanifolds · · · Ms → · · · → M2 → M1 = M where the general description of M l+1 is M l+1 = {p ∈ M l such that there exists Xp ∈ TpM l satisfying iX p Ω(p) = dH(p)}.
If the algorithm ends at a final constraint submanifold, in the sense that at some s ≥ 1 we have Ms+1 = Ms. We will denote this final constraint submanifold by M f . It may still happen that dim M f = 0, that is, M f is a discrete set of points, and in this case the system does not admit a proper dynamics. But, in the case when dim M f > 0, there exists a well-defined solution X of (21) along M f .
There is another characterization of the submanifolds M l that we will useful in the sequel. If N is a submanifold of M then we define T N ⊥ = {Z ∈ TpM, p ∈ N such that Ω(X, Z) = 0 for all X ∈ TpN }.
Then, at any point p ∈ M l there exists Xp ∈ TpM l verifying iX Ω(p) = dH(p) if and only if T M ⊥ l , dH = 0 (see [36,37]). Hence, we can define the l + 1 step of the constraint algorithm as where (F ⊥ x ) 0 is the annihilator of the subspace F ⊥ x . Moreover, using we obtain that ). Thus, from (22), we deduce that Next, we will assume that Ω is a presymplectic 2-section (d E Ω = 0) and that α ∈ Γ(E * ) is a closed 1-section (d E α = 0). Furthermore, we will assume that the kernel of Ω is a vector subbundle of E.
The dynamics of the presymplectic system defined by (Ω, α) is given by a section X ∈ Γ(E) satisfying the dynamical equation In general, a section X satisfying (25) cannot be found in all points of E. First, we look for the points where (25) has sense. We define From (24), it follows that If M1 is an embedded submanifold of M , then we deduce that there exists X : M1 → E a section of τE : E → M along M1 such that (25) holds. But ρ(X) is not, in general, tangent to M1. Thus, we have to restrict to E1 = ρ −1 (T M1). We remark that, provided that E1 is a manifold and τ1 = τE |E 1 : E1 → M1 is a vector bundle, τ1 : E1 → M1 is a Lie subalgebroid of E → M . Now, we must consider the subset M2 of M1 defined by is an embedded submanifold of M1, then we deduce that there exists X : M2 → E1 a section of τ1 : E1 → M1 along M2 such that (25) holds. However, ρ(X) is not, in general, tangent to M2. Therefore, we have that to restrict to E2 = ρ −1 (T M2). As above, if τ2 = τE |E 2 : E2 → M2 is a vector bundle, it follows that τ2 : E2 → M2 is a Lie subalgebroid of τ1 : E1 → M1.
Consequently, if we repeat the process, we obtain a sequence of Lie subalgebroids (by assumption) and If there exists k ∈ N such that M k = M k+1 , then we say that the sequence stabilizes. In such a case, there exists a well-defined (but non necessarily unique) dynamics on the final constraint submanifold M f = M k . We write Then, τ f = τ k : E f = E k → M f = M k is a Lie subalgebroid of τE : E −→ M (the Lie algebroid restriction of E to E f ). From the construction of the constraint algorithm, we deduce that there exists a section X ∈ Γ(E f ), verifying (25). Moreover, if X ∈ Γ(E f ) is a solution of the equation (25), then every arbitrary solution is of the form X = X + Y , where Y ∈ Γ(E f ) and Y (x) ∈ ker Ω(x), for all x ∈ M f . In addition, if we denote by Ω f and α f the restriction of Ω and α, respectively, to the Lie algebroid E f −→ M f , we have that Ω f is a presymplectic 2-section and then any X ∈ Γ(E f ) verifying Equation (25) also satisfies iX Ω f = α f (28) but, in principle, there are solutions of (28) which are not solutions of (25) since ker Ω ∩ E f ⊂ ker Ω f .

Remark 1.
Note that one can generalize the previous procedure to the general setting of implicit differential equations on a Lie algebroid. More precisely, let τE : E → M be a Lie algebroid and S ⊂ E be a submanifold of E (not necessarily a vector subbundle). Then, the corresponding sequence of submanifolds of E is . . .

3.3.
Vakonomic mechanics on Lie algebroids. In this section we will develop a geometrical description for second-order mechanics on Lie algebroids in the Skinner and Rusk formalism, given a general geometric framework for the previous results in this chapter and using strongly the results given in [40]. First, we will review the description of vakonomics mechanics on Lie algebroids given by Iglesias, Marrero, Martín de Diego and Sosa in [40]. After it we will introduce the notion of admissible elements on a Lie algebroid and we will particularize the previous construction to the case when the Lie algebroid is the prolongation of a Lie algebroid and the constraint submanifold is the set of admissible elements. Then we will obtain the second-order Skinner and Rusk formulation on Lie algebroids. Let . . ,m} where Φ α are the local independent constraint functions for the submanifold M.
We will suppose, without loss of generality, that the (m × n)-matrix Consequently, (x i , y a ) are local coordinates on M and we will denote byL the restriction of L to M.
Next, we consider the prolongation of the Lie algebroid E over τ E * : E * → Q (respectively, ν : W0 → Q). We will denote this Lie algebroid by T τ E * E (respectively, T ν E). Moreover, we can prolong π2 : W0 → E * to a morphism of Lie algebroids T π2 : If (x i , pA) are the local coordinates on E * associated with the local basis {e A } of Γ( E * ), then (x i , pA, y a ) are local coordinates on W0 and we may consider the local basis { e (1) , ( e A ) (2) A , e C , and the rest of the fundamental Lie brackets are zero. Moreover, The Pontryagin Hamiltonian HW 0 is a function defined on W0 = M ×Q E * given by or, in local coordinates, Moreover, one can consider the presymplectic 2-section Ω0 = (T π2, π2) * Ω E , where Ω E is the canonical symplectic section on T τ E * E defined in Equation (12). In local coordinates, where { e A (1) , e A , e a (2) } denotes the dual basis of { e (1) a } . Therefore, we have the triple (T ν E, Ω0, d T ν E HW 0 ) as a presymplectic hamiltonian system.
Definition 3.1. The vakonomic problem on Lie algebroids consists on finding the solutions for the equation that is, to solve the constraint algorithm for (T ν E, Ω0, d T ν E HW 0 ).
In local coordinates, we have that 2) .
If we apply the constraint algorithm, Since ker Ω0 = span {e (2) a }, we get that W1 is locally characterized by the equations ∂L ∂y a = 0, or pa = ∂L ∂y a − pα ∂Ψ α ∂y a ,m + 1 ≤ a ≤ n. Let us also look for the expression of X satisfying Eq. (31). A direct computation shows that Therefore, the vakonomic equations are Of course, we know that there exist sections X of T ν E along W1 satisfying (31), but they may not be sections of (ρ ν ) −1 (T W1) = T ν 1 E, in general (here ν1 : W1 → Q).
Then, following the procedure detailed in Section 3.2.2, we obtain a sequence of embedded submanifolds If the algorithm stabilizes, then we find a final constraint submanifold W f on which at least a section X ∈ Γ(T ν f E) verifies One of the most important cases is when W f = W1. The authors of [40] have analyzed this case with the following result: Consider the restriction Ω1 of Ω0 to T ν 1 E; Proposition 2. Ω1 is a symplectic section of the Lie algebroid T ν 1 E if and only if for any system of coordinates (x i , pA, y a ) on W0 we have that det ∂ 2L ∂y a ∂y b − pα ∂ 2 Ψ α ∂y a ∂y b = 0, for all point in W1.

3.4.
Second-order variational problems on Lie algebroids. In this section we will study second-order variational problems on Lie algebroid. First we introduce the geometric object for the formalism and then we study second-order unconstrained variation problems. After that, we will analyze the constrained case.

Prolongation of a Lie algebroid over a smooth map (cont'd).
This subsection is devoted to study some additional properties and characterizations about the prolongation of a Lie algebroid over a smooth map (see subsection 2.2).
Let E be a Lie algebroid over Q with fiber bundle projection τ E : E → Q and anchor map ρ : E → T Q. Also, let τE : E → M be a Lie algebroid with anchor map ρ : E → T M and let T τ E E be the E−tangent bundle to E. Now we will define the bundle T τ (1) In what follows we will describe the Lie algebroid structure of the E-tangent bundle to the prolongation Lie algebroid over τE : E → Q.
As we know from subsection (2.2), the basis of sections {eA} of E induces a local basis of the sections of T τ E E given by e (1) A (e) = e, 0, for e ∈ E. From this basis we can induce local coordinates ( Now, from this basis, we can induce a local basis of sections of T τ (1) E (T τ E E) in the following way: consider an element (e, v b ) ∈ T τ E E, then define the components of the basis {e A (e), .

The basis {e
for all A, B and C where C C AB are the structure constants of E. In the same way, from the basis { e (1) where e * ∈ E, we construct the set { e A , ( e A ) (2) }. This basis is given by where α * ∈ (T τ E E) * and τ (T τ E E) * : (T τ E E) * → E is the vector bundle projection. The Lie algebroid structure (T τ (T τ E E) * (T τ E E); [[·, ·]]2, ρ2) is given by where the unique non-zero Lie bracket is [[ e . This basis induces local coordinates (x i , y A , pA,pA, q A ,q A ; lA,lA) on T τ (T τ E E) * T τ E E.

3.4.2.
Second-order unconstrained problem on Lie algebroids. Next, we will study secondorder problem on Lie algebroids. Consider the Whitney sum of (T τ E E) * and T τ E E, W = T τ E E ×E (T τ E E) * and its canonical projections pr1 : W → T τ E E and pr2 : W → (T τ E E) * . Now, let W0 be the submanifold W0 = pr −1 1 (E (2) ) = E (2) ×E (T τ E E) * and the restrictions π1 = pr1 |W 0 and π2 = pr2 |W 0 . Also we denote by ν : W0 → E the canonical projection. The diagram in Figure 1 illustrates the situation. Figure 1. Second order Skinner and Rusk formalism on Lie algebroids Consider the prolongations of T τ E E by τ (T τ E E) * and by ν, respectively. We will denote these Lie algebroids by T τ (T τ E E) * (T τ E E) and T ν T τ E E respectively. Moreover, we can prolong π2 : W0 → (T τ E E) * to a morphism of Lie algebroids T π2 : We denote by (x i , y A , pA,pA) local coordinates on (T τ E E) * induced by {e A (1) , e A (2) }, the dual basis of the basis {e (1) A , e (2) A }, a basis of T τ E E. Then, (x i , y A , pA,pA, z A ) are local coordinates in W0 and we may consider { e , , , and the rest of the fundamental Lie brackets are zero. Moreover, , ρ ν (( e A ) (2,2) (α, α * )) = (α, α * ), ∂ ∂pA (α,α * ) .
The second-order problem on the Lie algebroid τE : E → M consists on finding the solutions of the equation that is, to solve the constraint algorithm for T ν T τ E E, Ω0, d T ν T τ E E HW 0 .
If we apply the constraint algorithm, since ker Ω0 = span {ě (2,1) A } the first constraint submanifold W1 is locally characterized by the equation Looking for the expression of X satisfying the equation for the second-order problem we have that the second-order equations arė After some straightforward computations the last equations are equivalent to the following equations: As in the previous section, it is possible to apply the constraint algorithm (3.2.2) to obtain a final constraint submanifold where we have at least a solution which is dynamically compatible. The algorithm is exactly the same but applied to the equation iX Ω0 = d T ν T τ E E HW 0 . Observe that the first constraint submanifold W1 is determined by the conditions ϕA =pA − ∂L ∂z A = 0. If we denote by ΩW 1 the pullback of the presymplectic 2-section ΩW 0 to W1, then we deduce the following: Proposition 3. ΩW 1 is a symplectic section of the Lie algebroid T ν 1 T τ E E if and only if Remark 2. Proposition 3 is the same result than the theorem given in [40] which are the second-order Lagrange-Poincaré equations associated to a G-invariant Lagrangian L : T (2) M → R (see [30] and [31]) where c C AB are the structure constants of the Lie algebra according to Example 4. Observe that If G = {e}, the identity of G, T (2) M = T (2) M and the second-order Lagrange-Poincaré equations become into the second-order Euler-Lagrange equations [19], [48] If G = M , T (2) M = 2g after a left-trivialization, and the second-order Lagrange-Poincaré equations become into the second-order Euler-Poincaré equations [20], [29], [30]

3.4.3.
Second-order constrained problem on Lie algebroids. Now, we will consider secondorder mechanical systems subject to second-order constraints. Let M ⊂ E (2) be an embedded submanifold of dimension n + m −m (locally determined by the vanishing of the constraint functions Φ α : M → R, α = 1, . . . , m) such that the bundle projection τ (2,1) E |M: M → E is a surjective submersion.
We will suppose that the (m × n)−matrix ∂Φ α ∂z B with α = 1, . . . ,m and B = 1, . . . , n is of maximal rank. Then, we will use the following notation z A = (z α , z a ) for 1 ≤ A ≤ n, 1 ≤ α ≤m andm + 1 ≤ a ≤ n. Therefore, using the implicit function theorem we can write z α = Ψ α (x i , y A , z a ). Consequently we can consider local coordinates on M by (x i , y A , z a ) and we will denote by L the restriction of L to M. Let us take the submanifold W 0 = pr −1 1 (M) = M ×E (T τ E E) * and the restrictions of W 0 of the canonical projections π1 and π2 given by π1 = pr1 | W 0 and π2 = pr1 | W 0 . We will denote local coordinates on W 0 by (x i , y A , pA,pA, z a ).
Therefore, proceeding as in the unconstrained case one can construct the presymplectic Hamiltonian system (W 0, Ω W 0 , H W 0 ), where Ω W 0 is the presymplectic 2-section on W 0 and the Hamiltonian function H : W 0 → R is locally given by With these two elements it is possible to write the following presymplectic system iX where (ρ ν ) −1 (T W0) denotes the Lie subalgebroid of T ν T τ E E over W 0 ⊂ W0.
To characterize the equations we will adopt an "extrinsic point of view", that is, we will work on the full space W0 instead of in the restricted space W0. Consider an arbitrary extension L : E (2) → R of LM : M → R. The main idea is to take into account that Equation (33) is equivalent to where H : W0 → R is the function defined in the last section and ann denotes the set of Assuming that M is determined by the vanishing of m-independent constraints then, locally, ann (ρ ν ) −1 (T W 0) = span {d T ν T τ E E Φ α } , and therefore the previous equations are rewritten as where λα are Lagrange multipliers to be determined. Proceeding as in the previous section, one can obtain the following system of equations Here the first constraint submanifold W 1 is determined by the condition If we denote by Ω W 1 the pullback of the presymplectic section Ω W 0 to W 1, then we can deduce that Ω W 1 is a symplectic section if and only if is nondegenerate.

Application to optimal control of mechanical systems
In this section we study optimal control problems of mechanical systems defined on Lie algebroids. First we treat with fully actuated system and next with underactuated systems. Optimality conditions for the optimal control of the controlled Elroy's Beany system are derived.
Optimal control problems can be seen as higher-order variational problems (see [5] and [6]). Higher-order variational problems are given by min q(·) T 0 L(q i ,q i , . . . , q (k)i )dt, subject to boundary conditions. The relationship between higher-order variational problems and optimal control problems of mechanical systems comes from the fact that Euler-Lagrange equations are represented by a second-order Newtonian system and mechanical control systems have the form F (q i ,q i ,q i ) = u, where u are the control inputs. Then, if C is a given cost function, min (q(·),u(·)) T 0 C(q i ,q i , u)dt, is equivalent to a higher-order variational problem with k = 2.

4.1.
Optimal control problems of fully-actuated mechanical systems on Lie algebroids. Let (E, [[·, ·]], ρ) be a Lie algebroid over Q with bundle projection τE : E → Q. The dynamics is specified fixing a Lagrangian L : E → R. External forces are modeled, in this case, by curves uF : R → E * where E * is the dual bundle τE * : E * → Q.
Given local coordinates (q i ) on Q, and fixing a basis of sections {eA} of τE : E → Q we can induce local coordinates (q i , y A ) on E; that is, every element b ∈ Eq = τ −1 E (q) is expressed univocally as b = y A eA(q).
It is possible to adapt the derivation of the Lagrange-d'Alembert principle to study fully-actuated mechanical controlled systems on Lie algebroids (see [26] and [59]). Let q0 and qT fixed in Q, consider an admissible curve ξ : I ⊂ R → E which satisfies the principle where η(t) ∈ E τ E (ξ(t)) and uF (t) ∈ E * τ E (ξ(t)) defines the control force (where we are assuming they are arbitrary). The infinitesimal variations in the variational principle are given by δξ = η C , for all time-dependent sections η ∈ Γ(τE), with η(0) = 0 and η(T ) = 0, where η C is a time-dependent vector field on E, the complete lift, locally defined by [26,55,56,57] where (uF )A(t) = uF (t), eA(q(t)) are the local components of uF fixed the system of coordinates (q i ) on Q and the basis of section {eA}.
The control force uF is chosen such that it minimizes the cost functional where C : E ⊕ E * → R is the cost function associated with the optimal control problem. Therefore, the optimal control problem consists on finding an admissible curve ξ(t) = (q i (t), y A (t)) solution of the controlled Euler-Lagrange equations, the boundary conditions and minimizing the cost functional for C : E ⊕ E * → R. This optimal control problem can be equivalently solved as a second-order variational problem by defining the second-order Lagrangian L : where we are considering local coordinates (q i , y A , z A ) on E (2) . Consider W0 = E (2) × (T τ E * E) * with local coordinates (q i , y A , pa,pA, z A ). The optimality conditions are determined bẏ The constraint submanifold W1 is determined bypA − ∂C ∂z A = 0. If the matrix is non-singular then we can write the previous equations as an explicit system of ordinary differential equations. This regularity assumption is equivalent to the condition that the constraint algorithm stops at the first constraint submanifold W1. Proceeding as in the previous section, after some computations, the dynamics associated with the second-order Lagrangian L : E (2) → R (and therefore the optimality conditions for the optimal control problem) is given by the second-order Euler-Lagrange equations on Lie algebroids together with the admissibility condition Remark 3. Alternatively, one can define the Lagrangian L : E (2) → R in terms of the Euler-Lagrange operator as where EL(L) : E (2) → E * is the Euler-Lagrange operator which locally reads as Here {e A } is the dual basis of {eA}, the basis of sections of E and τ E (2) E : E (2) → E is the canonical projection between E (2) and E given by the map E (2) Example 27. An illustrative example: optimal control of a fully actuated rigid body and cubic splines on Lie groups We consider the motion of a rigid body where the configuration space is the Lie group G = SO(3) and so(3) ≡ R 3 its Lie algebra. The motion of the rigid body is invariant under SO(3). The reduced Lagrangian function for this system defined on the Lie algebroid E = so(3), : so(3) → R is given by (Ω1, Ω2, Ω3) = 1 2 Denote by t → R(t) ∈ SO(3) a curve. The columns of the matrix R(t) represent the directions of the principal axis of the body at time t with respect to some reference system. Consider the following left invariant control problem. First, we have the reconstruction equation: where I1, I2, I3 are the moments of inertia and u1, u2, u3 denote the applied torques playing the role of controls of the system.
The first constraint submanifold is given by Observe that where I3×3 denotes the 3 × 3 identity matrix. Thus, the constraint algorithm stops at the first constraint submanifold W1. We can write the equations of motion for the optimal control system as: After some strighforward computations, previous equations can be reduced to ... Finally, we would like to comment that the regularity condition provides the existence of a unique solution of the dynamics along the submanifold W1. Therefore, there exists a unique vector field X ∈ X(W1) which satisfies iX ΩW 1 = dHW 1 . In consequence, we have a unique control input which extremizes (minimizes) the objective function A. If we take the flow Ft : W1 → W1 of the vector field X then we have that F * t ΩW 1 = ΩW 1 . Obviously, the Hamiltonian function is preserved by the solution of the optimal control problem, that is

4.2.
Optimal control problems of underactuated mechanical systems on Lie algebroids. Now, suppose that our mechanical control system is underactuated, that is, the number of control inputs is less than the dimension of the configuration space.
These equations are precisely the components of the Euler-Lagrange operator EL : E (2) → E * , which locally reads where {e A } is the dual basis of {eA} (see [26]). In terms of the Euler-Lagrange operator, the equations of motion just read EL = 0. In the underactuated case, we model the set of control forces by the vector subbundle span{e a } ⊂ E * and the forces are given by uF = (uF )ae a . Now, we add controls in our picture. Assume that the controlled Euler-Lagrange equations are d dt where we are denoting as {e A } = {e a , e α } the dual basis of {eA} and ua are admissible control parameters. Using the basis of sections of E, equations (38) can be rewritten as The optimal control problem consists on finding an admissible curve γ(t) = (q i (t), y A (t), u(t)) of the state variables and control inputs given initial and final boundary conditions (q i (0), y A (0)) and (q i (T ), y A (T )), respectively, solving the controlled Euler-Lagrange equations (39) and minimizing where C : E × U → R denotes the cost function.
To solve this optimal control problem is equivalent to solve the following second-order problem: The Lagrangian L is subjected to the second-order constraints: which determines a submanifold M of E (2) .

Remark 4.
Observe that the cost function is not completely defined in E ⊕ E * , it is only defined in a smaller subset of this space because d dt ∂L ∂y a − ρ i a ∂L ∂q i + C C aB y B ∂L ∂y C only belongs to the vector subbundle span{e a } ⊂ E * . That is, in the case of fully actuated system the cost function would be defined in the full space E * , and when we are dealing with an underactuated systems, the cost function is defined in a proper subset of E * . Next, for simplicity, we assume that C : E ⊕ E * → R.
Observe that from the constraint equations we have that ∂ 2 L ∂y α ∂y β z β + ∂ 2 L ∂y α ∂y a z a − ρ i α ∂L ∂q i + C C αB y B ∂L ∂y C = 0.
Therefore, assuming that the matrix W αβ = ∂ 2 L ∂y α ∂y β is regular, we can write the equations as z α = −W αβ ∂ 2 L ∂y β ∂y a z a − ρ i β ∂L ∂q i + C C βB y B ∂L ∂y C = G α (q i , y A , z a ) where W αβ = (W αβ ) −1 . Therefore, we can choose coordinates (q i , y A , z a ) on M. This choose allows us to consider an intrinsic point of view, that is, to work directly on W = M × (T τ E E) * avoiding the use of the Lagrange multipliers.
Define the restricted Lagrangian LM by L M : M → R and take induced coordinates on W , (q i , y A , z a , pA, p A ). Applying the same procedure than in section 3.4.3 we derive the following system of equationṡ To shorten the number of unknown variables involved in the previous set of equations, we can write them using as variables (q i , y A , z a , p α ) If the matrix is regular then we can write the previous equations as an explicit system of third-order differential equations. This regularity assumption is equivalent to the condition that the constrain algorithm stops at the first constraint submanifold. In this submanifold there exists a unique solution for the boundary value problem determined by the optimal control problem.
Example 28. Optimal control of an underactuated Elroy's beanie: This mechanical system is probably the simplest example of a dynamical system with a non-Abelian Lie group symmetry. It consists of two planar rigid bodies connected through their centers of mass (by a rotor let's say) moving freely in the plane (see [5] and [64]). The main (i.e. more massive) rigid body has the capacity to apply a torque to the connected rigid body. The configuration space is Q = SE(2) × S 1 with coordinates (x, y, θ, ψ), where the first three coordinates describe the position and orientation of the center of mass of the first body and the last one describe the relative orientation between both bodies. where m denotes the mass of the system and I1 and I2 are the inertias of the first and the second body, respectively; additionally, we also consider a potential function of the form V (ψ). The kinetic energy is associated with the Riemannian metric G on Q given by G = m(dx 2 + dy 2 ) + (I1 + I2)dθ 2 + I2dθ ⊗ dψ + I2dψ ⊗ dθ + I2dψ 2 .
Thus, the constraint algorithm stops at the first constraint submanifold W1.
Finally, in a similar fashion as the unconstrained situation, we would like to point out that the regularity condition provides the existence of a unique solution of the dynamics along the submanifold W1.
Then, we can write the equations determining necessary conditions for the optimal control problem: