## `detools::hasHamiltonian` -- check for Hamiltonian vector field

#### Introduction

`detools::hasHamiltonian``(vf,q,p)` checks whether the vector field `vf` in the variables `q` and `p` is Hamiltonian.

#### Call(s)

`detools::hasHamiltonian(vf, p, q)`

#### Parameters

`vf` | - | the vector field: a list of expressions; its length must be twice the length of the list `q`.
`q` | - | the position variables: a list of (indexed) identifiers.
`p` | - | the momentum variables: a list of (indexed) identifiers; must have the same length as the list `q`.

#### Returns

a list of expressions; each component represents an integrability condition which must be satisfied for the vector field `vf` to be Hamiltonian. If the list is empty, `vf` is unconditionally Hamiltonian.

#### Related Functions

`detools::hasPotential`

#### Details

- A vector field v with 2n components is called Hamiltonian, if there exists a function H(q,p) where q and p are vectors of the length n such that the first n components of v are given by diff(H,p) and the last n components by -diff(H,q). `detools::hasHamiltonian` computes necessary and sufficient conditions for the existence of such a function H; it does not try to determine H.
- `detools::hasHamiltonian` assumes that `q` and `p` represent canonical variables; i.e. it tests only whether `vf` is Hamiltonian with respect to the standard symplectic structure of R^(2n) for some integer n.

#### Example 1

In the following example it is checked whether the vector field describing the motion of a one-dimensional particle under the influence of a force `F` is Hamiltonian.

    >> detools::hasHamiltonian([p, -F(q)], [q], [p])

                                        []

As one can see, in one dimension the motion is Hamiltonian for any force `F`. In higher dimensions this is no longer true, cf. Ex. 2.

#### Example 2

This is basically the same example as Ex. 1 but now in two dimensions.

    >> detools::hasHamiltonian([px, py, - F(x, y), - G(x, y)],
                               [x, y], [px, py])

                       [diff(G(x, y), x) - diff(F(x, y), y)]

Now we obtain an integrability condition which must be satisfied by the force components `F` and `G`.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000