-
Notifications
You must be signed in to change notification settings - Fork 89
Description
I am proposing some modifications to the EGT-CG implementation at qiboml (PR here), and one important point of improvement there is to allow the calculation of expeted values of Hamiltonians in ways more general than uniquely with Hamiltonian.expectation() (see details below). However, since this is a more "core" functionality, I think it's more suitable to have it here on qibo, and just imported for use there.
In some cases, it's useful to represent a Hamiltonian as a linear combination of Pauli words, namely via a list of tuples [(coef, pauli_word)]. As an example, the Heisenberg XXZ model Hamiltonian on n=4 qubits with delta=0.5 is, in this representation, the following list:
[(1.0, 'XXII'),
(1.0, 'IXXI'),
(1.0, 'IIXX'),
(1.0, 'XIIX'),
(1.0, 'YYII'),
(1.0, 'IYYI'),
(1.0, 'IIYY'),
(1.0, 'YIIY'),
(0.5, 'ZZII'),
(0.5, 'IZZI'),
(0.5, 'IIZZ'),
(0.5, 'ZIIZ')]Given this input, we can calculate the expected value of the Hamiltonian either in infinite precision from the state (by building a sparse matrix for each Pauli word separately); or from samples (by performing the appropriate measurements, ideally after performing the grouping of commuting terms). I've implemented both procedures, will do the PR soon.