Skip to content

exact

eigenkit.chemistry.exact

Exact classical reference: dense matrix and ground-state energy of a qubit Observable. For validating VQE on small systems (exponential cost — keep n_qubits small).

dense_hamiltonian(observable, n_qubits, offset=0.0)

The 2**n_qubits × 2**n_qubits matrix of observable + offset * I.

Qubit 0 is the most significant factor of the tensor product, which matches the ordering of basis states in the simulators.

Parameters:

Name Type Description Default
observable Observable

The qubit operator.

required
n_qubits int

The number of qubits.

required
offset float

The constant (identity) term that the mapping returned separately, added back to the energy. For a molecule, it includes the nuclear repulsion, in Hartree.

0.0

Returns:

Type Description
ndarray

The matrix, as a complex NumPy array.

exact_ground_state_energy(observable, n_qubits, offset=0.0)

The lowest eigenvalue of observable + offset * I, by dense diagonalisation.

Parameters:

Name Type Description Default
observable Observable

The qubit operator.

required
n_qubits int

The number of qubits.

required
offset float

The constant (identity) term that the mapping returned separately, added back to the energy. For a molecule, it includes the nuclear repulsion, in Hartree.

0.0

Returns:

Type Description
float

The ground-state energy.