0
$\begingroup$

Is there a convenient way in Qiskit to calculate the expectation value for a non-local operator, i.e. I would like to calculate:

$$ \langle \Psi|O|\Psi \rangle $$

More precisely, I would like to calculate the expectation value for an Operator that can be described by the following circuit:

operator_circ = QuantumCircuit(4)
operator_circ.x(0)
operator_circ.cz([1, 1, 2], [2, 3, 3])

I am currently doing the following to calculate the expectation value:

operator = Operator(operator_circ)
#Where psi is some quantumstate/quantumcircuit
psi.save_expectation_value(operator, range(4))

But I am afraid, that this is not what I want since when I look into the decomposition of the Operator it consists of some multiplexers that in turn consists of $CCX$ gates and a gate called squ_dg. However, what I would like is to calculate the expectation value w.r.t. the decomposition of the operator circuit into summed weighted local Pauli.

Ideally some function expresses the $CZ$ gate like so:

$$ CZ_{12} = \frac{1}{2} (I_1 \otimes I_2 + I_1 \otimes Z_2 + Z_1 \otimes I_2 - Z_1 \otimes Z_2) $$

and then calculates the expectation value over the sums of weighted Paulis on the right hand side.

Or is it the same as just using the afformentioned code? What would be the best practice in Qiskit in this case?

$\endgroup$
1
  • $\begingroup$ I am not sure I understand what is that you wish for. save_expectation_value saves the expectation value of an hermitian operator ($O$ in that case) with respect to a statevector ($|\Psi\rangle$ in that case). Why would we care about different decompositions of $O$? $\endgroup$
    – Ohad
    Oct 2, 2022 at 7:22

1 Answer 1

0
$\begingroup$

Looking deeper into the source code I found out that any Operator always gets internally transformed into a SparsePauliOp, i.e. a representation of weighted (sparse) Paulis which is exactly what I wanted.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.