View on GitHub
Open this notebook in GitHub to run it yourself
Output:
Mathematical Background
Alice has a qubit which is initially set toBob has a qubit which is initally set to Alice applies 2x2 Hadamard Matrix (H) to create a superposition of her qubit’s state. It is defined as:
Alice and Bob combine their qubits and generate the composite quantum state as: Alice now applies the Controlled NOT gate operation, with her qubit being the control qubit and Bob’s qubit as the target qubit. The Controlled NOT qubit when applied only affects the target qubit by inverting its state if the control qubit is . The 4x4 matrix for Controlled NOT(CNOT) transformation matrix is defined as:
The new quantum state is: In this situation the qubit’s of Alice and Bob are correlated to each other.
If we measure both the qubits we will either get the state or the state with equal probability. It is described as:
- When Alice observes her state as then the state of Bob’s qubit collapses to the state
- When Alice observes her state as then the state of Bob’s qubit collapses to the state
GHZ State
The GHZ state, a highly entangeld state entengaling all qubits in a circuit. Create a function that will generate a GHZ state forn qubits.
Use the Classiq build in repeat no classical loops. An example circuit is shown below. As you can see to create this circuit, there are two steps:
- Apply the H gate to the first qubit.
- Perform a CNOT gate between the first qubit and all other qubits, or perform CNOT gates like seen in the image below.
Practice:
The Classiq library also has a GHZ state preparation built-in (seeprepare_ghz_state), but here you will try to implemnt it yourself.
Output:
The full solution for your reference
Output: