...

/

Simulating an Operation in Python

Simulating an Operation in Python

In this lesson, we will apply quantum gates to the quantum states we've created in NumPy.

So far, we’ve learned how to create single and multi-qubit states. We’ve also learned how to represent quantum gates. In this lesson, we’ll put together both pieces and see how we can apply gates to states.

Recall that gates acting on states are simply a representation of matrix multiplication. Both states and gates are matrices. So, multiplying the two is fairly simple, especially when a single qubit is involved. Things get slightly more complicated for multiple qubits and we will get to that in the second half of the lesson.

Applying a quantum gate to a single qubit

First, let’s start off with applying a gate to a single qubit. Mathematically, an arbitrary gate, say GG, when applied to an arbitrary state ϕ|\phi\rangle, can be represented by the operation GϕG|\phi\rangle. In the case where the Pauli-X gate XX is applied to the state 0|0\rangle, we would get the following output:

X0=[0110][10]=[01]X|0\rangle=\begin{bmatrix}0&1\\1&0\end{bmatrix}\begin{bmatrix}1\\0\end{bmatrix}=\begin{bmatrix}0\\1\end{bmatrix} ...

Access this course and 1400+ top-rated courses and projects.