1
$\begingroup$

I have this state: $$p |\text{GHZ}\rangle \langle \text{GHZ}| + (1-p)\rho$$ And after creating this state I have this code lines:

state = p * GHZ+(1-p)* rho
state = p * GHZ + (1 - p) * rho
print(f"final state: \n {state}")
print(cirq.sample_density_matrix(state, indices=[0, 1, 2], repetitions=10))

Now I want to measure this state. I know we have cirq.measure in Cirq But I don't know which kind of measurement is used by this function (and the last line is also doing measurement if I am not wrong??)

cirq.measure(a, b, c)

I have 3 questions

  1. I want to use rotation matrix and measure my state. Do we have rotation matrix in Cirq. Can you please show me how can I measure my state with rotation matrix in Cirq?

  2. I want to choose x and Y randomly and I want to do measurement

  3. Which kind of measurement is used by Cirq.measure() and (cirq.sample_density_matrix(state, indices=[0, 1, 2], repetitions=10))

    cirq.measure(a, b, c) (cirq.sample_density_matrix(state, indices=[0, 1, 2], repetitions=10))

Best and thanks

$\endgroup$
2
  • $\begingroup$ what is meant by GHZ $\endgroup$ – develarist Oct 29 '20 at 0:47
  • $\begingroup$ This is ordinary GHZ state which is created by H gate and CNOT gate $\endgroup$ – quest Oct 29 '20 at 0:59
1
$\begingroup$
  1. cirq.rx ry, rz exist for rotation around X, Y and Z axes on the Bloch sphere

  2. If you have to measure in non-computational bases, you will have to do the rotations yourself. In my answer to previous your question I wrote two versions: one with density matrices the other one with cirq.Circuit.

    • In case of the circuit model you can use circuit.append(cirq.rx(np.pi/3)(a)) for example before the measurement, where a is the first qubit.

    • in case of the density matrix you'll have to calculate the tensored unitaries with cirq.kron and cirq.unitary and then multiply the density as usual: unitary @ density_matrix @ unitary.conj().T. For example:

      # this is rx(pi/3) ⊗ I ⊗ I - the first qubit gets rotated, the other
      # two remains the same
      u = cirq.kron(cirq.unitary(cirq.rx(np.pi/3)), np.eye(2), np.eye(2))
      # this applies the unitary evolution on the state density matrix 
      rotated_state = u @ state @ u.conj().T
    
    
  3. cirq.measure measures in the computational basis. cirq.sample_density_matrix samples in the computational basis repeatedly see reference docs - it simulates "preparing the state and measuring it" multiple times. If you want the state after the measurement then probably cirq.measure_density_matrix is better suited.

$\endgroup$
11
  • $\begingroup$ Thanks for the answer. I could not understand the part of density matrix. Multiply means multiplying ghz part and rho part or multiplay with tensor and unitary part. And after that how can I define angle for rotation matrix?(like the circuit part) $\endgroup$ – quest Oct 29 '20 at 1:51
  • $\begingroup$ And for the circuit part,you wrote a. Does a correspond şubat aor the state? $\endgroup$ – quest Oct 29 '20 at 1:53
  • $\begingroup$ I clarified my points please take a look $\endgroup$ – Balint Pato Oct 29 '20 at 4:11
  • 1
    $\begingroup$ Got it :) Thanks for using Cirq for your thesis! $\endgroup$ – Balint Pato Oct 29 '20 at 23:42
  • 1
    $\begingroup$ If you want measurement statistics of a U unitary in a computational basis you do "apply U and then measure in computational basis". If you want to measure in non-computational basis, but you only can measure in computational basis, that means "apply U then rotate then measure in computational basis". So, you have to cirq.meausre_density_matrix and only after the rotation (not before it). The rotation rotates the frame of reference before the measurement. After the measurement it only rotates the collapsed state which I don't think is what you want. $\endgroup$ – Balint Pato Oct 30 '20 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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