So I am reading this book and I found this worked out example which I didn't get. If you understand these bits of pieces, can you please let me know.

Question: enter image description here

Answer: enter image description here

enter image description here

  1. Why is there two H over here? I thought it would be just H * Cnot?
  2. Where from do we get these representations?

  • $\begingroup$ We will close this question, please ask your questions with more clarity in two separate questions. $\endgroup$ Jan 22, 2021 at 14:41
  • 1
    $\begingroup$ we strongly discourage screenshots of text in stackexchange sites. Moreover, every post should contain a single, laser-focused question. If you could edit the question accordingly, it might get reopened. I'd also add to the mix that titles explaining the specific issue one is facing are preferable. $\endgroup$
    – glS
    Jan 25, 2021 at 12:31

2 Answers 2


If $\left|\psi\right> = \alpha \left|0\right> + \beta \left|1\right>$, then $\alpha = \left<0|\psi\right>$ and $\beta = \left<1|\psi\right>$. A 1-qubit unitary operator can be written as $U = a\left|0\right>\left<0\right| + b\left|0\right>\left<1\right| + c\left|1\right>\left<0\right| + d\left|1\right>\left<1\right|$ and this will correspond to a matrix $\begin{pmatrix}a & b\\c & d\end{pmatrix}$: to see this, notice that through the projection form $U \left|\psi\right> = (a \left<0|\psi\right> + b \left<1|\psi\right>)\left|0\right> + (c\left<0|\psi\right> + d\left<1|\psi\right>)\left|1\right>$. To get the values of the matrix out of $U$ and bras and kets of the computational basis states, notice $U\left|0\right> = a\left|0\right> + c\left|1\right>$ and $U\left|1\right> = b\left|0\right> + d\left|1\right>$: from this, the general matrix form can be given as $U = \begin{pmatrix}\left<0\right|U\left|0\right> & \left<0\right|U\left|1\right> \\\left<1\right|U\left|0\right> & \left<1\right|U\left|1\right> \end{pmatrix}$: this gives the answer to your second question when $X$ is said operator.

For the other question, if $T = \begin{pmatrix}\left<+|0\right> & \left<+|1\right> \\\left<-|0\right> & \left<-|1\right> \end{pmatrix}$, then an operator $U$'s form in the new basis is given by $U^T = \begin{pmatrix}\left<+\right|U\left|+\right> & \left<+\right|U\left|-\right> \\\left<-\right|U\left|+\right> & \left<-\right|U\left|-\right> \end{pmatrix}$, and it represents the operation's matrix when $\left|+\right>$ and $\left|-\right>$ are treated as $\begin{pmatrix}1 \\0\end{pmatrix}$ and $\begin{pmatrix}0 \\ 1\end{pmatrix}$ instead of $\left|0\right>$ and $\left|1\right>$. Then, $U^T = T U T^{-1}$ since $T^{-1}$ turns the representation in terms of the new basis back to its representation in the computational basis, $U$ runs the operator in the computational basis, and then $T$ converts it back to the new basis. As stated in the text, $H$ is its own inverse, so $H U_{NOT}H^{-1} = HU_{NOT}H$.

  • $\begingroup$ Thanks a lot for the answer. First part is clear but the operation of U's form on the original basis is performed this is just the "TUT'" U part right? What are the roles of those T's? $\endgroup$
    – user27286
    Dec 23, 2020 at 21:02
  • $\begingroup$ Edited for more clarity. $\endgroup$ Dec 23, 2020 at 23:55
  • $\begingroup$ I dont know what to say. Now if I say this, I guess you will get angry but then an operator U's form in the new basis is given by UT Why is it U^T? Seriously I am not getting it. You have wrote a great answer but idk why I am not getting it, $\endgroup$
    – user27286
    Dec 24, 2020 at 8:25
  • $\begingroup$ Can you please clarify a bit sir? $\endgroup$
    – user27286
    Dec 24, 2020 at 11:16
  • $\begingroup$ The explicit name $U^T$ is just notation, there's no powering implied by the superscript, just establishing that $U$ has been adjusted related to $T$. As for why that particular matrix has the effect stated after it, it's the same as the computational basis form from the first part of the question but with the new basis states replacing the old ones. $\endgroup$ Dec 24, 2020 at 18:31

Joseph's answer explains a lot of this already but I just want to give a much simpler answer in case others have the same question:

"Why is there two H over here? I thought it would be just H * Cnot?"

To put the $X$ matrix into the $H$ basis, simply calculate $H^{-1}XH$ as you can see here. Since $H^{-1} = H$, the expression is as given in the answer you found in that book :)

"Where from do we get these representations?"

In the basis containing $|0\rangle$ and $|1\rangle$, each of the 4 elements of the $X$ matrix will be given by $\langle 0| X |0\rangle$, $\langle 0| X |1\rangle$ , $\langle 1| X |0\rangle$, $\langle 1| X |1\rangle$ int he exact positions shown in the screenshot you gave us. If you do the matrix multiplication of a row vector, times a matrix, times a column vector (from left-to-right), combined with knowledge of how "Dirac notation works", you'll see why this is the case :).


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