Degenerate Lagrangian Systems

A Lagrangian $L(x,v)$ is said to be degenerate if the determinant of the Hessian with respect to the velocities vanishes, i.e.,

\[\left\vert \frac{\partial^2 L}{\partial v^i \, \partial v^j} \right\vert = 0 .\]

The Euler-Lagrange equations,

\[\frac{d}{dt} \frac{\partial L}{\partial v} - \frac{\partial L}{\partial x} = 0 ,\]

of such Lagrangians are a set of first-order ordinary differential equations and not second-order differential equations as for non-degenerate Lagrangians.

Of particular interest in various applications are degenerate Lagrangians of the form

\[L(x,v) = \vartheta(x) \cdot v - H (x) .\]

Their Euler-Lagrange equations take the form

\[\frac{d \vartheta}{dt} (x) = \nabla \vartheta(x) \cdot v - \nabla H (x) .\]

We exemplify this with the Lotka-Volterra problem in 2d.

Lotka-Volterra

Before any use, we need to load EulerLagrange:

using EulerLagrange
using LinearAlgebra

Next, we generate symbolic variables for a two-dimensional Lagrangian system:

t, x, v = lagrangian_variables(2)
(t, (x(t))[1:2], (v(t))[1:2])

We define a named tuple with typical values for the parameters, e.g.,

params = (
    a₁ = -1.0,
    a₂ = -1.0,
    b₁ = 1.0,
    b₂ = 2.0,
)
(a₁ = -1.0, a₂ = -1.0, b₁ = 1.0, b₂ = 2.0)

We use the function symbolize to generate a symbolic version of the parameters:

sparams = symbolize(params)
(a₁ = a₁ₚ, a₂ = a₂ₚ, b₁ = b₁ₚ, b₂ = b₂ₚ)

Define the Hamiltonian function and the symplectic potential:

ϑ(x, params) = [log(x[2]) / x[1] / 2, - log(x[1]) / x[2] / 2]
H(x, params) = params.a₁ * x[1] + params.a₂ * x[2] + params.b₁ * log(x[1]) + params.b₂ * log(x[2])
H (generic function with 1 method)

The Hamiltonian and the symplectic potential, evaluated on and together with the symbolic variables and parameters are used to construct a DegenerateLagrangianSystem:

lag_sys = DegenerateLagrangianSystem(ϑ(x,sparams) ⋅ v, H(x,sparams), t, x, v, sparams)

Degenerate Lagrangian system with

L = ((v(t))[1]*(x(t))[2]*log((x(t))[2]) - (v(t))[2]*(x(t))[1]*log((x(t))[1])) / (2(x(t))[1]*(x(t))[2]) - a₁ₚ*(x(t))[1] - a₂ₚ*(x(t))[2] - b₁ₚ*log((x(t))[1]) - b₂ₚ*log((x(t))[2])

The constructor computes the Euler-Lagrange equations and generates the corresponding Julia code.

In the last step, we can now construct a LODEProblem from the LagrangianSystem and some appropriate initial conditions, a time span to integrate over and a time step:

tspan = (0.0, 10.0)
tstep = 0.01

q₀ = [2.0, 1.0]
p₀ = ϑ(q₀, params)

