# State Vector Output for T$|1\rangle$ in Qiskit differs from manual calculation. Why is this so?

The T Gate is defined as $$\begin{bmatrix} 1&0 \\ 0&e^{i\pi/4} \end{bmatrix} = \begin{bmatrix} 1&0 \\ 0&\frac{\sqrt{2}}{2}(1+i) \end{bmatrix}.$$

So $$\begin{bmatrix} 1&0 \\ 0&\frac{\sqrt{2}}{2}(1+i) \end{bmatrix} \vert 1 \rangle = \begin{bmatrix} 1&0 \\ 0&\frac{\sqrt{2}}{2}(1+i) \end{bmatrix} \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ \frac{\sqrt{2}}{2}(1+i) \end{bmatrix}.$$

But the following code for the T Gate gives a slightly different output:

from qiskit import QuantumCircuit, Aer, execute
from qiskit_textbook.tools import array_to_latex

qc = QuantumCircuit(1)
qc.initialize([0,1],0)  # initialize to |1>
qc.t(0)
display(qc.draw('mpl'))
backend = Aer.get_backend('statevector_simulator')  # simulate the circuit
state = execute(qc,backend).result().get_statevector()  # get final state
array_to_latex(state, pretext="\\text{Output} = ")  # show final state vector


which is $$\begin{bmatrix} 0 \\ \frac{1}{\sqrt{2}}(1+i) \end{bmatrix}.$$

Why do these two results differ? Thanks for any insights.

• Maybe this help... $\dfrac{4}{8} = \dfrac{2}{4} = \dfrac{1}{2}$ – KAJ226 Oct 22 at 22:43

$$\frac{\sqrt{2}}{2}(1+i)$$ = $$\frac{1}{\sqrt{2}}(1+i)$$. To see how this is the case, multiply the numerator and denominator of $$\frac{1}{\sqrt{2}}$$ by $$\frac{\sqrt{2}}{\sqrt{2}}$$ = $$1$$. $$\frac {\sqrt{2}}{\sqrt{2}} \frac{1}{\sqrt{2}} = \frac{\sqrt{2}}{{2}}$$ .