Chapter 8, Grover’s Algorithm
- It takes 20 qubits to search among 1,000,000 values because 220 = 1,000,000. The number of Grover iterations will be .
- Here’s the code:
import random oracle_matrix = [ [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1] ] entry = random.randint(0, 7) print(entry) oracle_matrix[entry][entry] = -1 oracle = QuantumCircuit(3) oracle.unitary(oracle_matrix, qubits=[0, 1, 2], label=’oracle’) oracle.barrier() display(oracle.draw('latex'))
- The expression...