Hamiltonian lift
The Hamiltonian lift of a vector field
This is a purely algebraic operation — it uses no automatic differentiation. The lift is the bridge from the velocity picture (vector fields) to the Hamiltonian picture (scalar functions on phase space), and it is the building block of the Pontryagin maximum principle: the pseudo-Hamiltonian is a sum of lifts of the drift and control vector fields.
When
The relevant method is Lift.
On plain functions
Given a Julia Function, Lift returns a Function with the matching call signature. The traits are read from the is_autonomous and is_variable keyword arguments (both default to autonomous/fixed).
Autonomous, fixed — X(x)
X = x -> [x[2], -x[1]]
H = Lift(X)
H([1.0, 2.0], [0.5, 1.0]) # p' * X(x) = 0.5*2 + 1.0*(-1)0.0Non-autonomous — X(t, x)
Xt = (t, x) -> [t * x[2], -x[1]]
Ht = Lift(Xt; is_autonomous=false)
Ht(2.0, [1.0, 2.0], [0.5, 1.0]) # p' * X(t, x)1.0Variable-dependent — X(x, v)
Xv = (x, v) -> [x[2], -v * x[1]]
Hv = Lift(Xv; is_variable=true)
Hv([1.0, 2.0], [0.5, 1.0], 3.0) # p' * X(x, v)-2.0Non-autonomous and variable-dependent — X(t, x, v)
Xtv = (t, x, v) -> [t * x[2], -v * x[1]]
Htv = Lift(Xtv; is_autonomous=false, is_variable=true)
Htv(2.0, [1.0, 2.0], [0.5, 1.0], 3.0)-1.0On typed vector fields
When the argument is a typed VectorField, Lift returns a typed Hamiltonian whose traits are inherited from the vector field — no keyword arguments are needed.
Xt = VectorField(x -> [x[2], -x[1]]; is_autonomous=true, is_variable=false)
H = Lift(Xt)Hamiltonian: autonomous, fixed (no variable)
natural call: h(x, p)
uniform call: h(t, x, p, v)H([1.0, 2.0], [0.5, 1.0])0.0The same works for every trait combination; here a non-autonomous, variable-dependent field:
Xtv = VectorField((t, x, v) -> [t * x[2], -v * x[1]];
is_autonomous=false, is_variable=true)
Htv = Lift(Xtv)
Htv(2.0, [1.0, 2.0], [0.5, 1.0], 3.0)-1.0Not for Hamiltonian vector fields
Lift accepts a plain VectorField, not a HamiltonianVectorField: the latter already lives on phase space with signature (x, p). Lifting one raises a NotImplemented error — see Limitations & configuration.
See also
Lift— full docstring and method list.Poisson bracket — the lift connects Lie brackets of vector fields to Poisson brackets of their lifts (see the correspondence verified there).