0
$\begingroup$

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.

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

$\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}}$ .

The result doesn't differ; only how it's displayed in comparison to your manual calculation does.

| improve this answer | |
$\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.