The Symplectic manifold, denoted $\operatorname{Sp}(2n, \mathbb{F})$, is a closed, embedded, submanifold of $\mathbb{F}^{2n \times 2n}$ that represents transformations into symplectic subspaces which keep the canonical symplectic form over $\mathbb{F}^{2n \times 2n }$ invariant under the standard embedding inner product. The canonical symplectic form is a non-degenerate bilinear and skew symmetric map $\omega\colon \mathbb{F}^{2n} \times \mathbb{F}^{2n} \rightarrow \mathbb{F}$, given by $\omega(x, y) = x^T Q_{2n} y$ for elements $x, y \in \mathbb{F}^{2n}$, with

\[ Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix}.\]

That means that an element $p \in \operatorname{Sp}(2n)$ must fulfill the requirement that

\[ \omega (p x, p y) = x^T(p^TQp)y = x^TQy = \omega(x, y),\]

leading to the requirement on $p$ that $p^TQp = Q$.

The symplectic manifold also forms a group under matrix multiplication, called the $\textit{symplectic group}$. Since all the symplectic matrices necessarily have determinant one, the symplectic group $\operatorname{Sp}(2n, \mathbb{F})$ is a subgroup of the special linear group, $\operatorname{SL}(2n, \mathbb{F})$. When the underlying field is either $\mathbb{R}$ or $\mathbb{C}$ the symplectic group with a manifold structure constitutes a Lie group, with the Lie Algebra

\[ \mathfrak{sp}(2n,F) = \{H \in \mathbb{F}^{2n \times 2n} \;|\; Q H + H^{T} Q = 0\}.\]

This set is also known as the Hamiltonian matrices, which have the property that $(QH)^T = QH$ and are commonly used in physics.

Manifolds.ExtendedSymplecticMetric β€” Type
ExtendedSymplecticMetric <: AbstractMetric

The extension of the RealSymplecticMetric at a point p \in \operatorname{Sp}(2n) as an inner product over the embedding space $ℝ^{2n \times 2n}$, i.e.

\[ \langle x, y \rangle_{p} = \langle p^{-1}x, p^{-1}\rangle_{\operatorname{Fr}} = \operatorname{tr}(x^{\mathrm{T}}(pp^{\mathrm{T}})^{-1}y), \;\forall\; x, y \in ℝ^{2n \times 2n}.\]

Manifolds.RealSymplecticMetric β€” Type
RealSymplecticMetric <: RiemannianMetric

The canonical Riemannian metric on the symplectic manifold, defined pointwise for $p \in \operatorname{Sp}(2n)$ by [Fio11]]

\[\begin{align*} & g_p \colon T_p\operatorname{Sp}(2n) \times T_p\operatorname{Sp}(2n) \rightarrow ℝ, \\ & g_p(Z_1, Z_2) = \operatorname{tr}((p^{-1}Z_1)^{\mathrm{T}} (p^{-1}Z_2)). \end{align*}\]

This metric is also the default metric for the Symplectic manifold.

Manifolds.Symplectic β€” Type
Symplectic{n, 𝔽} <: AbstractEmbeddedManifold{𝔽, DefaultIsometricEmbeddingType}

The symplectic manifold consists of all $2n \times 2n$ matrices which preserve the canonical symplectic form over $𝔽^{2n Γ— 2n} \times 𝔽^{2n Γ— 2n}$,

\[ \omega\colon 𝔽^{2n Γ— 2n} \times 𝔽^{2n Γ— 2n} \rightarrow 𝔽, \quad \omega(x, y) = p^{\mathrm{T}} Q_{2n} q, \; x, y \in 𝔽^{2n Γ— 2n},\]


\[Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix}.\]

That is, the symplectic manifold consists of

\[\operatorname{Sp}(2n, ℝ) = \bigl\{ p ∈ ℝ^{2n Γ— 2n} \, \big| \, p^{\mathrm{T}}Q_{2n}p = Q_{2n} \bigr\},\]

with $0_n$ and $I_n$ denoting the $n Γ— n$ zero-matrix and indentity matrix in $ℝ^{n \times n}$ respectively.

The tangent space at a point $p$ is given by [BZ21]

