2
$\begingroup$

Broadly: I have noticed on the qiskit developer (assessment) exam there are many questions asking to calculate the probability after measurement however I generally have no idea how to do this without using code (for any gate).

Specifically: Given this code fragment, what is the probability that a measurement would result in $|1\rangle$ if the state is prepared with the following code:

qc = QuantumCircuit(1) qc.ry(2 * math.pi/4, 0)

I.e.: how do we answer questions like these in an exam setting using our knowledge of cosine and sine?

Note that I am referring to and broadening Sample Question 2 - IBM Quantum Developer Certification which can be seen here: https://www.youtube.com/watch?v=LBaVOE5pcaI

$\endgroup$
0

2 Answers 2

2
$\begingroup$

$Ry$ gate is described by following matrix $$ Ry(\theta) = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}. $$

If your qubit was in state $|0\rangle$ before application of the gate, operation $Ry(\theta)|0\rangle$ leads to state $$ Ry(\theta)|0\rangle = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \cos(\theta/2) \\ \sin(\theta/2) \end{pmatrix}= \cos(\theta/2)|0\rangle + \sin(\theta/2)|1\rangle. $$

Since probability of measuring a particular state is square of absolute value of the probability amplitude, we have $$ P(0) = |\cos(\theta/2)|^2 \\ P(1) = |\sin(\theta/2)|^2. $$

In your case $\theta = 2\pi/4 = \pi/2$. So, $P(0) = \cos^2(\pi/4) = 1/2$ and $P(1) = 1/2$.

Try yourself to calculate probabilities $P(0)$ and $P(1)$ for state $Ry(\theta)|1\rangle$.

Simiarly you can do the calculation for application of $Rx$ and $Rz$ gate. See matrices defining the gates here for $Rx$ and here for $Rz$.

$\endgroup$
0
$\begingroup$

The way I guess the probability and know the correct answer is to imagine a Bloch sphere, and imagine how the gate effect the arrow of the bloch sphere.

also can look at these two cheat sheet from Qiskit Slack # qiskit-cert-exam

I suggest playing with these two websites while learning quantum gate

$\endgroup$
4
  • $\begingroup$ Note that Bloch sphere is useful only for one-qubit state. Try to calculate probabilities after application of e.g. Toffoli gate on three-qubit state. :-) $\endgroup$ Jun 18 at 21:21
  • $\begingroup$ The links for the slack pdfs seem to be broken :( $\endgroup$ Jun 19 at 21:55
  • $\begingroup$ @epsilonolispe just join qiskit slack channel, and looking for the file, if you do, it should show file details at the right side bar., after you click the link $\endgroup$
    – poig
    Jun 20 at 2:23
  • $\begingroup$ @epsilonolispe you can use qiskit.visualization.visualize_transition for trace animation of Bloch sphere $\endgroup$
    – poig
    Jun 22 at 5:00

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.