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.

Each entry below provides details and the OpenQASM reference for each operation. See the topic on Build your circuit with OpenQASM code in the IBM Quantum Composer docs for more information.

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. See the q-sphere topic in the Quantum Composer docs for more information on this visualization.

You can define a custom operation to use in IBM Quantum Composer. For instructions, see the Create a custom operation in OpenQASM topic in the Quantum Composer docs.

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 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.

Classical gates

NOT gate CNOT gate Toffoli gate SWAP gate

Phase gates

T gate S gate Z gate TDG gate SDG gate Phase gate RZ gate

Non-unitary operators and modifiers

|0> operation Measurement Control modifier IF operation Barrier operation

Hadamard gate

H gate

Quantum gates

SX gate SXdg gate Y gate RX gate RY gate RXX gate RZZ gate U gate RCCX gate RC3X gate

Classical gates

NOT gate

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

For more information about the NOT 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.

CNOT gate

The controlled-NOT gate, also known as the controlled-x (CX) gate, acts on a pair of qubits, with one acting as ‘control’ and the other as ‘target’. It performs a NOT 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 CNOT gates. Because the two-qubit CNOT gate costs much more time to execute on real hardware than single qubit gates, circuit cost is sometimes measured in the number of CNOT gates.

For more information about the CNOT 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.

Toffoli gate

The Toffoli gate, also known as the double controlled-NOT gate (CCX), has two control qubits and one target. It applies a NOT to the target only when both controls are in state \left|1\right\rangle .

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

For more information about the Toffoli 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.

Identity gate

The identity gate (sometimes called the Id or the I gate) is actually the absence of a gate. It ensures that nothing is applied to a qubit for one unit of gate time.

Composer reference

Qasm reference

idgate

id q[0];

Return to top

Phase gates

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 applies a phase of i to the \left|1\right\rangle state. It is equivalent to RZ for the angle \pi/2 . Note that S=P( \pi/2 ).

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 NOT 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.

T ^{\dagger} gate

Also known as the Tdg or T-dagger gate.

The inverse of the T gate.

For more information about the T ^{\dagger} 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.

S ^{\dagger} gate

Also known as the Sdg or S-dagger gate.

The inverse of the S gate.

For more information about the S ^{\dagger} 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.

Phase gate

The Phase gate (previously called 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, P( \pi )=Z, P( \pi / 2 )=S, and P( \pi/4 )=T. Up to a global phase of e^{i\theta/2} , it is equivalent to RZ( \theta ).

For more information about the Phase gate, see PhaseGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

p_gate

p(theta) q[0];

p_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 IBM Quantum Composer, the default value for theta is \pi/2 .

RZ gate

The RZ gate implements exp(-i\frac{\theta}{2}Z) . On the Bloch sphere, this gate corresponds to rotating the qubit state around the z axis by the given angle.

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 IBM Quantum Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization.

Return to top

Non-unitary operators and modifiers

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];

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];

Control modifier

A control modifier yields a gate whose original operation is now contingent on the state of the control qubit. When the control is in the |1\rangle state, the target qubit(s) undergo the specified unitary evolution. In contrast, no operation is performed if the control is in the |0\rangle state. If the control is in a superposition state, then the resulting operation follows from linearity.

Drag the control modifier to a gate in order to add a control to it. Dots will appear above and below the gate, on the qubit wires that can be targets that control; click one or more dots to assign the target to one or more qubits. You can also assign a control by right-clicking a gate.

To remove a control, right-click the gate and select the option to remove control.

Composer reference

OpenQASM reference

cntrl-mod

c

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];

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;

Return to top

Hadamard gate

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.

Return to top

Quantum gates

\sqrt{X} gate

Also known as the square-root NOT gate.

This gate implements the square-root of X, \sqrt{X} . Applying this gate twice in a row produces the standard Pauli-X gate (NOT gate). Like the Hadamard gate, \sqrt{X} creates an equal superposition state if the qubit is in the state |0\rangle , but with a different relative phase. On some hardwares, it is a native gate that can be implemented with a \pi/2 or X90 pulse.

For more information about the \sqrt{X} gate, see SXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

sx_gate

sx q[0];

sx_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.

\sqrt{X} ^{\dagger} gate

Also known as the SXdg or square-root NOT-dagger gate.

This is the inverse of the \sqrt{X} gate. Applying it twice in a row produces the Pauli-X gate (NOT gate), since the NOT gate is its own inverse. Like the \sqrt{X} gate, this gate can be used to create an equal superposition state, and it too is natively implemented on some hardwares using an X90 pulse.

For more information about the \sqrt{X} ^{\dagger} gate, see SXdgGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

sxdg_gate

sxdg q[0];

sxdg_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.

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.

RX gate

The RX gate implements exp(-i\frac{\theta}{2}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 IBM Quantum Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization.

RY gate

The RY gate implements exp(-i\frac{\theta}{2}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 IBM Quantum Composer, the default value for angle is \pi/2 . Therefore, this is the angle used in the q-sphere visualization below.

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 IBM Quantum 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 IBM Quantum Composer, the default value for angle is \pi/2 .

U gate

(Previously called the 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 U gate, see UGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

u_gate

u(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 IBM Quantum Composer, the default value for angle is \pi/2 .

Return to top

RCCX gate

The simplified Toffoli gate, also referred to as Margolus gate.

The simplified Toffoli gate implements the Toffoli gate up to relative phases. This implementation requires three CX gates, which is the minimal amount possible, as shown in https://arxiv.org/abs/quant-ph/0312225. Note that the simplified Toffoli is not equivalent to the Toffoli, but can be used in places where the Toffoli gate is uncomputed again.

For more information about the RCCX gate, see RCCXGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rccx-gate

rccx a, b, c;

rccx_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.

Return to top

RC3X gate

The simplified 3-controlled Toffoli gate.

The simplified Toffoli gate implements the Toffoli gate up to relative phases. Note that the simplified Toffoli is not equivalent to the Toffoli, but can be used in places where the Toffoli gate is uncomputed again.

For more information about the RC3X gate, see RC3XGate in the Qiskit Circuit Library.

Composer reference

OpenQASM reference

Q-sphere

Note about q-sphere representations

rc3x-gate

rc3x a, b, c, d;

rc3x_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.

Return to top

Obsolete operations

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

CSWAP gate

Composer reference

OpenQASM reference

cswapgate

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

U1 gate

The U1 gate has been renamed the phase gate.

Composer reference

OpenQASM reference

u1_gate

u1(theta) q[0];

U3 gate

The U3 gate has been renamed the U gate.

Composer reference

OpenQASM reference

u3gate

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

U2 gate

Composer reference

OpenQASM reference

u2gate

u2(theta, phi) q[0];

CU1 gate

To recreate this gate, add the control modifier to the phase gate (formerly the U1 gate).

Composer reference

OpenQASM reference

cu1_gate

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

CU3 gate

To recreate this gate, add the control modifier to the U gate (formerly the U3 gate).

Composer reference

OpenQASM reference

cu3_gate

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

CH gate

Composer reference

OpenQASM reference

ch-gate

ch q[0], q[1];

CY gate

Composer reference

OpenQASM reference

cy-gate

cy q[0], q[1];

CZ gate

Composer reference

OpenQASM reference

cz-gate

cz q[0], q[1];

CRX gate

Composer reference

OpenQASM reference

crx_gate

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

CRY gate

Composer reference

OpenQASM reference

cry_gate

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

CRZ gate

Composer reference

OpenQASM reference

crzgate

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

Return to top