Controlled-SWAP (Fredkin) Gate Implementation

b317da6a-6fa9-4465-9dfe-07cbd0d25605
3.0
Description

This quantum circuit initializes a control qubit and two target qubits, applies a Fredkin gate (controlled-SWAP), and measures the results.

Qiskit Circuit Code
Python
```python
from qiskit import QuantumCircuit

# Create a circuit with 3 qubits and 3 classical bits
qc = QuantumCircuit(3, 3)

# Initialize the control qubit (qubit 0) in state |1⟩
qc.x(0)

# Initialize the target qubits (qubits 1 and 2) in superposition states
qc.h(1)
qc.h(2)

# Implement the Fredkin gate (controlled-SWAP gate) between qubits 1 and 2 with control qubit 0
# Decompose the Fredkin gate using basic gates

# Step 1: Apply CNOT between qubits 2 and 1
qc.cx(2, 1)

# Step 2: Apply CCX (Toffoli gate) with controls qubit 0 and qubit 1, target qubit 2
qc.ccx(0, 1, 2)

# Step 3: Apply CNOT between qubits 2 and 1 again
qc.cx(2, 1)

# Step 4: Apply CCX (Toffoli gate) with controls qubit 0 and qubit 1, target qubit 2 again
qc.ccx(0, 1, 2)

# Step 5: Apply CNOT between qubits 2 and 1 one more time
qc.cx(2, 1)

# Measure all qubits
qc.measure([0, 1, 2], [0, 1, 2])
```
Quantum Execution Results
ibm_sherbrooke
N/A
N/A shots
Execution Notice:

'Failed to run program: \'409 Client Error: Conflict for url: https://api.quantum.ibm.com/runtime/jobs. {"errors":[{"message":"You have reached the limit of 3 pending jobs. Please wait for a job to complete or cancel one before submitting anything new.","code":3458,"solution":"Wait until some previous jobs were finished. You can cancel pending jobs to run new jobs.","more_info":"https://docs.quantum-computing.ibm.com/errors"}]}\''

Raw Result Data
Download Results
Back to Home