Suppose I have a register(qs) of 3 qubits (first 2 being used solely for control, the last one is the input) . The first two control qubits are in the |+> state and the state of the 3rd input is unknown. Let it be a|0> + b|1>.
Now I apply CCNOT(qs[0],qs[1],qs[2]) so their combined state becomes 0.5(a,b,a,b,a,b,b,a) in Transposed matrix form [Please correct if I'm wrong here] . Now I apply S-gate to the 3rd qubit which transforms |1> -> i|1> .
I am unable to guess the state of the combined state of 'qs' now.
What I thought:
- One logic is to multiply every state by 'i' if it has the form
|XY1>so the combined state becomes0.5(a,ib,a,ib,a,ib,b,ia) [Transposed] - Another logic is to find tensor product of
(I x I x S)since I'm not changing the first 2 qubits. Performing this yields a different result which is0.5(a,b,a,b,ia,ib,ib,ia) [Transposed][Again, correct me if I'm wrong].
Which is the correct output after passing through S-gate (if any) ?
The first two qubits can't start in |+> state, since |+> is a single-qubit state. I assume that the starting state of the first two qubits in the register is
0.5 (|00> + |01> + |10> + |11>).Both approaches are correct, because they are different ways to represent the same transformation. The first answer
0.5(a,ib,a,ib,a,ib,b,ia) [Transposed]is correct. Your second answer0.5(a,b,a,b,ia,ib,ib,ia) [Transposed]seems to be obtained by multiplying byS x I x I, i.e., applyingSgate on the first qubit instead of the third one.The tensor product
I x I x Scan be calculated as tensor product ofI x I(which is just a 4x4 identity matrix) andS. The result is an 8x8 matrix which consists of 16 copies ofSmatrix, multiplied by corresponding elements ofI x I:If you multiply the state of the qubits by this matrix, you'll get the same answer as in the first approach.