Chapter 4 – Understanding Basic Quantum Computing Principles
Question 1
How would you create a circuit that entangles two qubits where each qubit is different (that is, 01, 10)?
Answer
We can use the following code to create a circuit that entangles two qubits:
qc = QuantumCircuit(2,2)
qc.h(0)
qc.x(1)
qc.cx(0,1)
qc.measure([0,1], [0,1])
qc.draw()
Question 2
Create a circuit with a multi-qubit gate, such as a controlled-Hadamard gate.
Answer
The circuit will just need to be ensured to have two qubits and include a controlled Hadamard gate (ch). In the following example, the first qubit is the control and the second qubit is the target. We add a Hadamard gate to the control qubit to ensure we will get either a 0
or 1
; otherwise, the control will never be set:
qc = QuantumCircuit(2,2)
qc.h(0)
qc.ch(0,1)
qc.draw()
Question 3
Create all 4 Bell states in a circuit.
Answer
The circuit will just need to have two qubits and include...