In Quantum Computing, U Gate is the most important and the most fundamental single Qubit Quantum gate. All single Qubit unitary Quantum gates can be considered as a special case of the U Gate. In this chapter of the OpenQASM Tutorial, you will be learning about how to apply U Gate on a Qubit.
In OpenQASM, U Gate is a built-in gate and therefore OpenQASM provides the syntax to apply U Gate on a Qubit. A U Gate has 3 parameters- θ, φ, and λ.
A U Gate with parameters θ, φ, and λ can be considered as equivalent to the following operations- RZ(φ) RY(θ) RZ(λ)
where RZ(x) is rotation about the Z-axis on bloch sphere by x radians and RY(x) is rotation about the Y-axis on the bloch sphere by x radians.
The U Gate with parameters θ, φ, and λ can be represented by the following matrix-
For example, H Gate is a special case of U Gate when the value of θ = π/2
, φ = 0
, λ = π
.
The value of parameters θ, φ, and λ can range between 0(included) and 4π(excluded).
U Gate
The U Gate can be applied on any Qubit.
The following syntax is used for applying the U Gate with parameters theta
, phi
, lambda
on Qubit quantum_register[index]
–
U(theta, phi, lambda) quantum_register[index];
Note– U is a built-in gate therefore U
is a reserved keyword.
Example
Below is an example of applying the U Gate on first Qubit of Quantum Register qubits
with parameters θ = π/2
, φ = 0
, λ = π
. Applying U Gate with these parameters is the equivalent of applying H Gate on the Qubit.
// Applying H gate on the first Qubit of Quantum Register
U(pi/2, 0, pi) qubits[0];
U Gate on Quantum Registers
It is also possible to apply U Gate with a particular set of parameters on all Qubits of a Quantum Register at once.
The following syntax is used for applying the U Gate with parameters theta
, phi
, lambda
on all Qubits of a Quantum Register quantum_register
at once.
U(theta, phi, lambda) quantum_register;
Example
Below is an example of applying the U Gate on all the Qubits of Quantum Register qubits
with parameters θ = π/2
, φ = 0
, λ = π
. Effectively, we are applying H Gate on all Qubits of the Quantum Register qubits
.
// Applying H gate on all Qubits of the Quantum Register
U(pi/2, 0, pi) qubits;