lprob = LODEProblem(lag_sys, tspan, tstep, q₀, p₀; parameters = params)
Geometric Equation Problem for Lagrangian Ordinary Differential Equation (LODE)

 with vector fields
   ϑ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xcd8dd1ad, 0x5059a3b4, 0x50a29946, 0xbbcd909d, 0x8919467a), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = log(getindex(X, 2)) / (2 * getindex(X, 1))
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * log(getindex(X, 1))) / (2 * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end)
   f = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x47d19f67, 0x2a277769, 0xa1e4f3c1, 0x7327d777, 0x5f7949b9), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = ((-1 * params.a₁ + (-1 * params.b₁) / getindex(X, 1)) + (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1) ^ 2) * getindex(X, 2))) + (-1 * getindex(V, 2) + (-1 * getindex(V, 2)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:8 =#
                        ˍ₋out[2] = ((-1 * params.a₂ + (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2) ^ 2)) + (getindex(V, 1) + getindex(V, 1) * log(getindex(X, 2))) / ((2 * getindex(X, 1)) * getindex(X, 2))) + (-1 * params.b₂) / getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end)
   g = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x3e1d0ee6, 0x54e46dc4, 0x51ae1e17, 0xccb9ea7f, 0xb461ffa8), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1) ^ 2) * getindex(X, 2)) + (-1 * getindex(V, 2) + (-1 * getindex(V, 2)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:8 =#
                        ˍ₋out[2] = (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2) ^ 2) + (getindex(V, 1) + getindex(V, 1) * log(getindex(X, 2))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end)

 Lagrangian: L = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x69df3288, 0xdcd86cfd, 0x8a404fcf, 0x1e734452, 0xc622e52e), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                (((((getindex(V, 1) * getindex(X, 2)) * log(getindex(X, 2)) + ((-1 * getindex(V, 2)) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2)) + (-1 * getindex(X, 1)) * params.a₁) + (-1 * getindex(X, 2)) * params.a₂) + (-1 * params.b₁) * log(getindex(X, 1))) + (-1 * params.b₂) * log(getindex(X, 2))
            end
        end
end)

 Invariants: 
   (h = EulerLagrange.var"#102#103"{@NamedTuple{L::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x69df3288, 0xdcd86cfd, 0x8a404fcf, 0x1e734452, 0xc622e52e), Expr}, H::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x855d5e14, 0x22d3b0ee, 0x344c9576, 0x3014d5d1, 0x3e77a82b), Expr}, EL::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x5dcc9bf2, 0xede2f8d7, 0x21eaf7b0, 0xb0a9e4b3, 0x2fabaebc), Expr}, ∇H::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xe6f1454c, 0xf2a70479, 0x8e1ea0fe, 0xed3234fe, 0xb82c6a43), Expr}, ẋ::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xa6549a66, 0x0d8c53ab, 0x48566a67, 0x5c76cc8f, 0xe4aa0b62), Expr}, v::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :P, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xa6549a66, 0x0d8c53ab, 0x48566a67, 0x5c76cc8f, 0xe4aa0b62), Expr}, f::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x47d19f67, 0x2a277769, 0xa1e4f3c1, 0x7327d777, 0x5f7949b9), Expr}, u::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xf4a5c6cf, 0x65663fc4, 0x6c216918, 0x8a613d9a, 0x75022a55), Expr}, g::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x3e1d0ee6, 0x54e46dc4, 0x51ae1e17, 0xccb9ea7f, 0xb461ffa8), Expr}, ū::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :P, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xf4a5c6cf, 0x65663fc4, 0x6c216918, 0x8a613d9a, 0x75022a55), Expr}, ḡ::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :P, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x185e121a, 0x594cee67, 0xd3138686, 0x9ba1ea16, 0xd4dde8d0), Expr}, p::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x99131ea6, 0x8c7aa92b, 0x6e2abd70, 0xa3e501a0, 0x30975d4b), Expr}, ϑ::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xcd8dd1ad, 0x5059a3b4, 0x50a29946, 0xbbcd909d, 0x8919467a), Expr}, ω::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x48579287, 0x6ab16d11, 0x8097fbf6, 0x3c308148, 0x4a74d203), Expr}, ϕ::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :P, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x283b5e25, 0xef40b098, 0xc35bed3c, 0xf35474ed, 0x80a76f63), Expr}, ψ::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :P, :F, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xb404cb9d, 0xc8957f40, 0xba8db510, 0x2375eb69, 0x7476dd29), Expr}, P::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x28e8ea00, 0x2f7a2021, 0xa61e2e9a, 0x54b9e49e, 0xa26fcaef), Expr}}}((L = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x69df3288, 0xdcd86cfd, 0x8a404fcf, 0x1e734452, 0xc622e52e), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                (((((getindex(V, 1) * getindex(X, 2)) * log(getindex(X, 2)) + ((-1 * getindex(V, 2)) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2)) + (-1 * getindex(X, 1)) * params.a₁) + (-1 * getindex(X, 2)) * params.a₂) + (-1 * params.b₁) * log(getindex(X, 1))) + (-1 * params.b₂) * log(getindex(X, 2))
            end
        end
end), H = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x855d5e14, 0x22d3b0ee, 0x344c9576, 0x3014d5d1, 0x3e77a82b), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                ((getindex(X, 1) * params.a₁ + getindex(X, 2) * params.a₂) + params.b₁ * log(getindex(X, 1))) + params.b₂ * log(getindex(X, 2))
            end
        end
