# Building a matrix corresponding to the teleportation circuit

I'm trying to build the matrix that corresponds to this quantum teleportation circuit, but it never works when I test it in the quirk simulator, I tried finding the matrix corresponding to every part of the circuit and then multiplying but it never works, anyone knows what I might be doing wrong? When I was calculating the matrices I didn't consider the measurement gates.

• And what are you doing? Commented Dec 13, 2018 at 19:27
• Based on the fact that you can decompose a unitary matrix U on a multiplication of two level matrices, i'm going the reverse way by calculating the 8x8 matrix corresponding to each section of the circuit and multiplying them to get the matrix corresponding to the circuit, you can see this method in page 189 in the Quantum Computation book by Nielsen. Commented Dec 13, 2018 at 22:10
• Great. But how should we know where your mistake lies if you don't explain us what you are doing? You should explain step by step what you are doing. Commented Dec 13, 2018 at 22:24
• for example, in the frist H gate a used the tensor product I x H x I to get the 8x8 matrix of the section of the circuit, then I multiplied them all and got what should be the matrx corresponding to the circuit. Other method that I tried was the shown in the frist answer, this generates a matrix that creates the expected states after the teleportation, but still does not work in this simulator Commented Dec 14, 2018 at 17:43
• There is no way to tell your mistake if you don't give all details of what you did - except coincidentally. Commented Dec 14, 2018 at 19:10

## 1 Answer

Since the quantum teleportation circuit has three qbits, the matrix at each step is 8x8 and thus has 64 elements; this is pretty clunky to type out in its entirety, so I'll just walk you through step by step and you can derive the full matrix for a specific step if you want. Given a qbit we want to teleport:

$$|\psi\rangle = \begin{bmatrix} \alpha \\ \beta \end{bmatrix}$$

the operations are as follows:

$$H_2C_{2,1}C_{1,0}H_1 \left ( \begin{bmatrix} \alpha \\ \beta \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0\end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0\end{bmatrix} \right ) = H_2C_{2,1}C_{1,0} \left ( \begin{bmatrix} \alpha \\ \beta \end{bmatrix} \otimes \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0\end{bmatrix} \right ) = H_2C_{2,1} \left (\begin{bmatrix} \alpha \\ \beta \end{bmatrix} \otimes \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} \right ) = H_2 \left ( \frac{1}{\sqrt{2}} \begin{bmatrix} \alpha \\ 0 \\ 0 \\ \alpha \\ 0 \\ \beta \\ \beta \\ 0 \end{bmatrix} \right ) = \frac{1}{2} \begin{bmatrix} \alpha \\ \beta \\ \beta \\ \alpha \\ \alpha \\ -\beta \\ -\beta \\ \alpha \end{bmatrix}$$

This is the vector directly before the first two qbits are measured. Note we can write it as follows:

$$\frac{1}{2} \begin{bmatrix} \alpha \\ \beta \\ \beta \\ \alpha \\ \alpha \\ -\beta \\ -\beta \\ \alpha \end{bmatrix} = \frac{1}{2} \left ( |00\rangle \otimes \begin{bmatrix} \alpha \\ \beta \end{bmatrix} + |01\rangle \otimes \begin{bmatrix} \beta \\ \alpha \end{bmatrix} + |10\rangle \otimes \begin{bmatrix} \alpha \\ -\beta \end{bmatrix} + |11\rangle \otimes \begin{bmatrix} -\beta \\ \alpha \end{bmatrix} \right )$$

We can then apply the intuitive "cancel and normalize" approach to measurement for each of the four possible measurement outcomes, which I outline in this answer. It should then become clear how applying the final $$X$$ and $$Z$$ gates (depending on measurement outcomes) will lead to the rightmost qbit taking on the value of $$|\psi\rangle$$.

If you'd like a more advanced account of how measurement works in quantum teleportation, you can also see an approach using the density operator which I go over here.

• Thank you! I used this method and calculated a matrix that mathematically works fine, but it doesn't work in the simulator I mentioned, I think it might be the simulator itself, but I'm still not sure, do you know any way I can test this matrix? Commented Dec 13, 2018 at 22:08
• What did you expect to happen in the simulator and what actually happened instead? Commented Dec 13, 2018 at 22:52
• when we use the example that the simulator gives us of a Teleportation circuit, it shows us that the message is being sent by ploting it on two Bloch Spheres, before and after the circuit, when I use the same message, the second Bloch Sphere isn't the same as the first, meaning that the message wasn't sent Commented Dec 14, 2018 at 17:38
• sorry for reviving the old question but shouldnt it be $$H_{1}C_{1,0}C_{2,1}H_{2}$$ given that matrix multiplication is not commutative? Commented Apr 10, 2022 at 20:24
• @Blackwidow what does commutativity have to do with it? The operators are consumed from right to left. Commented Apr 10, 2022 at 22:47