1
$\begingroup$

How do we construct a matrix that takes into account whether the first qubit is set?

I am trying to construct the controlled-V matrix, but there is no quantum computational paper that describes it so I am looking at CNOT and wondering how the matrix for CNOT determines whether the first bit is set (to apply the NOT part)

Could somebody help?

$\endgroup$
  • 2
    $\begingroup$ consider getting a text-book on quantum computation, e.g., Quantum Computation and Quantum Information by Nielsen and Chuang. These basic ideas are usually explained in textbooks, not in research papers. $\endgroup$ – Ran G. Dec 16 '15 at 3:26
  • $\begingroup$ @RanG. I'd strongly recommend against Nielsen and Chuang. When I couldn't understand their description of quantum mechanics, I thought I was just being dim. When I couldn't understand their description of Turing machines, I concluded that the book is just really badly written. $\endgroup$ – David Richerby Dec 16 '15 at 23:01
3
$\begingroup$

For any gate $U_n$ on $n$-qubits, you can create a controlled version by taking

$$\text{c-}U_n = \left (\begin{matrix} I_n & 0 \\ 0 & U_n \end{matrix}\right)$$

where $I_n$ is the identity matrix (of the same dimension as $U_n$). Note that this gate works on $n+1$ qubits, where the first serves as the control bit.

This should work because the controlled gate is required to satisfy

  • $\text{c-}U_n |0\rangle|x\rangle = |0\rangle|x\rangle $, and
  • $\text{c-}U_n |1\rangle|x\rangle = |1\rangle(U_n|x\rangle) $

where $|x\rangle$ is an $n$-qubit state. You should be able to check that the above matrix satisfies exactly this.

$\endgroup$
3
$\begingroup$

If you're ever not sure how to turn an operation into a matrix, just do it case by case.

Based on the paper you linked from another question, I'm guessing that your $V$ gate is a square-root-of-NOT gate. That is to say, $V = \sqrt{X} = \sqrt{\begin{bmatrix} 0&1\\1&0 \end{bmatrix}} \ni \frac{1}{2} \begin{bmatrix} 1+i & 1-i \\ 1-i & 1+i \end{bmatrix}$

We need to know what our operation does in every case. Suppose we have a state $\left| AB \right\rangle$ and we're controlling based on $A$ and applying our controlled $V$ gate to $B$. Then we find that:

  • If $\left| AB \right\rangle = \left| 00 \right\rangle$ then the output should be $\left| 00 \right\rangle$

  • If $\left| AB \right\rangle = \left| 01 \right\rangle$ then the output should be $\left| 01 \right\rangle$

  • If $\left| AB \right\rangle = \left| 10 \right\rangle$ then the output should be $\frac{1+i}{2} \left| 10 \right\rangle + \frac{1-i}{2} \left| 11 \right\rangle$

  • If $\left| AB \right\rangle = \left| 11 \right\rangle$ then the output should be $\frac{1-i}{2} \left| 10 \right\rangle + \frac{1+i}{2} \left| 11 \right\rangle$

Now we need to decide on a mapping between our kets and a vector. Let's say that $x \left| 00 \right\rangle + y \left| 01 \right\rangle + z \left| 10 \right\rangle + t \left| 11 \right\rangle$ maps to $\begin{bmatrix}x\\y\\z\\t\end{bmatrix}$. That is to say, we go in big-endian order.

We have all the elements we need to make the matrix now. Progress by:

  • Arranging the inputs in the order we decided on (i.e. 00 then 01 then 10 then 11)
  • Mapping each input's output to a column vector
  • Row-wise concatenating the output columns into a matrix

Our outputs are $\left|00\right\rangle = \begin{bmatrix} 1\\0\\0\\0 \end{bmatrix}$, $\left|01\right\rangle = \begin{bmatrix} 0\\1\\0\\0 \end{bmatrix}$, $\left|10\right\rangle = \begin{bmatrix} 0\\0\\\frac{1+i}{2}\\\frac{1-i}{2} \end{bmatrix}$, and $\left|10\right\rangle = \begin{bmatrix} 0\\0\\\frac{1-i}{2}\\\frac{1+i}{2} \end{bmatrix}$ so our matrix for a controlled-$V$ is:

$\begin{bmatrix} 1&0&0&0\\0&1&0&0\\0&0&\frac{1+i}{2}&\frac{1-i}{2}\\0&0&\frac{1-i}{2}&\frac{1+i}{2} \end{bmatrix}$

As you can see, it's basically just a matter of replacing a sub-section of an identity matrix with our target operation. Things get a bit more complicated when there's more qubits, because the interior matrix values get spread out and rearranged and repeated depending on where the controls are and how many uninvolved qubits there are, but you can always fall back on brute force if you're not sure.

(My personal method for computing the matrices of controlled operations is a mathematical hack of the tensor product that special-cases a sentinel value representing "controlled".)

$\endgroup$

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.