end), EL = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x5dcc9bf2, 0xede2f8d7, 0x21eaf7b0, 0xb0a9e4b3, 0x2fabaebc), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = -1 * params.a₁ + (-1 * params.b₁) / getindex(X, 1)
                        #= none:8 =#
                        ˍ₋out[2] = -1 * params.a₂ + (-1 * params.b₂) / getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ∇H = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xe6f1454c, 0xf2a70479, 0x8e1ea0fe, 0xed3234fe, 0xb82c6a43), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = params.a₁ + params.b₁ / getindex(X, 1)
                        #= none:8 =#
                        ˍ₋out[2] = params.a₂ + params.b₂ / getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ẋ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xa6549a66, 0x0d8c53ab, 0x48566a67, 0x5c76cc8f, 0xe4aa0b62), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = getindex(X, 1) * (params.b₂ + getindex(X, 2) * params.a₂)
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * (params.b₁ + getindex(X, 1) * params.a₁)) * getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), v = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :P, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xa6549a66, 0x0d8c53ab, 0x48566a67, 0x5c76cc8f, 0xe4aa0b62), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = getindex(X, 1) * (params.b₂ + getindex(X, 2) * params.a₂)
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * (params.b₁ + getindex(X, 1) * params.a₁)) * getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), f = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x47d19f67, 0x2a277769, 0xa1e4f3c1, 0x7327d777, 0x5f7949b9), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = ((-1 * params.a₁ + (-1 * params.b₁) / getindex(X, 1)) + (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1) ^ 2) * getindex(X, 2))) + (-1 * getindex(V, 2) + (-1 * getindex(V, 2)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:8 =#
                        ˍ₋out[2] = ((-1 * params.a₂ + (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2) ^ 2)) + (getindex(V, 1) + getindex(V, 1) * log(getindex(X, 2))) / ((2 * getindex(X, 1)) * getindex(X, 2))) + (-1 * params.b₂) / getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), u = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xf4a5c6cf, 0x65663fc4, 0x6c216918, 0x8a613d9a, 0x75022a55), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = getindex(V, 1)
                        #= none:8 =#
                        ˍ₋out[2] = getindex(V, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), g = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x3e1d0ee6, 0x54e46dc4, 0x51ae1e17, 0xccb9ea7f, 0xb461ffa8), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1) ^ 2) * getindex(X, 2)) + (-1 * getindex(V, 2) + (-1 * getindex(V, 2)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:8 =#
                        ˍ₋out[2] = (((-1 * getindex(V, 1)) * getindex(X, 2)) * log(getindex(X, 2)) + (getindex(V, 2) * getindex(X, 1)) * log(getindex(X, 1))) / ((2 * getindex(X, 1)) * getindex(X, 2) ^ 2) + (getindex(V, 1) + getindex(V, 1) * log(getindex(X, 2))) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ū = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :P, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xf4a5c6cf, 0x65663fc4, 0x6c216918, 0x8a613d9a, 0x75022a55), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = getindex(V, 1)
                        #= none:8 =#
                        ˍ₋out[2] = getindex(V, 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ḡ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :Λ, :P, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x185e121a, 0x594cee67, 0xd3138686, 0x9ba1ea16, 0xd4dde8d0), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = ((-1 * getindex(V, 1)) * log(getindex(X, 2))) / (2 * getindex(X, 1) ^ 2) + getindex(V, 2) / ((2 * getindex(X, 1)) * getindex(X, 2))
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * getindex(V, 1)) / ((2 * getindex(X, 1)) * getindex(X, 2)) + (getindex(V, 2) * log(getindex(X, 1))) / (2 * getindex(X, 2) ^ 2)
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), p = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x99131ea6, 0x8c7aa92b, 0x6e2abd70, 0xa3e501a0, 0x30975d4b), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                begin
                    #= none:7 =#
                    SymbolicUtils.Code.create_array(Array, nothing, Val{1}(), Val{(2,)}(), log(getindex(X, 2)) / (2 * getindex(X, 1)), (-1 * log(getindex(X, 1))) / (2 * getindex(X, 2)))
                end
            end
        end
