Can anyone explain me the behaviour of these two circuits? They contain Hadmard and rotation gates before the Toffoli gate.

enter image description here

Results of simulation: enter image description here

  • $\begingroup$ Welcome to QCSE! What's your question? As you said, between the barriers you have a toffoli. It looks like more context can help with an explanation. $\endgroup$
    – luciano
    Nov 3 '20 at 21:01
  • $\begingroup$ @luciano Thank you, I just saw a question containing this circuits, unfortunately I don't have more context, only I can provide the simulation result for circuits $\endgroup$
    – Farhad
    Nov 3 '20 at 21:10
  • $\begingroup$ In a notebook code __ $\endgroup$
    – Farhad
    Nov 3 '20 at 21:17

In the first circuit after Hadamard gates (I suppose that initial state is $|000\rangle$ and I will use Qiskit's convention for labeling the qubits $|q_2 q_1 q_0 \rangle$):

$$|000\rangle \xrightarrow[]{\text{Hadamards}} \frac{1}{2}|0\rangle(|00\rangle + |01\rangle+|10\rangle + |11\rangle)$$

The $R_x(0) = I$, so it does noting. Then comes Toffoli gate (apply $X$ gate on the $q_2$ qubit if the other two (control qubits) are in $|1\rangle$ state):

$$\xrightarrow[]{\text{Toffoli}} \frac{1}{2}|0\rangle(|00\rangle + |01\rangle+|10\rangle) + \frac{1}{2}|111\rangle$$

In the second circuit $R_x(\pi) = -iX$ (we can neglect $-i $ term because it is a global phase here) and the combained action of Hadamards plus $R_x(\pi)$

$$|000\rangle \xrightarrow[]{\text{Hadamards + }R_x(\pi)} \frac{1}{2}|1\rangle(|00\rangle + |01\rangle+|10\rangle + |11\rangle)$$

Then Toffoli:

$$\xrightarrow[]{\text{Toffoli}} \frac{1}{2} |1\rangle (|00\rangle + |01\rangle+|10\rangle) + \frac{1}{2}|011\rangle$$

  • $\begingroup$ No Thank you this is what i'm looking for, but dose your calculation now confirms the simulation or I have trouble reading simulation result!? Because in first case I don't see the '100' $\endgroup$
    – Farhad
    Nov 3 '20 at 21:28
  • $\begingroup$ Or in the second case we don't have '111' $\endgroup$
    – Farhad
    Nov 3 '20 at 21:29
  • $\begingroup$ @Farhad, I edited the answer, the problem was with the labeling convention...Qiskit uses this labeling convention in ket vectors $|q_2 q_1 q_0\rangle$ rather than $|q_0 q_1 q_2\rangle$ that I was using initially. $\endgroup$ Nov 3 '20 at 21:37
  • 1
    $\begingroup$ Thank you for your response $\endgroup$
    – Farhad
    Nov 3 '20 at 21:39
  • $\begingroup$ @Farhad, you are welcome :). I just want to suggest to rename the question with this title "Two circuits with Toffoli, Hadamard and $R_x$ gates". I think this title better describes the question. $\endgroup$ Nov 3 '20 at 21:50

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