Questions tagged [quantum-gate]

For questions regarding usage, performance, implementation, application or theory related to quantum gates.

An ideal quantum gate can be described by a unitary matrix. That is, any (ideal) gate acting on $n$ qubits can be described as an element of (the matrix representation of) $\mathrm U\left(2^n\right)$. For a gate acting on $n$, $d$-dimensional, qudits this becomes $\mathrm U\left(d^n\right)$. The result of a gate $U$ acting on state $\left|\psi\right>$ is $U\left|\psi\right>$. When the state is being described by a density matrix $\rho$, this becomes $U\rho U^\dagger$.

Gates are usually denoted with respect to the computational basis and any basis change on the state also has to be applied to the matrix representing the gate.


Gates can act on single, two or more qubits (or qudits). Some common examples are:

Single qubit gates:

  • Hadamard: $$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1 \\\ 1 & -1\end{pmatrix}$$
  • Pauli gates: $$X = \begin{pmatrix}0 & 1 \\\ 1 & 0\end{pmatrix},\quad Y = \begin{pmatrix}0 & -i \\\ i & 0\end{pmatrix},\quad Z = \begin{pmatrix}1 & 0 \\\ 0 & -1\end{pmatrix}$$
  • $\sqrt{\text{NOT}} = \sqrt X$: $$\sqrt X = \frac 12\begin{pmatrix}1+i & 1-i \\\ 1-i & 1+i\end{pmatrix}$$
  • Phase: $$R_\phi = \begin{pmatrix}1 & 0 \\\ 0 & e^{i\phi}\end{pmatrix}$$

Two qubit gates:

  • Controlled gates: $$\text{CNOT} = \begin{pmatrix}1&0&0&0\\\ 0&1&0&0 \\\ 0&0&0&1 \\\ 0&0&1&0\end{pmatrix},\quad CU = \begin{pmatrix}I_2 & 0 \\\ 0 & U\end{pmatrix}$$
  • SWAP: $$\text{SWAP} = \begin{pmatrix}1&0&0&0\\\ 0&0&1&0 \\\ 0&1&0&0 \\\ 0&0&0&1\end{pmatrix}$$

Multiple qubit gates/transformations:

  • Toffoli/CCNOT: $$\text{CCNOT} = \begin{pmatrix}I_6 & 0 \\\ 0 & X\end{pmatrix}$$
  • Quantum Fourier Transform (QFT)
  • (multiple qubit) Hadamard/Discrete Fourier Transform: This is defined by the recursive relation $H^{\otimes n} = H\otimes H^{\otimes \left(n-1\right)}$, where $H = H^{\otimes 1}$

However, currently, gates aren't perfect and an actual implementation of a gate can't recreate the exact, ideal gate. To quantify how 'close' an implemented gate is to the ideal one, gate fidelity is often used.

1857 questions
51
votes
6 answers

How do I add 1+1 using a quantum computer?

This can be seen as the software complement to How does a quantum computer do basic math at the hardware level? The question was asked by a member of the audience at the 4th network of the Spanish Network on Quantum Information and Quantum…
43
votes
2 answers

What is quantum gate teleportation?

Quantum state teleportation is the quantum information protocol where a qubit is transferred between two parties using an initial shared entangled state, Bell measurement, classical communication and local rotation. Apparently, there is also…
Kiro
  • 2,025
  • 17
  • 24
39
votes
8 answers

If all quantum gates must be unitary, what about measurement?

All quantum operations must be unitary to allow reversibility, but what about measurement? Measurement can be represented as a matrix, and that matrix is applied to qubits, so that seems equivalent to the operation of a quantum gate. That's…
auden
  • 3,489
  • 1
  • 21
  • 50
37
votes
1 answer

How are quantum gates implemented in reality?

Quantum gates seem to be like black boxes. Although we know what kind of operation they will perform, we don't know if it's actually possible to implement in reality (or, do we?). In classical computers, we use AND, NOT, OR, XOR, NAND, NOR, etc…
Sanchayan Dutta
  • 17,945
  • 8
  • 50
  • 112
36
votes
5 answers

How to derive the CNOT matrix for a 3-qubit system where the control & target qubits are not adjacent?

In a three-qubit system, it's easy to derive the CNOT operator when the control & target qubits are adjacent in significance - you just tensor the 2-bit CNOT operator with the identity matrix in the untouched qubit's position of…
ahelwer
  • 4,288
  • 2
  • 15
  • 36
34
votes
6 answers

How do I build a gate from a matrix on Qiskit?

I'm creating a gate for a project and need to test if it has the same results as the original circuit in a simulator, how do I build this gate on Qiskit? It's a 3 qubit gate, 8x8 matrix: $$ \frac{1}{2} \begin{bmatrix} 1 & 0 & 1 & 0 & 0 & 1 & 0 & -1…
Nillmer
  • 785
  • 1
  • 5
  • 13
33
votes
3 answers

What are magic states?

I wonder what are magic states, and a magic state gadget. While I'm reading a paper, these terms frequently appear.
30
votes
5 answers

How can I implement an n-bit Toffoli gate?

I want to create a Toffoli gate controlled by n qubits, and implement it in QISKit. Can this be done? If so, how?
Ali Javadi
  • 1,652
  • 1
  • 9
  • 11
28
votes
2 answers

Why is it important to eliminate the garbage qubits?

Most reversible quantum algorithms use standard gates like Toffoli gate (CCNOT) or Fredkin gate (CSWAP). Since some operations require a constant $\left|0\right>$ as input and the number of inputs and outputs is equal, garbage qubits (or junk…
26
votes
4 answers

How to calculate circuit depth properly?

Is the circuit depth the longest sequence of gates applied on one of the qubits? Or is it something more complicated?
C-Roux
  • 928
  • 2
  • 9
  • 20
26
votes
1 answer

Explicit Conversion Between Universal Gate Sets

I'm interested in the conversion between different sets of universal gates. For example, it is known that each of the following sets is universal for quantum computation: $\{T,H,\textrm{cNOT}\}$ $\{H,\textrm{c}S\}$, where $S=T^2$ and $S^2=Z$, and…
DaftWullie
  • 62,671
  • 4
  • 55
  • 140
25
votes
1 answer

How to interpret a quantum circuit as a matrix?

If a circuit takes more than one qubit as its input and has quantum gates which take different numbers of qubits as their input, how would we interpret this circuit as a matrix? Here is a toy example:
PiMan
  • 2,235
  • 1
  • 21
  • 32
22
votes
2 answers

How do you implement the Toffoli gate using only single-qubit and CNOT gates?

I've been reading through "Quantum Computing: A Gentle Introduction", and I've been struggling with this particular problem. How would you create the circuit diagram, and what kind of reasoning would lead you to it?
Lucas Myers
  • 323
  • 1
  • 2
  • 7
22
votes
3 answers

Toffoli gate as FANOUT

I was searching for examples of quantum circuits to exercise with Q# programming and I stumbled on this circuit: From: Examples of Quantum Circuit Diagrams - Michal Charemza During my introductory courses in quantum computation, we were taught…
D-Brc
  • 413
  • 3
  • 6
22
votes
4 answers

Why are quantum gates unitary and not special unitary?

Given that the global phases of states cannot be physically discerned, why is it that quantum circuits are phrased in terms of unitaries and not special unitaries? One answer I got was that it is just for convenience but I'm still unsure. A related…
wdc
  • 447
  • 4
  • 7
1
2 3
99 100