Magician-created Code
Explore how to implement a quantum oracle in a parameterized quantum circuit. Understand the use of Hadamard gates to create superposition, apply the oracle, and measure outcomes representing heads or tails. This lesson clarifies that a quantum oracle is a control structure to transform states, not a predictive tool.
We'll cover the following...
The magician created a reusable function. It takes as a parameter a callback function—the oracle in line 5. First, we’ll create the QuantumCircuit with a single qubit in line 8. Tossing the coin sets it into superposition. This is what the first Hadamard gate does in line 11. Then, we apply the oracle in line 14. The magician uses the second Hadamard gate to transform the oracle’s result into the desired state in line 17. Finally, we run the ...