Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

Q3mini

Guides

  • Fermionic Quantum Computation
  • Q3: Symbolic Quantum Simulation
  • Quantum Information Systems
  • Quantum Many-Body Systems
  • Quantum Spin Systems

Tech Notes

  • About Q3
  • Q3: Quick Start
  • Quantum Fourier Transform
  • Quantum Information Systems with Q3
  • Quantum Many-Body Systems with Q3
  • Quantum Operations
  • Quantum Spin Systems with Q3
  • Quantum States
  • Quantum Teleportation
  • Quick Quantum Computing with Q3

Symbols

  • Basis
  • Boson
  • Bra
  • CNOT
  • ControlledGate
  • ExpressionFor
  • Fermion
  • Heisenberg
  • Ket
  • Let
  • Majorana
  • Matrix
  • Multiply
  • NambuGreen
  • NambuHermitian
  • NambuMatrix
  • NambuUnitary
  • Pauli
  • Phase
  • QuantumCircuit
  • Qubit
  • Qudit
  • RandomWickCircuitSimulate
  • Rotation
  • Species
  • Spin
  • SWAP
  • WickCircuit
  • WickEntanglementEntropy
  • WickEntropy
  • WickGreenFunction
  • WickJump
  • WickLindbladSolve
  • WickLogarithmicNegativity
  • WickMeasurement
  • WickMonitor
  • WickMutualInformation
  • WickNonunitary
  • WickSimulate
  • WickState
  • WickUnitary

Overviews

  • The Postulates of Quantum Mechanics
  • Quantum Algorithms
  • Quantum Computation: Models
  • Quantum Computation: Overview
  • Quantum Error-Correction Codes
  • Quantum Information Theory
  • Quantum Noise and Decoherence
QuantumMob`Q3mini`
SWAP
​
SWAP[a,b]
represents the SWAP gate on the two qubits
a
and
b
.
​
Details and Options

Examples  
(5)
Basic Examples  
(2)
In[1]:=
Let[Qubit,S]
In[2]:=
op=SWAP[S[1],S[2]]
Out[2]=
SWAP[
S
1
,
S
2
]
In[3]:=
Elaborate[op]
Out[3]=
1
2
+
1
2
X
S
1
X
S
2
+
1
2
Y
S
1
Y
S
2
+
1
2
Z
S
1
Z
S
2
The SWAP gate exchanges the states of the two qubits.
In[4]:=
in=Basis[S@{1,2,3}];​​out=op**in;​​Thread[inout]//TableForm
Out[4]//TableForm=

0
S
1
0
S
2
0
S
3

0
S
1
0
S
2
0
S
3


0
S
1
0
S
2
1
S
3

0
S
1
0
S
2
1
S
3


0
S
1
1
S
2
0
S
3

1
S
1
0
S
2
0
S
3


0
S
1
1
S
2
1
S
3

1
S
1
0
S
2
1
S
3


1
S
1
0
S
2
0
S
3

0
S
1
1
S
2
0
S
3


1
S
1
0
S
2
1
S
3

0
S
1
1
S
2
1
S
3


1
S
1
1
S
2
0
S
3

1
S
1
1
S
2
0
S
3


1
S
1
1
S
2
1
S
3

1
S
1
1
S
2
1
S
3

This is the matrix representation of the SWAP gate in the logical basis.
In[5]:=
Matrix[op]//MatrixForm
Out[5]//MatrixForm=
1
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
In the quantum circuit model, the SWAP gate is represented as follows.
In[6]:=
qc=QuantumCircuit[SWAP[S[1],S[2]]]
Out[6]=
​
The SWAP gate can be implemented by means of the CNOT gate.
In[1]:=
new=QuantumCircuit[CNOT[S[1],S[2]],CNOT[S[2],S[1]],CNOT[S[1],S[2]]]
Out[1]=
In[2]:=
more=QuantumCircuit[CNOT[S[2],S[1]],CNOT[S[1],S[2]],CNOT[S[2],S[1]]]
Out[2]=
In[3]:=
Elaborate[qc-new]​​Elaborate[qc-more]
Out[3]=
0
Out[3]=
0
Scope  
(1)

Properties & Relations  
(2)

SeeAlso
CNOT
TechNotes
▪
Two-Qubit Gates
▪
Quantum Computation: Overview
▪
Quantum Information Systems with Q3
▪
Quick Quantum Computing with Q3
▪
Q3: Quick Start
RelatedGuides
▪
Q3: Symbolic Quantum Simulation
▪
Quantum Information Systems
RelatedLinks
▪
D. Loss and D. DiVincenzo, Physical Review A 57, 120 (1998)
, "Quantum computation with quantum dots."
▪
M. Nielsen and I. L. Chuang (2022)
, Quantum Computation and Quantum Information (Cambridge University Press).
▪
Mahn-Soo Choi (2022)
, A Quantum Computation Workbook (Springer).
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com