\[\begin{align*} T_p\operatorname{Sp}(2n) &= \{X \in \mathbb{R}^{2n \times 2n} \;|\; p^{T}Q_{2n}X + X^{T}Q_{2n}p = 0 \}, \\ &= \{X = pQS \;|\; S ∈ R^{2n Γ— 2n}, S^{\mathrm{T}} = S \}. \end{align*}\]


Symplectic(2n, field=ℝ) -> Symplectic{div(2n, 2), field}()

Generate the (real-valued) symplectic manifold of $2n \times 2n$ symplectic matrices. The constructor for the Symplectic manifold accepts the even column/row embedding dimension $2n$ for the real symplectic manifold, $ℝ^{2n Γ— 2n}$.

Manifolds.SymplecticMatrix β€” Type

A lightweight structure to represent the action of the matrix representation of the canonical symplectic form,

\[Q_{2n}(Ξ») = Ξ» \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix} \quad \in ℝ^{2n \times 2n},\]

such that the canonical symplectic form is represented by

\[\omega_{2n}(x, y) = x^{\mathrm{T}}Q_{2n}(1)y, \quad x, y \in ℝ^{2n}.\]

The entire matrix is however not instantiated in memory, instead a scalar $Ξ»$ of type T is stored, which is used to keep track of scaling and transpose operations applied to each SymplecticMatrix. For example, given Q = SymplecticMatrix(1.0) represented as 1.0*[0 I; -I 0], the adjoint Q' returns SymplecticMatrix(-1.0) = (-1.0)*[0 I; -I 0].

Base.exp β€” Method
exp(M::Symplectic, p, X)
exp!(M::Symplectic, q, p, X)

The Exponential mapping on the Symplectic manifold with the RealSymplecticMetric Riemannian metric.

For the point $p \in \operatorname{Sp}(2n)$ the exponential mapping along the tangent vector $X \in T_p\operatorname{Sp}(2n)$ is computed as [WSF18]

\[ \operatorname{exp}_p(X) = p \operatorname{Exp}((p^{-1}X)^{\mathrm{T}}) \operatorname{Exp}(p^{-1}X - (p^{-1}X)^{\mathrm{T}}),\]

where $\operatorname{Exp}(\cdot)$ denotes the matrix exponential.

Base.inv β€” Method
inv(::Symplectic, A)
inv!(::Symplectic, A)

Compute the symplectic inverse $A^+$ of matrix $A ∈ ℝ^{2n Γ— 2n}$. Given a matrix

\[A ∈ ℝ^{2n Γ— 2n},\quad A = \begin{bmatrix} A_{1,1} & A_{1,2} \\ A_{2,1} & A_{2, 2} \end{bmatrix}\]

the symplectic inverse is defined as:

\[A^{+} := Q_{2n}^{\mathrm{T}} A^{\mathrm{T}} Q_{2n},\]


\[Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix}.\]

The symplectic inverse of A can be expressed explicitly as:

\[A^{+} = \begin{bmatrix} A_{2, 2}^{\mathrm{T}} & -A_{1, 2}^{\mathrm{T}} \\[1.2mm] -A_{2, 1}^{\mathrm{T}} & A_{1, 1}^{\mathrm{T}} \end{bmatrix}.\]

Base.rand β€” Method
rand(::SymplecticStiefel; vector_at=nothing,
    hamiltonian_norm = (vector_at === nothing ? 1/2 : 1.0))

Generate a random point on $\operatorname{Sp}(2n)$ or a random tangent vector $X \in T_p\operatorname{Sp}(2n)$ if vector_at is set to a point $p \in \operatorname{Sp}(2n)$.

A random point on $\operatorname{Sp}(2n)$ is constructed by generating a random Hamiltonian matrix $Ξ© \in \mathfrak{sp}(2n,F)$ with norm hamiltonian_norm, and then transforming it to a symplectic matrix by applying the Cayley transform

\[ \operatorname{cay}\colon \mathfrak{sp}(2n,F) \rightarrow \operatorname{Sp}(2n), \; \Omega \mapsto (I - \Omega)^{-1}(I + \Omega).\]

