# qml.qchem.basis_rotation¶

basis_rotation(one_electron, two_electron, tol_factor=1e-05)[source]

Return the grouped coefficients and observables of a molecular Hamiltonian and the basis rotation unitaries obtained with the basis rotation grouping method.

Parameters
• one_electron (array[float]) – one-electron integral matrix in the molecular orbital basis

• two_electron (array[array[float]]) – two-electron integral tensor in the molecular orbital basis arranged in chemist notation

• tol_factor (float) – threshold error value for discarding the negligible factors

Returns

tuple containing grouped coefficients, grouped observables and basis rotation transformation matrices

Return type

tuple(list[array[float]], list[list[Observable]], list[array[float]])

Example

>>> symbols  = ['H', 'H']
>>> geometry = np.array([[0.0, 0.0, 0.0], [1.398397361, 0.0, 0.0]], requires_grad = False)
>>> mol = qml.qchem.Molecule(symbols, geometry)
>>> core, one, two = qml.qchem.electron_integrals(mol)()
>>> coeffs, ops, unitaries = basis_rotation(one, two, tol_factor=1.0e-5)
>>> print(coeffs)
[array([-3.07829375,  1.92254344,  1.15575031]),
array([-9.73801723e-05,  5.59923133e-03,  9.57150297e-05, -5.59756619e-03]),
array([-0.09060523,  0.09060523]),
array([-0.68077716,  1.01246018, -0.66913628,  0.33745327])]


A second-quantized molecular Hamiltonian can be constructed in the chemist notation format following Eq. (1) of [PRX Quantum 2, 030305, 2021] as

$H = \sum_{\alpha \in \{\uparrow, \downarrow \} } \sum_{pq} T_{pq} a_{p,\alpha}^{\dagger} a_{q, \alpha} + \frac{1}{2} \sum_{\alpha, \beta \in \{\uparrow, \downarrow \} } \sum_{pqrs} V_{pqrs} a_{p, \alpha}^{\dagger} a_{q, \alpha} a_{r, \beta}^{\dagger} a_{s, \beta},$

where $$V_{pqrs}$$ denotes a two-electron integral in the chemist notation and $$T_{pq}$$ is obtained from the one- and two-electron integrals, $$h_{pq}$$ and $$h_{pqrs}$$, as

$T_{pq} = h_{pq} - \frac{1}{2} \sum_s h_{pssq}.$

The tensor $$V$$ can be converted to a matrix which is indexed by the indices $$pq$$ and $$rs$$ and eigendecomposed up to a rank $$R$$ to give

$V_{pqrs} = \sum_r^R L_{pq}^{(r)} L_{rs}^{(r) T},$

where $$L$$ denotes the matrix of eigenvectors of the matrix $$V$$. The molecular Hamiltonian can then be rewritten following Eq. (7) of [Phys. Rev. Research 3, 033055, 2021] as

$H = \sum_{\alpha \in \{\uparrow, \downarrow \} } \sum_{pq} T_{pq} a_{p,\alpha}^{\dagger} a_{q, \alpha} + \frac{1}{2} \sum_r^R \left ( \sum_{\alpha, \beta \in \{\uparrow, \downarrow \} } \sum_{pq} L_{pq}^{(r)} a_{p, \alpha}^{\dagger} a_{q, \alpha} \right )^2.$

The orbital basis can be rotated such that each $$T$$ and $$L^{(r)}$$ matrix is diagonal. The Hamiltonian can then be written following Eq. (2) of [npj Quantum Information, 7, 23 (2021)] as

$H = U_0 \left ( \sum_p d_p n_p \right ) U_0^{\dagger} + \sum_r^R U_r \left ( \sum_{pq} d_{pq}^{(r)} n_p n_q \right ) U_r^{\dagger},$

where the coefficients $$d$$ are obtained by diagonalizing the $$T$$ and $$L^{(r)}$$ matrices. The number operators $$n_p = a_p^{\dagger} a_p$$ can be converted to qubit operators using

$n_p = \frac{1-Z_p}{2},$

where $$Z_p$$ is the Pauli $$Z$$ operator applied to qubit $$p$$. This gives the qubit Hamiltonian

$H = U_0 \left ( \sum_p O_p^{(0)} \right ) U_0^{\dagger} + \sum_r^R U_r \left ( \sum_{q} O_q^{(r)} \right ) U_r^{\dagger},$

where $$O = \sum_i c_i P_i$$ is a linear combination of Pauli words $$P_i$$ that are a tensor product of Pauli $$Z$$ and Identity operators. This allows all the Pauli words in each of the $$O$$ terms to be measured simultaneously. This function returns the coefficients and the Pauli words grouped for each of the $$O$$ terms as well as the basis rotation transformation matrices that are constructed from the eigenvectors of the $$T$$ and $$L^{(r)}$$ matrices. Each column of the transformation matrix is an eigenvector of the corresponding $$T$$ or $$L^{(r)}$$ matrix.

Using PennyLane

Development

API

Internals