3

I'm following the Qiskit textbook. I'm currently here: https://quantum-computing.ibm.com/jupyter/user/qiskit-textbook/content/ch-states/representing-qubit-states.ipynb

Here's an example of my initialization code:

initial_state = [1/sqrt(2), 1j/sqrt(2)]

qc = QuantumCircuit(1)

qc.initialize(initial_state, 0)

state = execute(qc,backend).result().get_statevector()

print(state)

[0.70710678+0.j 0. +0.70710678j]

results = execute(qc,backend).result().get_counts()

plot_histogram(results)

When I plot this to a histogram, the same 50/50 distribution occurs as when I remove the imaginary "j" from the initialization. Why is the j in there?

glS
  • 24,708
  • 5
  • 34
  • 108

1 Answers1

1

Those two states are different quantum states (with different relative phases) that have the same probabilities of measurement outcomes when we measure in $Z$ basis. The first state without $i$ ($j$ in the Python):

$$|+\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$

with $i$:

$$|i\rangle = \frac{1}{\sqrt{2}}(|0\rangle + i|1\rangle)$$

In order to show the difference between these two states let's apply $H S^{\dagger}$ gates to each of them and see how much different results we can obtain:

$$ H S^{\dagger} |+\rangle = H \frac{1}{\sqrt{2}}(|0\rangle - i|1\rangle) = \frac{1}{2}((1-i)|0\rangle + (1 + i)|1\rangle)$$

The probability of measuring $|0\rangle$ or $|1\rangle$ is equal to $|\frac{1-i}{2}|^2 = |\frac{1+i}{2}|^2 = 0.5$. Now let's apply the same gates to the $|i\rangle$:

$$ H S^{\dagger} |i\rangle = H \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) = |0\rangle$$

The probability of measuring $|0\rangle$ is equal to $1$. These two states ($|+\rangle$ and $|i\rangle$) can lead to different results, so $i$ (or $j$ in Python) does make a difference.


Answer to the questions in the comments

Measurement in $Z$ basis is the conventional measurement: measuring if the state is in $|0\rangle$ or $|1\rangle$ state (there are other basis measurements: a related example can be found in this answer). $|0\rangle$ and $|1\rangle$ are eigenvectors (also eigenbasis) of $Z=\begin{pmatrix} 1&0 \\ 0 & -1 \end{pmatrix}$ operator. $HS^{\dagger}$ is two separate gates: $H$ and $S^{\dagger}$. Here I have applied firstly $S^\dagger = \begin{pmatrix} 1&0 \\ 0 & -i \end{pmatrix}$ gate, then $H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1&1 \\ 1 & -1 \end{pmatrix}$ gate.

Davit Khachatryan
  • 4,301
  • 1
  • 10
  • 21