To generate a random tangent vector in $T_p\operatorname{Sp}(2n)$, this code employs the second tangent vector space parametrization of Symplectic. It first generates a random symmetric matrix $S$ by S = randn(2n, 2n) and then symmetrizes it as S = S + S'. Then $S$ is normalized to have Frobenius norm of hamiltonian_norm and X = pQS is returned, where Q is the SymplecticMatrix.

ManifoldDiff.gradient β€” Method
gradient(M::Symplectic, f, p, backend::RiemannianProjectionBackend;
gradient!(M::Symplectic, f, p, backend::RiemannianProjectionBackend;

Compute the manifold gradient $\text{grad}f(p)$ of a scalar function $f \colon \operatorname{Sp}(2n) \rightarrow ℝ$ at $p \in \operatorname{Sp}(2n)$.

The element $\text{grad}f(p)$ is found as the Riesz representer of the differential $\text{D}f(p) \colon T_p\operatorname{Sp}(2n) \rightarrow ℝ$ w.r.t. the Riemannian metric inner product at $p$ [Fio11]]. That is, $\text{grad}f(p) \in T_p\operatorname{Sp}(2n)$ solves the relation

\[ g_p(\text{grad}f(p), X) = \text{D}f(p) \quad\forall\; X \in T_p\operatorname{Sp}(2n).\]

The default behaviour is to first change the representation of the Euclidean gradient from the Euclidean metric to the RealSymplecticMetric at $p$, and then we projecting the result onto the correct tangent tangent space $T_p\operatorname{Sp}(2n, ℝ)$ w.r.t the Riemannian metric $g_p$ extended to the entire embedding space.


  • extended_metric = true: If true, compute the gradient $\text{grad}f(p)$ by first changing the representer of the Euclidean gradient of a smooth extension of $f$, $βˆ‡f(p)$, w.r.t. the RealSymplecticMetric at $p$ extended to the entire embedding space, before projecting onto the correct tangent vector space w.r.t. the same extended metric $g_p$. If false, compute the gradient by first projecting $βˆ‡f(p)$ onto the tangent vector space, before changing the representer in the tangent vector space to comply with the RealSymplecticMetric.
Manifolds.project_normal! β€” Method
project_normal!(::MetricManifold{𝔽,Euclidean,ExtendedSymplecticMetric}, Y, p, X)

Project onto the normal of the tangent space $(T_p\operatorname{Sp}(2n))^{\perp_g}$ at a point $p ∈ \operatorname{Sp}(2n)$, relative to the riemannian metric $g$ RealSymplecticMetric. That is,

\[(T_p\operatorname{Sp}(2n))^{\perp_g} = \{Y \in \mathbb{R}^{2n \times 2n} : g_p(Y, X) = 0 \;\forall\; X \in T_p\operatorname{Sp}(2n)\}.\]

The closed form projection operator onto the normal space is given by [GSAS21]

\[\operatorname{P}^{(T_p\operatorname{Sp}(2n))\perp}_{g_p}(X) = pQ\operatorname{skew}(p^{\mathrm{T}}Q^{\mathrm{T}}X),\]

where $\operatorname{skew}(A) = \frac{1}{2}(A - A^{\mathrm{T}})$. This function is not exported.

Manifolds.symplectic_inverse_times β€” Method
symplectic_inverse_times(::Symplectic, p, q)
symplectic_inverse_times!(::Symplectic, A, p, q)

Directly compute the symplectic inverse of $p \in \operatorname{Sp}(2n)$, multiplied with $q \in \operatorname{Sp}(2n)$. That is, this function efficiently computes $p^+q = (Q_{2n}p^{\mathrm{T}}Q_{2n})q \in ℝ^{2n \times 2n}$, where $Q_{2n}$ is the SymplecticMatrix of size $2n \times 2n$.

ManifoldsBase.change_representer β€” Method
change_representer(::Symplectic, ::EuclideanMetric, p, X)
change_representer!(::Symplectic, Y, ::EuclideanMetric, p, X)

Compute the representation of a tangent vector $ΞΎ ∈ T_p\operatorname{Sp}(2n, ℝ)$ s.t.

\[ g_p(c_p(ΞΎ), Ξ·) = ⟨ξ, η⟩^{\text{Euc}} \;βˆ€\; Ξ· ∈ T_p\operatorname{Sp}(2n, ℝ).\]

with the conversion function

\[ c_p : T_p\operatorname{Sp}(2n, ℝ) \rightarrow T_p\operatorname{Sp}(2n, ℝ), \quad c_p(ΞΎ) = \frac{1}{2} pp^{\mathrm{T}} ΞΎ + \frac{1}{2} pQ ΞΎ^{\mathrm{T}} pQ.\]

Each of the terms $c_p^1(ΞΎ) = p p^{\mathrm{T}} ΞΎ$ and $c_p^2(ΞΎ) = pQ ΞΎ^{\mathrm{T}} pQ$ from the above definition of $c_p(Ξ·)$ are themselves metric compatible in the sense that

\[ c_p^i : T_p\operatorname{Sp}(2n, ℝ) \rightarrow \mathbb{R}^{2n \times 2n}\quad g_p^i(c_p(ΞΎ), Ξ·) = ⟨ξ, η⟩^{\text{Euc}} \;βˆ€\; Ξ· ∈ T_p\operatorname{Sp}(2n, ℝ),\]

for $i \in {1, 2}$. However the range of each function alone is not confined to $T_p\operatorname{Sp}(2n, ℝ)$, but the convex combination

\[ c_p(ΞΎ) = \frac{1}{2}c_p^1(ΞΎ) + \frac{1}{2}c_p^2(ΞΎ)\]

does have the correct range $T_p\operatorname{Sp}(2n, ℝ)$.

ManifoldsBase.change_representer β€” Method
change_representer(MetMan::MetricManifold{𝔽, Euclidean{Tuple{m, n}, 𝔽}, ExtendedSymplecticMetric},
                   EucMet::EuclideanMetric, p, X)
change_representer!(MetMan::MetricManifold{𝔽, Euclidean{Tuple{m, n}, 𝔽}, ExtendedSymplecticMetric},
                    Y, EucMet::EuclideanMetric, p, X)

Change the representation of a matrix $ΞΎ ∈ \mathbb{R}^{2n \times 2n}$ into the inner product space $(ℝ^{2n \times 2n}, g_p)$ where the inner product is given by $g_p(ΞΎ, Ξ·) = \langle p^{-1}ΞΎ, p^{-1}Ξ· \rangle = \operatorname{tr}(ΞΎ^{\mathrm{T}}(pp^{\mathrm{T}})^{-1}Ξ·)$, as the extension of the RealSymplecticMetric onto the entire embedding space.

By changing the representation we mean to apply a mapping

\[ c_p : \mathbb{R}^{2n \times 2n} \rightarrow \mathbb{R}^{2n \times 2n},\]

defined by requiring that it satisfy the metric compatibility condition

\[ g_p(c_p(ΞΎ), Ξ·) = ⟨p^{-1}c_p(ΞΎ), p^{-1}η⟩ = ⟨ξ, η⟩^{\text{Euc}} \;βˆ€\; Ξ· ∈ T_p\operatorname{Sp}(2n, ℝ).\]

In this case, we compute the mapping

\[ c_p(ΞΎ) = pp^{\mathrm{T}} ΞΎ.\]

ManifoldsBase.check_point β€” Method
check_point(M::Symplectic, p; kwargs...)

Check whether p is a valid point on the Symplectic M=$\operatorname{Sp}(2n)$, i.e. that it has the right AbstractNumbers type and $p^{+}p$ is (approximately) the identity, where $A^{+} = Q_{2n}^{\mathrm{T}}A^{\mathrm{T}}Q_{2n}$ is the symplectic inverse, with

\[Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix}.\]

