Deutsch coding algorithm

I am currently trying to encode the Deutsch algorithm and struggle with how to measure | x> qubit. Reading an example here helped, but did not solve my fundamental problem.

Using the following diagram as the basis for representing my problem that I have, in the sense that they offer a second Hadamard transform, I still have my information encoded as a probability vector corresponding to | 00>, | 01>, | 10> and | 11>.

Deutsch Algorithm Diagram

All I read suggests that all I do is take the top 2 values ​​(how they correspond to the first qubit) and apply the Hadamard transform, and then see if it is zero or one, but that doesn't seem to work. Has anyone implemented this and got any recommendations on how to actually do this? I am currently coding Python using Numpy, and the following:

x = np.array([[1], [0]])
y = np.array([[0], [1]])
h = calc_hadamard(1)

phi2 = np.kron(h.dot(x), h.dot(y))

constantF = np.array([[1, 0, 0, 0],
                      [0, 1, 0, 0],
                      [0, 0, 1, 0],
                      [0, 0, 0, 1]])

balancedF = np.array([[1, 0, 0, 0],
                      [0, 1, 0, 0],
                      [0, 0, 0, 1],
                      [0, 0, 1, 0]])

print(constantF.dot(phi2))
print(balancedF.dot(phi2))

Somewhere what is displayed by these print functions,

  • (0.5, -0.5, 0.5, -0.5) and
  • (0.5, -0.5, -0.5, 0.5)

As it should be, this is obviously what is expected, but performing the subsequent Hadamard transform on the first two values ​​gives the same answer. What am I missing here?

+4
source share
1 answer

, , , , , - 2 ( ) ,

, , . . , 1 , 2- , :

phi3 = constantF.dot(phi2)  # or balancedF
h_on_1_for_2 = np.kron(np.eye(2), h)
phi4 = np.dot(h_on_1_for_2, phi3)
+2

Source: https://habr.com/ru/post/1686001/


All Articles