3
$\begingroup$

I am trying to understand how the quantum gates work, so I started with the simplest one, the Pauli X gate.

I get that it turns $|0\rangle$ into $|1\rangle$ and $|1\rangle$ to $|0\rangle$.

So my question is how do I read its matrix:

\begin{equation} X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \end{equation}

What maps to it?

$\endgroup$
  • $\begingroup$ Welcome to quantum computing SE! Does this question look like what you want to know? If not, what's the difference between that question (and the answers) and what you're looking for? $\endgroup$ – Mithrandir24601 Apr 30 at 18:04
  • 2
    $\begingroup$ @Mithrandir24601 Thanks for the welcoming. For starters, the question isnt exactly on my experience level! I am only now past getting the besic concepts in QC. So the question and answers are not very related to this(from my POV) $\endgroup$ – Aleksandar Kostovic Apr 30 at 18:43
3
$\begingroup$

Lets understand this first using Bra-Ket notation then we move on to answering : what does a matrix maps by just looking at it.

Lets get some basics out of the way, the vectors $\vert 0 \rangle$ and $\vert 1 \rangle$ are represented by,

\begin{equation} \vert 0 \rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \ \ \ \ \ \& \ \ \ \vert 1 \rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \end{equation}

This implies, \begin{equation} \vert 0 \rangle \langle 1\vert = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \ \ \ \ \ \& \ \ \ \vert 1 \rangle \langle 0\vert = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix}. \end{equation}

Now, I can write my $X$ gate as, \begin{equation} X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} + \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix} = \vert 0 \rangle \langle 1\vert + \vert 1 \rangle \langle 0\vert . \end{equation}

The term $\vert 1 \rangle \langle 0\vert$ maps $\vert 0 \rangle \rightarrow \vert 1 \rangle$, and the term $\vert 0 \rangle \langle 1\vert$ maps $\vert 0 \rangle \rightarrow \vert 1 \rangle$. You can see this by:

\begin{equation} \left(\vert 0 \rangle \langle 1 \vert\right) \vert 1\rangle = \vert 0 \rangle \ \ \ \ \ \& \ \ \ \left(\vert 1 \rangle \langle 0 \vert\right) \vert 0\rangle = \vert 1 \rangle. \end{equation}

Given a matix you can always write it in this bra-ket notation, and easily see how it maps.

As you gain experience working with these it is easy to see that a general matrix pictorially can be represented as, \begin{equation} \begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix} a\vert 0 \rangle\langle 0 \vert & b \vert 0 \rangle\langle 1 \vert \\ c\vert 1 \rangle\langle 0 \vert & d\vert 1 \rangle\langle 1 \vert \end{bmatrix} \end{equation} Note the word pictorially, cause the way I wrote it, in standard text it would imply a $4\times4$ matrix. Now given a matrix you can easily work out how each of the non-zero term acts on the basis states $\vert 0 \rangle, \vert 1 \rangle$ ans see where the matrix maps to.

For example, \begin{equation} Z = \begin{bmatrix}1 & 0 \\ 0 & -1 \end{bmatrix} \end{equation} has non-zero terms $\vert 0 \rangle\langle0 \vert$ which maps $\vert 0 \rangle \rightarrow \vert 0 \rangle$, and $-\vert 1 \rangle\langle1 \vert$ which maps $\vert 1 \rangle \rightarrow -\vert 1 \rangle$.

Now a homework for you, Understand the mapping of Hadamard gate and then move on to understand $CNOT$ gate.

Note: I did not worry about what $\vert 1 \rangle \langle 0\vert$ maps $\vert 1 \rangle$ to, cause of orthogonality.

EDIT : After writing this I realized maybe you are asking the following

Lets say someone gives you a mapping and ask you to find the matrix that applies the said mapping. Note that $$ \vert x \rangle \langle b \vert $$ maps $\vert b \rangle $ to $\vert x \rangle$. So as an example if one asks you find the matrix that maps $\vert 0 \rangle \rightarrow (\vert 0 \rangle + \vert 1 \rangle)/\sqrt{2}$ and $\vert 1 \rangle \rightarrow (\vert 0 \rangle - \vert 1 \rangle)/\sqrt{2}$ you can easily write the matrix being

$$ \frac{\vert 0 \rangle + \vert 1 \rangle}{\sqrt{2}}\langle 0 \vert + \frac{\vert 0 \rangle - \vert 1 \rangle}{\sqrt{2}}\langle 1 \vert $$

$$ =\frac{1}{\sqrt{2}}(\vert 0 \rangle\langle 0 \vert + \vert 0 \rangle\langle 1 \vert + \vert 1 \rangle\langle 0 \vert - \vert 1 \rangle\langle 1 \vert) = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & 1 \\ 1 & -1 \end{bmatrix} $$

$\endgroup$
  • $\begingroup$ Thank you very much for your answer! Its now pretty clear to me how it all works. BTW, is there an typo when you wrote $d\vert 1 \rangle\langle 01 \vert$ and shouldnt that be $d\vert 1 \rangle\langle 1 \vert$ ? $\endgroup$ – Aleksandar Kostovic May 1 at 7:10
  • $\begingroup$ You are welcome! And thanks for pointing out the typo. $\endgroup$ – Hemant May 1 at 8:33
  • $\begingroup$ Hi again, i thought i understood but turns out i dont. So my question is how does this happen: \begin{equation} \vert 0 \rangle \langle 1\vert = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \ \ \ \ \ \& \ \ \ \vert 1 \rangle \langle 0\vert = \begin{bmatrix} 0 & 0 \\ 1 & 0 \end{bmatrix}. \end{equation} how does $\vert 0 \rangle \langle 1\vert$ and $\vert 1 \rangle \langle 0\vert$map to matrix? Thanks! $\endgroup$ – Aleksandar Kostovic May 1 at 17:11
  • 1
    $\begingroup$ @AleksandarKostovic: If you know what column-vectors are represented by $\lvert 0 \rangle$ and $\lvert 1 \rangle$, and you know what row-vectors are represented by $\langle 0 \rvert$ and $\langle 1 \rvert$, then you should be able to see how that works by simple matrix multiplication. There is no mystery in this case --- it's all just basic matrix algebra. $\endgroup$ – Niel de Beaudrap May 1 at 17:19
  • $\begingroup$ Thanks! Now i get it :) $\endgroup$ – Aleksandar Kostovic May 1 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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