0

I am trying to create this state: rho = = q . rho_{1,2} + r . rho_{2,3} + s . rho{1,3} + (1-q-r-s) . rho_separable

And I wrote this code:

   import random
import numpy as np
import cirq

circuit, circuit2, circuit3 = cirq.Circuit() p = 0.2 q = 0.1 r = 0.3 alice, bob, charlie = cirq.LineQubit.range(1, 4) rho_12 = circuit.append([cirq.H(alice), cirq.CNOT(alice, bob)]) #circuit.append([cirq.H(alice), cirq.CNOT(alice, bob)]) rho_23 = circuit.append([cirq.H(bob), cirq.CNOT(bob, charlie)]) rho_13 = circuit.append([cirq.H(alice), cirq.CNOT(alice, charlie)]) circuit = rho_12 + rho_23 + rho_13 print(circuit)

In here I have 2 problem:

1)This line is not working: circuit = rho_12 + rho_23 + rho_13

2)I cannot multiply the state with p or q or r. What I mean is that I can't write this line:

rho_12 = circuit.append([cirq.H(alice), cirq.CNOT(alice, bob)]) * q 

Could you please show me how I can write this state?

glS
  • 27,670
  • 7
  • 39
  • 126
quest
  • 704
  • 4
  • 11

1 Answers1

0

You seem to think append is returning a circuit, instead of modifying the circuit you called it on. circuit.append(op) doesn't return anything, it adds an operation to circuit.

alice, bob, charlie = cirq.LineQubit.range(1, 4)
circuit = cirq.Circuit()
circuit.append([cirq.H(alice), cirq.CNOT(alice, bob)])
circuit.append([cirq.H(bob), cirq.CNOT(bob, charlie)]) 
...

Alternatively, you can make a new circuit for each of the pieces and then add them together:

rho_12 = cirq.Circuit(
    cirq.H(alice),
    cirq.CNOT(alice, bob),
)
...
circuit = rho_12 + rho_23 + rho_13
Craig Gidney
  • 47,099
  • 1
  • 44
  • 119