CNOT Gate

Quantum Computing relies heavily on principles of Quantum Mechanics such as Quantum Superposition and Quantum Entanglement. CNOT Gate (or sometimes also known as CX Gate) is can be used for entangling the state of 2 Qubits, which makes it a very important Quantum Gate. In this chapter of the OpenQASM Tutorial, you will be learning about how to apply CNOT Gate on Qubits.

CNOT(or CX) is a fundamental two-Qubit gate in the field of Quantum Computing. In OpenQASM, CNOT is a built-in gate and therefore OpenQASM provides the syntax to apply a CNOT Gate on two Qubits.

CNOT Gate

The CNOT Gate is a two-Qubit gate which applies a conditional NOT Gate on a target Qubit if and only if the control Qubit is in state |1>

The following syntax is used for applying the CNOT Gate with control Qubit qr1[index] and target Qubit qr2[index]–

cx qr1[index], qr2[index];

Note: CNOT is a built-in gate therefore cx is a reserved keyword.

Example

Below is an example of applying the CNOT Gate with control Qubit as first Qubit of Quantum Register qubits and target qubit as second Qubit of Quantum Register qubits–

Diagram

OPENQASM 2.0; include "qelib1.inc"; // Define quantum registers qreg qubits[2]; // Apply CX gate cx qubits[0], qubits[1];

Translation

Powered by Perceval, Qiskit, PyZX

Not run yet

Simulation

Not run yet

Note: The control and target Qubits can both be in the same as well as different Quantum Register.

Below is a representation of the code in the above example

U Gate

Copyright © 2024 Walther Group, Faculty of Physics, University of Vienna. All rights reserved.

ImprintContact