# Phase Kickback - factoring Dirac representation

In section 2.3 of the Qiskit textbook (Phase Kickback), there's an example where a controlled-T gate is applied to $$|1+\rangle$$.

You're asked to attempt the same thing with $$|0+\rangle$$. I've done this by means of statevectors and successfully got the correct answer (that it has no effect): $$\text{Controlled-T}|0+\rangle$$ $$=\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{\frac{i\pi}{4}} \end{pmatrix}\times\frac{1}{\sqrt{2}} \begin{pmatrix}1\\1\\0\\0\\\end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\\0\\0\\\end{pmatrix}$$

The textbook's example (using $$|1+\rangle$$) performs the calculation in Dirac representation - i.e. by factoring out the individual qubits. I decided to try the same thing with the above. Here's what I got: $$|0+\rangle = |0\rangle \otimes \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$ $$=\frac{1}{\sqrt{2}}(|00\rangle + |01\rangle)$$

$$\text{Controlled-T}|0+\rangle =\frac{1}{\sqrt{2}}(|00\rangle + e^{\frac{i\pi}{4}}|01\rangle)$$ $$=|0\rangle \otimes\frac{1}{\sqrt{2}}(|0\rangle + e^{\frac{i\pi}{4}}|1\rangle)$$ When I then multiply that out to get the statevector, I get: $$\frac{1}{\sqrt(2)}\begin{pmatrix}1\\e^{\frac{i\pi}{4}}\\0\\0\\\end{pmatrix}$$ which is clearly different. What am I doing wrong with the algebraic approach?

$$\textrm{Controlled-T} = |0\rangle\langle 0| \otimes I + |1\rangle\langle1| \otimes T$$

Thus, if you apply this to the state $$|\psi \rangle = |0\rangle \bigg( \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \bigg)$$ you have:

\begin{align} \textrm{Controlled-T} |\psi\rangle &= \bigg[|0\rangle\langle 0| \otimes I + |1\rangle\langle1| \otimes T \bigg] |0\rangle \bigg( \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \bigg) \\ &= \bigg[ |0\rangle\langle 0| \otimes I \bigg]|0\rangle \bigg( \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \bigg) + \bigg[ |1\rangle\langle1| \otimes T \bigg]|0\rangle \bigg( \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \bigg) \\ &= |0\rangle \bigg( \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} \bigg) + 0 = |\psi\rangle \end{align}

Thus nothing changed.

• Could you maybe explain why the second term becomes $0$ ? I am definitely missing something here ! Feb 23 '21 at 21:12
• $(|1\rangle \langle 1|)|0\rangle = \vec{0}$. I should have wrote my $0$ with a vector notation earlier. Feb 23 '21 at 22:13

Controlled-T gate has no effect on the $$|01\rangle$$ state (the control qubit is in $$|0\rangle$$ state), rather than add a phase to it.

• While I understand that in principle, it doesn't seem to work with the example in the textbook. They factored out Controlled-T|1+⟩. The steps they used were as follows: $$|1+\rangle=\frac{1}{\sqrt{2}}(|10\rangle+|11\rangle$$ $$Controlled-T|1+\rangle=\frac{1}{\sqrt{2}}(|10\rangle+e^{\frac{i\pi}{4}}|11\rangle)$$ $$=|1\rangle\otimes\frac{1}{\sqrt{2}}(|0\rangle+e^{\frac{i\pi}{4}}|1\rangle)$$ This only makes sense to me if the textbook is using the second qubit as the control, so I was following that pattern. What did I miss? Feb 24 '21 at 7:36
• The first qubit is actually the control; the |10⟩ term didn't change because T gate has no effect on the |0⟩ state, so it's applied in the controlled variant but doesn't have effect. Feb 24 '21 at 8:26
• Right - thank you. This makes a lot more sense now. I'd normally seen the first qubit as the control, but I couldn't understand why the T gate had just been dropped from the $|10\rangle$ state. Upvoted. Feb 24 '21 at 8:42