4

Assume one has a QuantumCircuit object and a list of SparsePauliOp. How do I calculate their expectation values using the MPS simulator in Qiskit 1.0?

I would like to perform a simple VQE-type measurement (not phase estimation or anything like that, just estimating individually term by term). Ideally, I would like the commuting terms to be estimated simultaneously (at least, the trivially commuting products of Zs).

How do I do this?

Also, for StateVector I currently use the following:

simulator = StatevectorSimulator()
qc_transpiled = transpile(qc, simulator)
job = simulator.run(qc_transpiled)
result = job.result()
statevector = result.get_statevector(qc_transpiled)
return np.array([statevector.expectation_value(obs) for obs in observable])

Can this be improved in any way?

mavzolej
  • 2,271
  • 9
  • 18

0 Answers0