PennyLane
PreviousNext

To attempt this challenge, please switch to a larger screen size.

Intermediate
Quantum Information

Quantum State Discrimination

Challenge statement

This challenge was part of the Canadian Quantum Cup 2023 coding competition.

Let's play a little game! Let's say you made a quantum state \vert \psi \rangle in your lab. It was very late at night when you made it, and when you come back to the lab the next day, you realize that you forgot to write down the state of your qubit. Your heroic lab partner says that your qubit state is definitely in one of two states with some probabilities.

In this challenge, you must devise an optimal strategy that will correctly identify the state with the highest probability possible. You may measure the state only once. According to your lab partner, your quantum state \vert \psi \rangle can be in one of two states:

\vert \phi_1 \rangle = \cos(\theta_1) \vert 0 \rangle + \sin(\theta_1) \vert 1 \rangle \ \text{with probability} \ p_1

or

\vert \phi_2 \rangle = \cos(\theta_2) \vert 0 \rangle + \sin(\theta_2) \vert 1 \rangle \ \text{with probability} \ p_2.

In this case, the probability of correctly identifying the state refers to the average-case success probability. Namely, if q_1 and q_2 are the probabilities of correctly identifying \vert \phi_1 \rangle and \vert \phi_2 \rangle using a given strategy, that is

q_i = \text{Prob}(\text{state identified as} \vert \phi_i\rangle \vert \text{ state was actually} \vert \phi_i\rangle ),

then the success probability is

p_{success} = p_1 \times q_1 + p_2 \times q_2.

You must find the strategy that maximizes this average-case success probability.

You may find section 4 on Introduction to state distinguishing problems useful.

Challenge code

In the code shown, you must complete the maximal_probability function, which takes as the angles \theta_1 and \theta_2 (float), and the probabilities p_1 and p_2 (float) as arguments. It must return a float or a numpy tensor containing a single float, corresponding to the maximum probability of distinguishing the state.

Input

As input to this problem, you are given theta_1 (float) and theta_2 (float), which are the angles that define \vert \phi_1 \rangle and \vert \phi_2 \rangle, respectively. You are also given p_1 and p_2, the probabilities that the state is in \vert \phi_1 \rangle and \vert \phi_2 \rangle respectively.

Output

This code must output the maximum possible probability (float) of correctly identifying the quantum state with one measurement, as measured by the average-case success probability.

Test cases

The test cases are given as arrays of the form [theta_1, theta_2, p_1, p_2]. The following public test cases are available for you to check your work. There are also some hidden test cases that we will use to check that your solution works in full generality.

test_input: [0, 0.7853981633974483, 0.25, 0.75] expected_ouput: 0.89528471 test_input: [1.83259571459, 1.88495559215, 0.5, 0.5] expected_output: 0.52616798

If your solution matches the correct one up to a relative tolerance of 1\times 10^{-4}, the output will be "Success!". Otherwise, you will receive an "Incorrect" prompt.

Good luck!

Loading...