# When defining the state vector of a qubit in qiskit, what difference does putting "j" make?

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?

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.

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.
• @SalvosMachina, you are welcome. I don't know if there is a standard state vector for a 50/50 superposition, but maybe $|+\rangle$ is a more popular one. Aug 29 '20 at 18:46