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

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