0
$\begingroup$

I am implementing RQAOA in Cirq. After running regular QAOA to find an optimal state a (This I have done successfully).

I need to calculate $\langle a|Z_iZ_j|a\rangle$ for all $i,j$ in MyGraph.edges().

How should I go about using state a found with the QAOA circuit, to calculate the expectation value of a different circuit with that state?

$\endgroup$
1
  • $\begingroup$ Welcome! Could you add some relevant links/code upon which others can build up upon? $\endgroup$ Mar 15, 2021 at 11:31

1 Answer 1

1
$\begingroup$

If you've already simulated the final state $|a\rangle$, something like the following should work:

qubits = cirq.LineQubit.range(nqubits)

# qubit order in the observables must match the qubit order in the circuit used to generate |a>
qubit_map = dict(zip(qubits, range(nqubits))) 

for (i, j) in MyGraph.edges():
  # make the Z_i*Z_j observable
  ZiZj = cirq.Z(qubits[i]) * cirq.Z(qubits[j]) 
  # compute desired expectation
  expectation_ZiZj = ZiZj.expectation_from_state_vector(a, qubit_map=qubit_map)

Also in the expression $\langle a | B | a \rangle$, $B$ is generally not a quantum circuit, it needs to be an "observable" (Hermitian operator).

$\endgroup$
1
  • $\begingroup$ Great that is exactly what I needed, thanks @forky40!! $\endgroup$
    – GuusH
    Mar 16, 2021 at 8:54

Your Answer

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

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