Operations glossary

Overview

This page is a reference that defines the various classical and quantum operations you can use to manipulate qubits in a quantum circuit. Quantum operations include quantum gates, such as the Hadamard gate, as well as operations that are not quantum gates, such as the measurement operation.

The operations are color-coded as follows:

  • Red: Hadamard gate

  • Dark blue: Classical gates

  • Light blue: Phase gates

  • Grey: Non-unitary operations

  • Pink or dark red: Other quantum gates

Each entry below provides details and the OpenQASM reference for each operation. The q-sphere image in each gate entry below shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle , where n is the number of qubits needed to support the gate.

You can define a custom operation to use in Circuit Composer. For instructions, see Create a custom operation in OpenQASM.

To learn more about using operations to create quantum algorithms, see the single- and multi-qubit gates chapter of the Qiskit textbook, Learn Quantum Computation using Qiskit.

Note

The gate colors are slightly different in the light and dark themes. The colors from the light theme are shown here.

Click on a quantum operation below to view its definition. Operations no longer used in Circuit Composer are listed in the Obsolete operations section as a historical reference.

H gate X gate CX gate CCX gate SWAP gate CSWAP gate T gate S gate Z gate SDG gate TDG gate U1 gate Barrier operation |0> operation IF operation Measurement RX gate RY gate RZ gate U3 gate Y gate U2 gate CH gate CY gate CZ gate CRX gate CRY gate CRZ gate CU1 gate CU3 gate RXX gate RZZ gate

X gate

The Pauli X gate, also known as the NOT gate, flips the \left|0\right\rangle state to \left|1\right\rangle , and vice versa. The X gate is equivalent to RX for the angle \pi or to ‘HZH’.

For more information about the X gate, see XGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

_x_gate

x q[0];

image19

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CX gate

The controlled-X gate, also known as the controlled-NOT gate, acts on a pair of qubits, with one acting as ‘control’ and the other as ‘target’. It performs an X on the target whenever the control is in state \left|1\right\rangle . If the control qubit is in a superposition, this gate creates entanglement.

All unitary circuits can be decomposed into single qubit gates and CX gates. Because the two-qubit CX gate costs much more time to execute on real hardware than single qubit gates, circuit cost is sometimes measured in the number of CX gates.

For more information about the CX gate, see CXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cxgate

cx q[0], q[1];

cx_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CCX gate

The double controlled-X gate, commonly known as the Toffoli, has two control qubits and one target. At applies an X to the target only when both controls are in state \left|1\right\rangle .

The CCX gate with the Hadamard gate is a universal gate set for quantum computing.

For more information about the CCX gate, see CCXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

ccx-gat

ccx q[0], q[1], q[2];

ccx_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

SWAP gate

The SWAP gate swaps the states of two qubits.

For more information about the SWAP gate, see SwapGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

swapgate

swap q[0], q[1];

swap_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CSWAP gate

The CSWAP gate, also called the Fredkin gate, swaps the states of the two target qubits if the control qubit is in the \left|1\right\rangle state.

For more information about the CSWAP gate, see CSwapGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cswapgate

cswap q[0], q[1], q[2];

cswap_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

T gate

The T gate is equivalent to RZ for the angle \pi/4 . Fault-tolerant quantum computers will compile all quantum programs down to just the T gate and its inverse, as well as the Clifford gates.

For more information about the T gate, see TGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

_t_gate

t q[0];

image29

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

S gate

The S gate is applies a phase of i to the \left|1\right\rangle state. It is equivalent to RZ for the angle \pi/2 . This gate is sometimes referred to as “phase gate”.

For more information about the S gate, see SGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

_s_gate

s q[0];

image25

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

Z gate

The Pauli Z gate acts as identity on the \left|0\right\rangle state and multiplies the sign of the \left|1\right\rangle state by -1. It therefore flips the \left|+\right\rangle and \left|-\right\rangle states. In the +/- basis, it plays the same role as the X gate in the \left|0\right\rangle / \left|1\right\rangle basis.

For more information about the Z gate, see ZGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

_z_gate

z q[0];

image23

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

Sdg gate

The inverse of the S gate.

For more information about the Sdg gate, see SdgGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

sdggate

sdg q[0];

image27

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

Tdg gate

The inverse of the T gate.

For more information about the Tdg gate, see TdgGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

tdggate

tdg q[0];

image31

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

U1 gate

The U1 gate applies a phase of e^{i\theta} to the \left|1\right\rangle state. For certain values of \theta , it is equivalent to other gates. For example, U1( \pi )=Z U1( \pi/2 )=S, and U1( \pi/4 )=T. Up to a global phase of e^{i\theta/2} , it is equivalent to RZ( \theta ).

For more information about the U1 gate, see U1Gate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

u1_gate

u1(theta) q[0];

u1_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for theta is \pi/2 .

Barrier operation

To make your quantum program more efficient, the compiler will try to combine gates. The barrier is an instruction to the compiler to prevent these combinations being made. Additionally, it is useful for visualizations.

For more information about the Barrier instruction, see Barrier in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

barrier

barrier q;

Reset operation

The reset operation returns a qubit to state \left|0\right\rangle , irrespective of its state before the operation was applied. It is not a reversible operation.

Composer reference

OpenQASM reference

0-opera

reset q[0];

IF operation

The IF operation allows quantum gates to be conditionally applied, depending on the state of a classical register.

Composer reference

OpenQASM reference

if-oper

if (c==0) x q[0];

Measurement