The tolerance can be set with kwargs... (e.g. atol = 1.0e-14).

ManifoldsBase.check_vector β€” Method
check_vector(M::Symplectic, p, X; kwargs...)

Checks whether X is a valid tangent vector at p on the Symplectic M=$\operatorname{Sp}(2n)$, i.e. the AbstractNumbers fits and it (approximately) holds that $p^{T}Q_{2n}X + X^{T}Q_{2n}p = 0$, where

\[Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix}.\]

The tolerance can be set with kwargs... (e.g. atol = 1.0e-14).

ManifoldsBase.distance β€” Method
distance(M::Symplectic, p, q)

Compute an approximate geodesic distance between two Symplectic matrices $p, q \in \operatorname{Sp}(2n)$, as done in [WSF18].

\[ \operatorname{dist}(p, q) β‰ˆ ||\operatorname{Log}(p^+q)||_{\operatorname{Fr}},\]

where the $\operatorname{Log}(\cdot)$ operator is the matrix logarithm.

This approximation is justified by first recalling the Baker-Campbell-Hausdorf formula,

\[\operatorname{Log}(\operatorname{Exp}(A)\operatorname{Exp}(B)) = A + B + \frac{1}{2}[A, B] + \frac{1}{12}[A, [A, B]] + \frac{1}{12}[B, [B, A]] + \ldots \;.\]

