3
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you for showing that after a certain gate, they have different probabilities. What is Z basis? What does a HS gate do? Also what is the standard state vectors for a 50/50 superposition $\endgroup$ – SalvosMachina Aug 29 at 18:13
  • $\begingroup$ @SalvosMachina, I have added the answers to the questions from the comment at the end of the main answer. $\endgroup$ – Davit Khachatryan Aug 29 at 18:35
  • $\begingroup$ Thanks so much I appreciate it $\endgroup$ – SalvosMachina Aug 29 at 18:38
  • $\begingroup$ @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. $\endgroup$ – Davit Khachatryan Aug 29 at 18:46
  • $\begingroup$ @SalvosMachina, If this answers to the question, please consider accepting it by clicking to the accept tick. $\endgroup$ – Davit Khachatryan Aug 29 at 18:51

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.