end), ϑ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xcd8dd1ad, 0x5059a3b4, 0x50a29946, 0xbbcd909d, 0x8919467a), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = log(getindex(X, 2)) / (2 * getindex(X, 1))
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * log(getindex(X, 1))) / (2 * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ω = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x48579287, 0x6ab16d11, 0x8097fbf6, 0x3c308148, 0x4a74d203), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = 0
                        #= none:8 =#
                        ˍ₋out[2] = 1 / (getindex(X, 1) * getindex(X, 2))
                        #= none:9 =#
                        ˍ₋out[3] = -1 / (getindex(X, 1) * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out[4] = 0
                        #= none:12 =#
                        ˍ₋out
                    end
            end
        end
end), ϕ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :P, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x283b5e25, 0xef40b098, 0xc35bed3c, 0xf35474ed, 0x80a76f63), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = getindex(P, 1) + (-1 * log(getindex(X, 2))) / (2 * getindex(X, 1))
                        #= none:8 =#
                        ˍ₋out[2] = getindex(P, 2) + log(getindex(X, 1)) / (2 * getindex(X, 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), ψ = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :P, :F, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0xb404cb9d, 0xc8957f40, 0xba8db510, 0x2375eb69, 0x7476dd29), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = (getindex(F, 1) + -1 * (((-1 * getindex(V, 1)) * log(getindex(X, 2))) / (2 * getindex(X, 1) ^ 2))) + -1 * (getindex(V, 2) / ((2 * getindex(X, 1)) * getindex(X, 2)))
                        #= none:8 =#
                        ˍ₋out[2] = (getindex(F, 2) + -1 * ((-1 * getindex(V, 1)) / ((2 * getindex(X, 1)) * getindex(X, 2)))) + -1 * ((getindex(V, 2) * log(getindex(X, 1))) / (2 * getindex(X, 2) ^ 2))
                        #= none:10 =#
                        ˍ₋out
                    end
            end
        end
end), P = RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :t, :X, :V, :params), EulerLagrange.var"#_RGF_ModTag", EulerLagrange.var"#_RGF_ModTag", (0x28e8ea00, 0x2f7a2021, 0xa61e2e9a, 0x54b9e49e, 0xa26fcaef), Expr}(quote
    #= none:1 =#
    #= none:2 =#
    #= none:2 =# @inbounds begin
            #= none:4 =#
            begin
                #= none:5 =#
                #= none:5 =# @inbounds begin
                        #= none:7 =#
                        ˍ₋out[1] = 0
                        #= none:8 =#
                        ˍ₋out[2] = (-1 * getindex(X, 1)) * getindex(X, 2)
                        #= none:9 =#
                        ˍ₋out[3] = getindex(X, 1) * getindex(X, 2)
                        #= none:10 =#
                        ˍ₋out[4] = 0
                        #= none:12 =#
                        ˍ₋out
                    end
            end
        end
end))),)

 Timespan: (0.0, 10.0) 
 Timestep: 0.01 

 Initial conditions: 
   (t = fill(0.0), q = [2.0, 1.0], p = [0.0, -0.34657359027997264], v = [2.0, 1.0])

 Parameters: 
   (a₁ = -1.0, a₂ = -1.0, b₁ = 1.0, b₂ = 2.0)

We can integrate this system using GeometricIntegrators:

using GeometricIntegrators
sol = integrate(lprob, Gauss(1))

using CairoMakie
fig = lines(parent(sol.q[:,1]), parent(sol.q[:,2]);
    axis = (; xlabel = "x₁", ylabel = "x₂", title = "Lotka-Volterra system in 2d"),
    figure = (; size = (800,600), fontsize = 22))