Quantum Teleportation (Part 3): Implementation
Let’s implement and verify the teleporation protocol following the procedure we discussed throughout previous parts.
First we need to create an arbitrary quantum state. Trong has been curious about the combined effect of rotation gates about the x, y, and z axes. So, he decides to apply three distinct rotation gates, each as a rotation of 60 degrees around one coordinate axis acting on a qubit currently in the Hadamard state $|-\rangle$. All of these steps are wrapped up in the ‘initializeFirstQubit’ operation.
|
|
Now it's time to play teleporting. I'll also show the circuit diagram here ahead of time to make it easy for you to follow.
|
|
The final is a program driver that runs our main operation $10000$ times and return probabilities, i.e. the squares of probability amplitudes.
|
|
Now is your turn. In order to verify our programming result, you need to find out the state created by ‘initializeFirstQubit’. Some Python coding or calculating with pencil and paper, you can get your hand dirty by one way or the other. The matrix formulas for the rotations are as follows
$$R_x(\theta) = \begin{bmatrix} \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} \\ \cos{\frac{\theta}{2}} & \cos{\frac{\theta}{2}}\end{bmatrix}, R_y(\theta) = \begin{bmatrix} \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} \\ \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{bmatrix}, R_z(\theta) = \begin{bmatrix} e^{-\frac{i\theta}{2}} & 0 \\ 0 & e^{\frac{i\theta}{2}} \end{bmatrix}$$Do it, don’t be a lazy ass like my servant.
And here’s the resulting coefficients $$R_z(\frac{\pi}{3})R_y(\frac{\pi}{3})R_x(\frac{\pi}{3})|-\rangle \approx 0.9659|0\rangle - 0.2588|1\rangle$$ It’s easy to see the displayed results get in line with our calculation. So, the code works as expected. Feel free to experiment with the here.