pyquil icon indicating copy to clipboard operation
pyquil copied to clipboard

Easy interface for getting the matrix form of a PauliTerm/Sum

Open karalekas opened this issue 5 years ago • 2 comments

In PR #867, @jlbosse is looking to extend the PauliTerm/PauliSum interface to include a method for getting its matrix representation. In the unitary_tools module, there exists a function lifted_pauli which seems to accomplish this task, but is not necessarily well-known or well-documented functionality. This issue is for discussing that feature request, and for designing such an interface.

karalekas avatar Aug 25 '19 01:08 karalekas

Some more explanations for the use cases I had in mind:

  1. Finding eigenvalues and eigenvectors of (small) enough PauliSums. This is interesting for example for applications in QAOA or VQE.

  2. Calculating expectation values and variances via <wf|pauli_sum|wf> and <wf|pauli_sum**2|wf> - <wf|pauli_sum|wf>**2. This means, that the matrix form should be tensored up in the same order the wavefunction returned by the WavefunctionSimulator is. Nothe that the expectation value can also be calculated via WavefunctionSimulator.expectation(), but the variance can't. (well it could, but you would need to run the circuit twice)

jlbosse avatar Aug 27 '19 01:08 jlbosse

+1 to this issue. Would be useful to have this functionality easily accessible.

willzeng avatar Apr 20 '20 20:04 willzeng