In mathematics, a **Hamiltonian matrix** is a 2*n*-by-2*n* matrix A such that *JA* is symmetric, where J is the skew-symmetric matrix

and *I _{n}* is the n-by-n identity matrix. In other words, A is Hamiltonian if and only if (

Suppose that the 2*n*-by-2*n* matrix A is written as the block matrix

where a, b, c, and d are n-by-n matrices. Then the condition that *A* be Hamiltonian is equivalent to requiring that the matrices *b* and *c* are symmetric, and that *a* + *d*^{T} = 0.^{[1]}^{[2]} Another equivalent condition is that *A* is of the form *A* = *JS* with *S* symmetric.^{[2]}^{: 34 }

It follows easily from the definition that the transpose of a Hamiltonian matrix is Hamiltonian. Furthermore, the sum (and any linear combination) of two Hamiltonian matrices is again Hamiltonian, as is their commutator. It follows that the space of all Hamiltonian matrices is a Lie algebra, denoted sp(2*n*). The dimension of sp(2*n*) is 2*n*^{2} + *n*. The corresponding Lie group is the symplectic group Sp(2*n*). This group consists of the symplectic matrices, those matrices A which satisfy *A*^{T}*JA* = *J*. Thus, the matrix exponential of a Hamiltonian matrix is symplectic. However the logarithm of a symplectic matrix is not necessarily Hamiltonian because the exponential map from the Lie algebra to the group is not surjective.^{[2]}^{: 34–36 }^{[3]}

The characteristic polynomial of a real Hamiltonian matrix is even. Thus, if a Hamiltonian matrix has λ as an eigenvalue, then −λ, λ^{*} and −λ^{*} are also eigenvalues.^{[2]}^{: 45 } It follows that the trace of a Hamiltonian matrix is zero.

The square of a Hamiltonian matrix is skew-Hamiltonian (a matrix A is skew-Hamiltonian if (*JA*)^{T} = −*JA*). Conversely, every skew-Hamiltonian matrix arises as the square of a Hamiltonian matrix.^{[4]}

As for symplectic matrices, the definition for Hamiltonian matrices can be extended to complex matrices in two ways. One possibility is to say that a matrix A is Hamiltonian if (*JA*)^{T} = *JA*, as above.^{[1]}^{[4]} Another possibility is to use the condition (*JA*)^{*} = *JA* where the superscript asterisk ((⋅)^{*}) denotes the conjugate transpose.^{[5]}

Let V be a vector space, equipped with a symplectic form Ω. A linear map is called **a Hamiltonian operator** with respect to Ω if the form is symmetric. Equivalently, it should satisfy

Choose a basis *e*_{1}, …, *e*_{2n} in V, such that Ω is written as . A linear operator is Hamiltonian with respect to Ω if and only if its matrix in this basis is Hamiltonian.^{[4]}