Then we write the expression for the exponential map from $p$ to $q$ as

\[ q = \operatorname{exp}_p(X) = p \operatorname{Exp}((p^{+}X)^{\mathrm{T}}) \operatorname{Exp}([p^{+}X - (p^{+}X)^{\mathrm{T}}]), X \in T_p\operatorname{Sp},\]

and with the geodesic distance between $p$ and $q$ given by $\operatorname{dist}(p, q) = ||X||_p = ||p^+X||_{\operatorname{Fr}}$ we see that

\[ \begin{align*} ||\operatorname{Log}(p^+q)||_{\operatorname{Fr}} &= ||\operatorname{Log}\left( \operatorname{Exp}((p^{+}X)^{\mathrm{T}}) \operatorname{Exp}(p^{+}X - (p^{+}X)^{\mathrm{T}}) \right)||_{\operatorname{Fr}} \\ &= ||p^{+}X + \frac{1}{2}[(p^{+}X)^{\mathrm{T}}, p^{+}X - (p^{+}X)^{\mathrm{T}}] + \ldots ||_{\operatorname{Fr}} \\ &β‰ˆ ||p^{+}X||_{\operatorname{Fr}} = \operatorname{dist}(p, q). \end{align*}\]

ManifoldsBase.inner β€” Method
inner(::Symplectic{n, ℝ}, p, X, Y)

Compute the canonical Riemannian inner product RealSymplecticMetric

\[ g_p(X, Y) = \operatorname{tr}((p^{-1}X)^{\mathrm{T}} (p^{-1}Y))\]

between the two tangent vectors $X, Y \in T_p\operatorname{Sp}(2n)$.

ManifoldsBase.inverse_retract β€” Method
inverse_retract(M::Symplectic, p, q, ::CayleyInverseRetraction)

Compute the Cayley Inverse Retraction $X = \mathcal{L}_p^{\operatorname{Sp}}(q)$ such that the Cayley Retraction from $p$ along $X$ lands at $q$, i.e. $\mathcal{R}_p(X) = q$ [BZ21].

First, recall the definition the standard symplectic matrix

\[Q = \begin{bmatrix} 0 & I \\ -I & 0 \end{bmatrix}\]

as well as the symplectic inverse of a matrix $A$, $A^{+} = Q^{\mathrm{T}} A^{\mathrm{T}} Q$.

For $p, q ∈ \operatorname{Sp}(2n, ℝ)$ then, we can then define the inverse cayley retraction as long as the following matrices exist.

\[ U = (I + p^+ q)^{-1}, \quad V = (I + q^+ p)^{-1}.\]

If that is the case, the inverse cayley retration at $p$ applied to $q$ is

\[\mathcal{L}_p^{\operatorname{Sp}}(q) = 2p\bigl(V - U\bigr) + 2\bigl((p + q)U - p\bigr) ∈ T_p\operatorname{Sp}(2n).\]

[BZ21]: > Bendokat, Thomas and Zimmermann, Ralf: > The real symplectic Stiefel and Grassmann manifolds: metrics, geodesics and applications > arXiv preprint arXiv:2108.12447, 2021.

ManifoldsBase.manifold_dimension β€” Method

Returns the dimension of the symplectic manifold embedded in $ℝ^{2n \times 2n}$, i.e.

\[ \operatorname{dim}(\operatorname{Sp}(2n)) = (2n + 1)n.\]

