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`
ControlledGate
​
ControlledGate
[{
c
1
,
c
2
,…},op]
represents a multi-control multi-target unitary gate with control qubits
c
1
,
c
2
,…
and unitary operator
op
acting on the target qubits.
​
​
ControlledGate
[c,op]
is equivalent to
ControlledGate[{c},op]
.
​
​
ControlledGate
[{
c
1

v
1
,
c
2

v
2
,…},op]
represents a variation of the controlled-unitary gate, where operator op operates when the control qubits
c
1
,
c
2
,…
take the logical values
v
1
,
v
2
,…
, respectively.
​
​
ControlledGate
[cv,…]
is automatically converted to
ControlledGate
[{cv},…]
.
​
​
ControlledGate
[{
c
1
,
c
2
,…}v,…]
is automatically converted to
ControlledGate
[{
c
1
v,
c
2
v,…},…]
.
​
Details and Options

Examples  
(10)
Basic Examples  
(4)
In[1]:=
Let[Qubit,S]
This is a controlled-U operator. Usually it remains unevaluated.
In[2]:=
op=ControlledGate[S[1],S[2,1]]
Out[2]=
ControlledGate{
S
1
1},
X
S
2

In[3]:=
Elaborate[op]
Out[3]=
1
2
-
1
2
Z
S
1
X
S
2
+
1
2
Z
S
1
+
1
2
X
S
2
In[4]:=
Matrix[op]//MatrixForm
Out[4]//MatrixForm=
1
0
0
0
0
1
0
0
0
0
0
1
0
0
1
0
In[5]:=
Elaborate[op]
Out[5]=
1
2
-
1
2
Z
S
1
X
S
2
+
1
2
Z
S
1
+
1
2
X
S
2
In[6]:=
op**S[2,3]//Elaborate
Out[6]=
1
2

Z
S
1
Y
S
2
+
1
2
Z
S
1
Z
S
2
-
1
2

Y
S
2
+
1
2
Z
S
2
​
In the quantum circuit model, a controlled-U gate is depicted by the following quantum circuit element.
In[1]:=
QuantumCircuit[op]
Out[1]=
CNOT
is a special case of controlled-U gate.
In[2]:=
x1=Elaborate@ControlledGate[S[1],S[2,1]]//Simplify​​x2=Elaborate@CNOT[S[1],S[2]]//Simplify​​x1-x2//Simplify
Out[2]=
1
2
1-
Z
S
1
X
S
2
+
Z
S
1
+
X
S
2

Out[2]=
1
2
1-
Z
S
1
X
S
2
+
Z
S
1
+
X
S
2

Out[2]=
0
In[3]:=
x1=Elaborate@ControlledGate[{S[1],S[2]},S[3,1]]//Simplify​​x2=Elaborate[Toffoli[S[1],S[2],S[3]]]//Simplify​​x1-x2//Simplify
Out[3]=
1
4
3-
Z
S
1
Z
S
2
-
Z
S
1
X
S
3
-
Z
S
2
X
S
3
+
Z
S
1
Z
S
2
X
S
3
+
Z
S
1
+
Z
S
2
+
X
S
3

Out[3]=
1
4
3-
Z
S
1
Z
S
2
-
Z
S
1
X
S
3
-
Z
S
2
X
S
3
+
Z
S
1
Z
S
2
X
S
3
+
Z
S
1
+
Z
S
2
+
X
S
3

Out[3]=
0
​
Here, the controlled-unitary gate has the unitary operator acting on multiple qubits.
In[1]:=
U=Rotation[ϕ,S[2,1]]**Rotation[θ,S[3,2]]
Out[1]=
Exp-
1
2
ϕ
X
S
2
Exp-
1
2
θ
Y
S
3
In[2]:=
qc=QuantumCircuit[ControlledGate[S[1],U,"Label""U"]]
Out[2]=
In[3]:=
Elaborate[qc]
Out[3]=
1
2
1+Cos
θ
2
Cos
ϕ
2
+
1
2
1-Cos
θ
2
Cos
ϕ
2

Z
S
1
+
1
2
Cos
ϕ
2

Z
S
1
Y
S
3
Sin
θ
2
-
1
2
Cos
ϕ
2

Y
S
3
Sin
θ
2
+
1
2
Cos
θ
2

Z
S
1
X
S
2
Sin
ϕ
2
-
1
2
Cos
θ
2

X
S
2
Sin
ϕ
2
-
1
2
X
S
2
Y
S
3
Sin
θ
2
Sin
ϕ
2
+
1
2
Z
S
1
X
S
2
Y
S
3
Sin
θ
2
Sin
ϕ
2

It is more common to have multiple controlled qubits.
In[4]:=
qc=QuantumCircuit[ControlledGate[S@{1,2},Rotation[ϕ,S[3,2]]]]
Out[4]=
In[5]:=
Elaborate@qc
Out[5]=
1
4
3+Cos
ϕ
2
-
1
2
Z
S
1
Z
S
2
2
Sin
ϕ
4

+
1
2
Z
S
1
2
Sin
ϕ
4

+
1
2
Z
S
2
2
Sin
ϕ
4

+
1
4

Z
S
1
Y
S
3
Sin
ϕ
2
+
1
4

Z
S
2
Y
S
3
Sin
ϕ
2
-
1
4

Z
S
1
Z
S
2
Y
S
3
Sin
ϕ
2
-
1
4

Y
S
3
Sin
ϕ
2

​
In[1]:=
qc=QuantumCircuit[ControlledGate[S@{1,2}{1,0},Rotation[ϕ,S[3,2]]]]
Out[1]=
In[2]:=
new=QuantumCircuit[S[2,1],ControlledGate[S@{1,2},Rotation[ϕ,S[3,2]]],S[2,1]]
Out[2]=
In[3]:=
new-qc//Elaborate//Simplify
Out[3]=
0
Scope  
(4)

Generalizations & Extensions  
(2)

SeeAlso
QuantumCircuit
 
▪
CNOT

© 2025 Wolfram. All rights reserved.

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