From the course: Quantum Computing Fundamentals
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Swap and Fredkin gates with Qiskit
From the course: Quantum Computing Fundamentals
Swap and Fredkin gates with Qiskit
- [Instructor] To demonstrate the swap and Fredkin gates in Qiskit, we'll start with this three qubit circuit which initializes the last two qubits with a Hadamard gate and an X rotation gate. We can see what the initial states of those qubits look like on the simulated block spheres below. Now let's insert a swap gate between the last two qubits, to do that, I'll type circuit.swap, pass in the index for the middle qubit 1 and then the index for the last qubit 2, I'll click the Run All button to update that circuit and run the simulation. We can see the swap gate added to the circuit diagram between qubits 1 and 2 and on the block spheres below, we can see that the states of those last two qubits have been swapped from what they previously were. Next, let's try using a Fredkin gate. I'll comment out that swap gate to remove it from the circuit and then on the next line, I'll insert a Fredkin gate with the command…
Contents
-
-
-
-
-
-
-
(Locked)
Controlled-NOT (CNOT) gate2m 46s
-
(Locked)
Controlled-NOT (CNOT) gate with Qiskit3m 19s
-
(Locked)
Toffoli gate2m 27s
-
(Locked)
Toffoli gate with Qiskit2m 39s
-
(Locked)
Swap and Fredkin gates2m 21s
-
(Locked)
Swap and Fredkin gates with Qiskit2m 22s
-
(Locked)
Challenge: Classical two-bit adder2m 17s
-
(Locked)
Solution: Classical two-bit adder2m 24s
-
(Locked)
-
-
-
-