# 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:

• 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 , where 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.

### X gate¶

The Pauli X gate, also known as the NOT gate, flips the state to , and vice versa. The X gate is equivalent to RX for the angle or to ‘HZH’.

Composer reference

OpenQASM reference

Q-sphere

x q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 . 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.

Composer reference

OpenQASM reference

Q-sphere

cx q[0], q[1];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 .

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

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### SWAP gate¶

The SWAP gate swaps the states of two qubits.

Composer reference

OpenQASM reference

Q-sphere

swap q[0], q[1];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 state.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### T gate¶

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

Composer reference

OpenQASM reference

Q-sphere

t q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### S gate¶

The S gate is applies a phase of to the state. It is equivalent to RZ for the angle . This gate is sometimes referred to as “phase gate”.

Composer reference

OpenQASM reference

Q-sphere

s q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### Z gate¶

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

Composer reference

OpenQASM reference

Q-sphere

z q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### Sdg gate¶

The inverse of the S gate.

Composer reference

OpenQASM reference

Q-sphere

sdg q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### Tdg gate¶

The inverse of the T gate.

Composer reference

OpenQASM reference

Q-sphere

tdg q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### U1 gate¶

The U1 gate applies a phase of to the state. For certain values of , it is equivalent to other gates. For example, U1()=Z U1()=S, and U1()=T. Up to a global phase of , it is equivalent to RZ().

Composer reference

OpenQASM reference

Q-sphere

u1(theta) q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for theta is .

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

Composer reference

OpenQASM reference

barrier q;

### Reset operation¶

The reset operation returns a qubit to state , irrespective of its state before the operation was applied. It is not a reversible operation.

Composer reference

OpenQASM reference

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

measure q[0];

### H gate¶

The H, or Hadamard, gate rotates the states and to and , 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.

Composer reference

OpenQASM reference

Q-sphere

h q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

### RX gate¶

The RX gate implements . On the Bloch sphere, this gate corresponds to rotating the qubit state around the x axis by the given angle.

Composer reference

OpenQASM reference

Q-sphere

rx(angle) q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

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

### RY gate¶

The RY gate implements . 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.

Composer reference

OpenQASM reference

Q-sphere

ry(angle) q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

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

### RZ gate¶

The RZ gate implements . 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 .

Composer reference

OpenQASM reference

Q-sphere

rz(angle) q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is . 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.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for the angles is .

### Y gate¶

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

Composer reference

OpenQASM reference

Q-sphere

y q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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.

Composer reference

OpenQASM reference

Q-sphere

u2(theta, phi) q[0];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for the angles is .

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

Composer reference

OpenQASM reference

Q-sphere

ch q[0], q[1];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 .

Composer reference

OpenQASM reference

Q-sphere

cy q[0], q[1];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 . This gate is symmetric; swapping the two qubits it acts on doesn’t change anything.

Composer reference

OpenQASM reference

Q-sphere

cz q[0], q[1];

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where 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 , or alternatively in state if the argument ctrl_state is set to 0.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

### CRY gate¶

Applies the RY gate to the target qubit if the control qubit is in state , or alternatively in state 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.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

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

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

### CU1 gate¶

Applies the U1 gate if the control qubit is in state , or alternatively in state 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.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

### CU3 gate¶

Applies the U3 gate if the control qubit is in state , or alternatively in state if the argument ctrl_state is set to 0.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

### RXX gate¶

The RXX gate implements . The Mølmer–Sørensen gate, the native gate on ion-trap systems, can be expressed as a sum of RXX gates.

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

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

Composer reference

OpenQASM reference

Q-sphere

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

The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.

In Circuit Composer, the default value for angle is .

## Obsolete operations¶

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

### ID gate¶

Composer reference

OpenQASM reference

id q[0];