ManifoldsBase.project! β€” Method
project!(::MetricManifold{𝔽,Euclidean,ExtendedSymplecticMetric}, Y, p, X) where {𝔽}

Compute the projection of $X ∈ R^{2n Γ— 2n}$ onto $T_p\operatorname{Sp}(2n, ℝ)$ w.r.t. the Riemannian metric $g$ RealSymplecticMetric. The closed form projection mapping is given by [GSAS21]

\[ \operatorname{P}^{T_p\operatorname{Sp}(2n)}_{g_p}(X) = pQ\operatorname{sym}(p^{\mathrm{T}}Q^{\mathrm{T}}X),\]

where $\operatorname{sym}(A) = \frac{1}{2}(A + A^{\mathrm{T}})$. This function is not exported.

ManifoldsBase.project β€” Method
project(::Symplectic, p, A)
project!(::Symplectic, Y, p, A)

Given a point $p \in \operatorname{Sp}(2n)$, project an element $A \in \mathbb{R}^{2n \times 2n}$ onto the tangent space $T_p\operatorname{Sp}(2n)$ relative to the euclidean metric of the embedding $\mathbb{R}^{2n \times 2n}$.

That is, we find the element $X \in T_p\operatorname{SpSt}(2n, 2k)$ which solves the constrained optimization problem

\[ \operatorname{min}_{X \in \mathbb{R}^{2n \times 2n}} \frac{1}{2}||X - A||^2, \quad \text{s.t.}\; h(X) \colon= X^{\mathrm{T}} Q p + p^{\mathrm{T}} Q X = 0,\]

where $h\colon\mathbb{R}^{2n \times 2n} \rightarrow \operatorname{skew}(2n)$ defines the restriction of $X$ onto the tangent space $T_p\operatorname{SpSt}(2n, 2k)$.

ManifoldsBase.retract β€” Method
retract(::Symplectic, p, X, ::CayleyRetraction)
retract!(::Symplectic, q, p, X, ::CayleyRetraction)

Compute the Cayley retraction on $p ∈ \operatorname{Sp}(2n, ℝ)$ in the direction of tangent vector $X ∈ T_p\operatorname{Sp}(2n, ℝ)$, as defined in by Birtea et al in proposition 2 [BCC20].

Using the symplectic inverse of a matrix $A \in ℝ^{2n \times 2n}$, $A^{+} := Q_{2n}^{\mathrm{T}} A^{\mathrm{T}} Q_{2n}$ where

\[Q_{2n} = \begin{bmatrix} 0_n & I_n \\ -I_n & 0_n \end{bmatrix},\]

the retraction $\mathcal{R}\colon T\operatorname{Sp}(2n) \rightarrow \operatorname{Sp}(2n)$ is defined pointwise as

\[\begin{align*} \mathcal{R}_p(X) &= p \operatorname{cay}\left(\frac{1}{2}p^{+}X\right), \\ &= p \operatorname{exp}_{1/1}(p^{+}X), \\ &= p (2I - p^{+}X)^{-1}(2I + p^{+}X). \end{align*}\]

Here $\operatorname{exp}_{1/1}(z) = (2 - z)^{-1}(2 + z)$ denotes the PadΓ© (1, 1) approximation to $\operatorname{exp}(z)$.



T. Bendokat and R. Zimmermann. The real symplectic Stiefel and Grassmann manifolds: metrics, geodesics and applications, arXiv Preprint, 2108.12447 (2021).
P. Birtea, I. CaΓ§u and D. ComΔƒnescu. Optimization on the real symplectic group. Monatshefte fΓΌr Mathematik 191, 465–485 (2020).
S. Fiori. Solving Minimal-Distance Problems over the Manifold of Real-Symplectic Matrices. SIAM Journal on Matrix Analysis and Applications 32, 938–968 (2011).
B. Gao, N. T. Son, P.-A. Absil and T. Stykel. Riemannian Optimization on the Symplectic Stiefel Manifold. SIAM Journal on Optimization 31, 1546–1575 (2021).
J. Wang, H. Sun and S. Fiori. A Riemannian-steepest-descent approach for optimization on the real symplectic group. Mathematical Methods in the Applied Science 41, 4273–4286 (2018).