Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Quantum logic gate
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Notable examples == {{Main|List of quantum logic gates}} There exists an [[Uncountable set|uncountably infinite]] number of gates. Some of them have been named by various authors,<ref name="Williams">{{cite book|author=Colin P. Williams |year=2011 |title=Explorations in Quantum Computing |publisher=[[Springer Science+Business Media|Springer]] |isbn=978-1-84628-887-6}}</ref><ref name="Barenco"/><ref name="Nielsen-Chuang">{{Cite book|title=Quantum Computation and Quantum Information|last1=Nielsen|first1=Michael A.|last2=Chuang|first2=Isaac|date=2010|publisher=[[Cambridge University Press]]|isbn=978-1-10700-217-3|location=Cambridge|oclc=43641333|author-link=Michael Nielsen|author-link2=Isaac Chuang|url=https://www.cambridge.org/9781107002173}}</ref><ref name="Yanofsky-Mannucci">{{Cite book|title=Quantum computing for computer scientists|last1=Yanofsky|first1=Noson S.|last2=Mannucci|first2=Mirco|date=2013|publisher=[[Cambridge University Press]]|isbn=978-0-521-87996-5}}</ref><ref>{{cite web|url=https://qiskit.org/documentation/apidoc/circuit_library.html|title=Circuit Library|publisher=IBM ([[Qiskit]])}}</ref><ref name="inspire">{{cite web|url=https://www.quantum-inspire.com/kbase/cqasm-qubit-gate-operations/|title=cQASM: Qubit gate operations|publisher=QuTech}}</ref><ref>{{cite web |url=https://docs.microsoft.com/en-us/qsharp/api/qsharp/microsoft.quantum.intrinsic |title=Microsoft.Quantum.Intrinsic namespace |date=28 July 2023 |publisher=Microsoft ([[Q Sharp|Q#]])}}</ref> and below follow some of those most often used in the literature. === Identity gate === The identity gate is the [[identity matrix]], usually written as ''I'', and is defined for a single qubit as :<math> I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} ,</math> where ''I'' is basis independent and does not modify the quantum state. The identity gate is most useful when describing mathematically the result of various gate operations or when discussing multi-qubit circuits. {{Anchor|Pauli X|Not|X|X gate|Not gate}} {{Anchor|Pauli Z|Z|Z gate}} === Pauli gates (''X'',''Y'',''Z'') === {{Further|Clifford gates|Pauli group}} {{Multiple image | image1 = Qcircuit I.svg | image2 = Qcircuit NOT.svg | image3 = Qcircuit Y.svg | total_width = 120 | footer = Quantum gates (from top to bottom): Identity gate, NOT gate, Pauli Y, Pauli Z | direction = vertical | image4 = Qcircuit Z.svg }} The Pauli gates <math>(X,Y,Z)</math> are the three [[Pauli matrices]] <math>(\sigma_x,\sigma_y,\sigma_z)</math> and act on a single qubit. The Pauli ''X'', ''Y'' and ''Z'' equate, respectively, to a rotation around the ''x'', ''y'' and ''z'' axes of the [[Bloch sphere]] by <math>\pi</math> radians.{{efn|Note, here a full rotation about the Bloch sphere is <math>2 \pi</math> radians, as opposed to the [[List of quantum logic gates#Rotation operator gates|rotation operator gates]] where a full turn is <math>4 \pi.</math>}} The Pauli-''X'' gate is the quantum equivalent of the [[NOT gate]] for classical computers with respect to the standard basis {{nowrap|<math>|0\rangle</math>, <math>|1\rangle</math>,}} which distinguishes the ''z'' axis on the [[Bloch sphere]]. It is sometimes called a bit-flip as it maps <math>|0\rangle</math> to <math>|1\rangle</math> and <math>|1\rangle</math> to <math>|0\rangle</math>. Similarly, the Pauli-''Y'' maps <math>|0\rangle</math> to <math>i|1\rangle</math> and <math>|1\rangle</math> to {{nowrap|<math>-i|0\rangle</math>}}. Pauli ''Z'' leaves the basis state <math>|0\rangle</math> unchanged and maps <math>|1\rangle</math> to {{nowrap|<math>-|1\rangle</math>.}} Due to this nature, Pauli ''Z'' is sometimes called phase-flip. These matrices are usually represented as :<math> X = \sigma_x =\operatorname{NOT} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} ,</math> :<math> Y = \sigma_y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}, </math> :<math> Z = \sigma_z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}.</math> The Pauli matrices are [[Involutory matrix|involutory]], meaning that the square of a Pauli matrix is the [[identity matrix]]. :<math>I^2 = X^2 = Y^2 = Z^2 = -iXYZ = I</math> The Pauli matrices also [[Anticommutative property|anti-commute]], for example <math>ZX=iY=-XZ.</math> The [[matrix exponential]] of a Pauli matrix <math>\sigma_j</math> is a [[List of quantum logic gates#Rotation operator gates|rotation operator]], often written as <math>e^{-i\sigma_j\theta/2}.</math> {{anchor|squares}} {{Anchor|CX|CY|CZ|controlled gate|Controlled gates|Controlled|CNOT}} === Controlled gates === {{Further|Controlled NOT gate}} [[Image:Controlled gate.svg|upright=0.6|thumb|Circuit representation of controlled-''U'' gate]] Controlled gates act on 2 or more qubits, where one or more qubits act as a control for some operation.<ref name="Barenco" /> For example, the [[controlled NOT gate]] (or CNOT or CX) acts on 2 qubits, and performs the NOT operation on the second qubit only when the first qubit is {{nowrap|<math>|1\rangle</math>,}} and otherwise leaves it unchanged. With respect to the basis {{nowrap|<math>|00\rangle</math>,}} {{nowrap|<math>|01\rangle</math>,}} {{nowrap|<math>|10\rangle</math>,}} {{nowrap|<math>|11\rangle</math>,}} it is represented by the [[Hermitian matrix|Hermitian]] [[Unitary matrix|unitary]] matrix: :<math> \mbox{CNOT} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} . </math> The CNOT (or controlled Pauli-''X'') gate can be described as the gate that maps the basis states <math>|a,b\rangle \mapsto |a,a \oplus b\rangle</math>, where <math>\oplus</math> is [[Exclusive or|XOR]]. The CNOT can be expressed in the [[Pauli matrices|Pauli basis]] as: :<math> \mbox{CNOT} = e^{i\frac{\pi}{4}(I-Z_1)(I-X_2)}=e^{-i\frac{\pi}{4}(I-Z_1)(I-X_2)}. </math> Being a Hermitian unitary operator, CNOT [[Sylvester's formula|has the property]] that <math> e^{i\theta U}=(\cos \theta)I+(i\sin \theta) U</math> and <math> U =e^{i\frac{\pi}{2}(I-U)}=e^{-i\frac{\pi}{2}(I-U)}</math>, and is [[Involutory matrix|involutory]]. More generally if ''U'' is a gate that operates on a single qubit with matrix representation :<math> U = \begin{bmatrix} u_{00} & u_{01} \\ u_{10} & u_{11} \end{bmatrix} , </math> then the ''controlled-U gate'' is a gate that operates on two qubits in such a way that the first qubit serves as a control. It maps the basis states as follows.{{Multiple image | image1 = Qcircuit_CNOT.svg | image2 = Qcircuit_CY.svg | image3 = Qcircuit CC.svg | total_width = 400 | footer = Circuit diagrams of controlled Pauli gates (from left to right): CNOT (or controlled-X), controlled-Y and controlled-Z. }} :<math> | 0 0 \rangle \mapsto | 0 0 \rangle </math> :<math> | 0 1 \rangle \mapsto | 0 1 \rangle </math> :<math> | 1 0 \rangle \mapsto | 1 \rangle \otimes U |0 \rangle = | 1 \rangle \otimes (u_{00} |0 \rangle + u_{10} |1 \rangle) </math> :<math> | 1 1 \rangle \mapsto | 1 \rangle \otimes U |1 \rangle = | 1 \rangle \otimes (u_{01} |0 \rangle + u_{11} |1 \rangle) </math> The matrix representing the controlled ''U'' is :<math> \mbox{C}U = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & u_{00} & u_{01} \\ 0 & 0 & u_{10} & u_{11} \end{bmatrix}.</math> When ''U'' is one of the Pauli operators, ''X'',''Y'', ''Z'', the respective terms "controlled-''X''", "controlled-''Y''", or "controlled-''Z''" are sometimes used.{{r|Nielsen-Chuang|pages=177β185}} Sometimes this is shortened to just C''X'', C''Y'' and C''Z''. In general, any single qubit [[Unitary matrix#Properties|unitary gate]] can be expressed as <math> U = e^{iH} </math>, where ''H'' is a [[Hermitian matrix]], and then the controlled ''U'' is <math> CU = e^{i\frac{1}{2}(I-Z_1)H_2}.</math> Control can be extended to gates with arbitrary number of qubits<ref name="Barenco" /> and functions in programming languages.<ref name="adjoint-controlled-qsharp"/> Functions can be conditioned on superposition states.<ref name="Oemer-structured-programming">{{cite web|title=Structured Quantum Programming|last=Γmer|first=Bernhard|url=http://tph.tuwien.ac.at/~oemer/doc/structquprog.pdf|pages=72, 92β107|date=2 September 2009|publisher=Institute for Theoretical Physics, Vienna University of Technology|archive-url=https://web.archive.org/web/20220327170025/tph.tuwien.ac.at/~oemer/doc/structquprog.pdf|archive-date=March 27, 2022}}</ref><ref name="Oemer2"/> ==== Classical control ==== {{Further|Deferred measurement principle}} [[File:Example for classic controlled quantum gate.png|thumb|upright=0.8|'''Example:''' The qubit <math>\phi</math> is [[#Measurement|measured]], and the result of this measurement is a [[Boolean data type|Boolean]] value, which is consumed by the classical computer. If <math>\phi</math> measures to 1, then the classical computer tells the quantum computer to apply the U gate on <math>\psi</math>.<br>In circuit diagrams, single lines are [[qubit]]s, and doubled lines are [[bit]]s.]] Gates can also be controlled by classical logic. A quantum computer is controlled by a [[classical computing|classical computer]], and behaves like a [[coprocessor]] that receives instructions from the classical computer about what gates to execute on which qubits.{{r|Oemer|pages=42β43}}<ref name="cryo-controller"/> Classical control is simply the inclusion, or omission, of gates in the instruction sequence for the quantum computer.{{r|Nielsen-Chuang|pages=26β28}}{{r|Williams|pages=87β88}} {{anchor|Phase shift|Phase shift gates|Phase shift gate|Phase gate}} === Phase shift gates === The phase shift is a family of single-qubit gates that map the basis states <math>|0\rangle \mapsto |0\rangle</math> and <math>|1\rangle \mapsto e^{i\varphi}|1\rangle</math>. The probability of measuring a <math>|0\rangle</math> or <math>|1\rangle</math> is unchanged after applying this gate, however it modifies the phase of the quantum state. This is equivalent to tracing a horizontal circle (a line of constant latitude), or a rotation about the z-axis on the [[Bloch sphere]] by <math>\varphi</math> radians. The phase shift gate is represented by the matrix: :<math>P(\varphi) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \varphi} \end{bmatrix}</math> where <math>\varphi</math> is the ''phase shift'' with the [[Periodic function|period]] {{math|2π}}. Some common examples are the ''T'' gate where <math display="inline">\varphi = \frac{\pi}{4}</math> (historically known as the <math>\pi /8</math> gate), the phase gate (also known as the S gate, written as ''S'', though ''S'' is sometimes used for SWAP gates) where <math display="inline">\varphi= \frac{\pi}{2}</math> and the [[#Z|Pauli-''Z'' gate]] where <math>\varphi = \pi.</math> The phase shift gates are related to each other as follows: :<math> Z = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \pi} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} = P\left(\pi\right)</math> :<math> S = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \frac{\pi}{2}} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & i \end{bmatrix} = P\left(\frac{\pi}{2}\right)=\sqrt{Z}</math> :<math> T = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \frac{\pi}{4}} \end{bmatrix} =P\left(\frac{\pi}{4}\right) = \sqrt{S} = \sqrt[4]{Z}</math> Note that the phase gate <math>P(\varphi)</math> is not [[Hermitian matrix|Hermitian]] (except for all <math>\varphi = n\pi, n \in \mathbb{Z}</math>). These gates are different from their Hermitian conjugates: <math>P^\dagger(\varphi)=P(-\varphi)</math>. The two [[Hermitian adjoint|adjoint]] (or [[conjugate transpose]]) gates <math>S^\dagger</math> and <math>T^\dagger</math> are sometimes included in instruction sets.<ref>{{cite web|url=https://qiskit.org/documentation/stubs/qiskit.circuit.library.TdgGate.html#qiskit.circuit.library.TdgGate|title=TdgGate}} [[Qiskit]] online documentation.</ref><ref>{{cite web|url=https://www.quantum-inspire.com/kbase/t-dagger-gate/|title=T dagger Gate}} cQASM online documentation.</ref> {{anchor|Hadamard|Hadamard gate|H gate}} === Hadamard gate === {{further|Hadamard transform#Quantum computing applications|Hadamard matrix}}The Hadamard or Walsh-Hadamard gate, named after [[Jacques Hadamard]] ({{IPA|fr|adamaΚ|lang}}) and [[Joseph L. Walsh]], acts on a single qubit. It maps the basis states <math display="inline">|0\rangle \mapsto \frac{|0\rangle + |1\rangle}{\sqrt{2}}</math> and <math display="inline">|1\rangle \mapsto \frac{|0\rangle - |1\rangle}{\sqrt{2}}</math> (it creates an equal superposition state if given a computational basis state). The two states <math>(|0\rangle + |1\rangle)/\sqrt{2}</math> and <math>(|0\rangle - |1\rangle)/\sqrt{2}</math> are sometimes written <math>|+\rangle</math> and <math>|-\rangle</math> respectively. The Hadamard gate performs a rotation of <math>\pi</math> about the axis <math>(\hat{x}+\hat{z})/\sqrt{2}</math> at the [[Bloch sphere]], and is therefore [[Involutory matrix|involutory]]. It is represented by the [[Hadamard matrix]]: [[Image:Hadamard gate.svg|upright=0.8|thumb|Circuit representation of Hadamard gate]] :<math> H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} .</math> If the [[Hermitian matrix|Hermitian]] (so <math>H^{\dagger}=H^{-1}=H</math>) Hadamard gate is used to perform a [[Change of basis#Endomorphisms|change of basis]], it flips <math>\hat{x}</math> and <math>\hat{z}</math>. For example, <math>HZH=X</math> and <math>H\sqrt{X}\;H=\sqrt{Z}=S.</math> {{Anchor|Swap|SWAP|Swap gate}} === Swap gate === {{Further|List of quantum logic gates#Non-Clifford swap gates}} [[Image:Swap gate.svg|upright=0.6|thumb|Circuit representation of SWAP gate]] The swap gate swaps two qubits. With respect to the basis <math>|00\rangle</math>, <math>|01\rangle</math>, <math>|10\rangle</math>, <math>|11\rangle</math>, it is represented by the matrix :<math> \mbox{SWAP} = \begin{bmatrix} 1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} . </math> The swap gate can be decomposed into summation form: :<math>\mbox{SWAP}=\frac{I\otimes I +X\otimes X+Y\otimes Y+Z\otimes Z}{2}</math> {{Anchor|Toffoli gate|Toffoli|CCNOT}} === Toffoli (CCNOT) gate === {{Main|Toffoli gate}} [[Image:Toffoli gate.svg|upright=0.6|thumb|Circuit representation of Toffoli gate]] The Toffoli gate, named after [[Tommaso Toffoli]] and also called the CCNOT gate or [[#Deutsch gate|Deutsch gate]] <math>D(\pi/2)</math>, is a 3-bit gate that is [[Functional completeness|universal]] for classical computation but not for quantum computation. The quantum Toffoli gate is the same gate, defined for 3 qubits. If we limit ourselves to only accepting input qubits that are <math>|0\rangle</math> and {{nowrap|<math>|1\rangle</math>,}} then if the first two bits are in the state <math>|1\rangle</math> it applies a Pauli-''X'' (or NOT) on the third bit, else it does nothing. It is an example of a CC-U (controlled-controlled Unitary) gate. Since it is the quantum analog of a classical gate, it is completely specified by its truth table. The Toffoli gate is universal when combined with the single qubit Hadamard gate.<ref name="Aharonov">{{cite arXiv|last=Aharonov|first=Dorit|date=2003-01-09|title=A Simple Proof that Toffoli and Hadamard are Quantum Universal|eprint=quant-ph/0301040}}</ref> {| |- ! Truth table !! Matrix form |- | {| class="wikitable" |- ! colspan="3" | Input ! colspan="3" | Output |- style="text-align:center;" | 0 || 0 || 0 || 0 || 0 || 0 |- style="text-align:center;" | 0 || 0 || 1 || 0 || 0 || 1 |- style="text-align:center;" | 0 || 1 || 0 || 0 || 1 || 0 |- style="text-align:center;" | 0 || 1 || 1 || 0 || 1 || 1 |- style="text-align:center;" | 1 || 0 || 0 || 1 || 0 || 0 |- style="text-align:center;" | 1 || 0 || 1 || 1 || 0 || 1 |- style="text-align:center;" | 1 || 1 || 0 || 1 || 1 || 1 |- style="text-align:center;" | 1 || 1 || 1 || 1 || 1 || 0 |} | <math> \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{bmatrix} </math> |} The Toffoli gate is related to the classical [[Logical conjunction|AND]] (<math>\land</math>) and [[exclusive or|XOR]] (<math>\oplus</math>) operations as it performs the mapping <math>|a, b, c\rangle \mapsto |a, b, c\oplus (a \land b)\rangle</math> on states in the computational basis. The Toffoli gate can be expressed using [[Pauli matrices]] as :<math> \mbox{Toff} = e^{i\frac{\pi}{8}(I-Z_1)(I-Z_2)(I-X_3)}= e^{-i\frac{\pi}{8}(I-Z_1)(I-Z_2)(I-X_3)}. </math>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)