Measurement in the standard basis, also known as the z basis or computational basis. Can be used to implement any kind of measurement when combined with gates. It is not a reversible operation.

Composer reference

OpenQASM reference

z-measu

measure q[0];

H gate

The H, or Hadamard, gate rotates the states \left|0\right\rangle and \left|1\right\rangle to \left|+\right\rangle and \left|-\right\rangle , respectively. It is useful for making superpositions. If you have a universal gate set on a classical computer and add the Hadamard gate, it becomes a universal gate set on a quantum computer.

For more information about the H gate, see HGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

h-gate

h q[0];

image1

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

RX gate

The RX gate implements e^{i\theta X} . On the Bloch sphere, this gate corresponds to rotating the qubit state around the x axis by the given angle.

For more information about the RX gate, see RXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rx_gate

rx(angle) q[0];

image13

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization below.

RY gate

The RY gate implements e^{i\theta Y} . On the Bloch sphere, this gate corresponds to rotating the qubit state around the y axis by the given angle and does not introduce complex amplitudes.

For more information about the RY gate, see RYGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

ry_gate

ry(angle) q[0];

image15

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization below.

RZ gate

The RZ gate implements e^{i\theta Z} . On the Bloch sphere, this gate corresponds to rotating the qubit state around the z axis by the given angle. It is a diagonal gate and is equivalent to U1 up to a phase of e^{(-i\theta/2)} .

For more information about the RZ gate, see RZGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rz_gate

rz(angle) q[0];

image17

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization below.

U3 gate

The three parameters allow the construction of any single-qubit gate. Has a duration of one unit of gate time.

For more information about the U3 gate, see U3Gate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

u3gate

u3(theta, phi, lam) q[0];

u3_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for the angles is \pi/2 .

Y gate

The Pauli Y gate is equivalent to Ry for the angle \pi . It is equivalent to applying X and Z, up to a global phase factor.

For more information about the Y gate, see YGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

_y_gate

y q[0];

image21

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

U2 gate

The two parameters control two different rotations within the gate. Has a duration of one unit of gate time.

For more information about the U2 gate, see U2Gate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

u2gate

u2(theta, phi) q[0];

u2_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for the angles is \pi/2 .

CH gate

The controlled-Hadamard gate acts on a control and target qubit. It performs an H on the target whenever the control is in state \left|1\right\rangle .

For more information about the CH gate, see CHGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

ch-gate

ch q[0], q[1];

ch_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CY gate

The controlled-Y gate acts on a control and target qubit. It performs a Y on the target whenever the control is in state \left|1\right\rangle .

For more information about the CY gate, see CYGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cy-gate

cy q[0], q[1];

cy_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CZ gate

The controlled-Z gate acts on a control and target qubit. It performs a Z on the target whenever the control is in state \left|1\right\rangle . This gate is symmetric; swapping the two qubits it acts on doesn’t change anything.

For more information about the CZ gate, see CZGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cz-gate

cz q[0], q[1];

cz_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

CRX gate

Applies the RX gate to the target qubit if the control qubit is in state \left|1\right\rangle , or alternatively in state \left|0\right\rangle if the argument ctrl_state is set to 0.

For more information about the CRX gate, see CRXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

crx_gate

crx(angle) q[0], q[1];

crx_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

CRY gate

Applies the RY gate to the target qubit if the control qubit is in state \left|1\right\rangle , or alternatively in state \left|0\right\rangle if the argument ctrl_state is set to 0.

The CRY gate can be used to map functions to qubit amplitudes, for example as in the LinearPauliRotations circuit, which implements a linear function.

For more information about the CRY gate, see CRYGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cry_gate

cry(angle) q[0], q[1];

cry_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

CRZ gate

The controlled-RZ gate acts on a control and target qubit. It performs an RZ rotation on the target whenever the control is in state \left|1\right\rangle .

For more information about the CRZ gate, see CRZGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

crzgate

crz(angle) q[0], q[1];

crz_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

CU1 gate

Applies the U1 gate if the control qubit is in state \left|1\right\rangle , or alternatively in state \left|0\right\rangle if the argument ctrl_state is set to 0. This is a diagonal and symmetric gate. One usage of this gate is in the quantum Fourier transform.

For more information about the CU1 gate, see CU1Gate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cu1_gate

cu1(angle) q[0], q[1];

cu1_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

CU3 gate

Applies the U3 gate if the control qubit is in state \left|1\right\rangle , or alternatively in state \left|0\right\rangle if the argument ctrl_state is set to 0.

For more information about the CU3 gate, see CU3Gate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

cu3_gate

cu3(angle) q[0], q[1];

cu3_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

RXX gate

The RXX gate implements \exp(-i \theta/2 X \otimes X) . The Mølmer–Sørensen gate, the native gate on ion-trap systems, can be expressed as a sum of RXX gates.

For more information about the RXX gate, see RXXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rxx-gate

rxx(angle) q[0], q[1];

rxx_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

RZZ gate

The RZZ gate requires a single parameter: an angle expressed in radians. This gate is symmetric; swapping the two qubits it acts on doesn’t change anything.

For more information about the RZZ gate, see RZZGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rzz_gate

rzz(angle) q[0], q[1];

rzz_qsph

The q-sphere representation shows the state after the gate operates on the initial equal superposition state \frac{1}{\sqrt{2^{n}}}\sum_{i=0}^{2^{n}-1}|i\rangle, where n is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is \pi/2 .

Obsolete operations

These operations are no longer used in Circuit Composer; we list them here for historical purposes.

ID gate

Composer reference

OpenQASM reference

idgate

id q[0];