Main Content

rzGate

z-axis rotation gate

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

example

g = rzGate(targetQubit,theta) applies a z-axis rotation gate to a single target qubit and returns a quantum.gate.SimpleGate object. This gate rotates the qubit state around the z-axis by an angle of theta.

  • If targetQubit and theta are vectors of the same length, rzGate returns a column vector of gates, where g(i) represents a z-axis rotation gate applied to a qubit with index targetQubit(i) with a rotation angle of theta(i).

  • If either targetQubit or theta is a scalar, and the other input is a vector, then MATLAB® expands the scalar to match the size of the vector input.

Examples

collapse all

Create a z-axis rotation gate that acts on a single qubit with rotation angle pi/2.

g = rzGate(1,pi/2)
g = 

  SimpleGate with properties:

             Type: "rz"
    ControlQubits: [1×0 double]
     TargetQubits: 1
           Angles: 1.5708

Get the matrix representation of the gate.

M = getMatrix(g)
M =

   0.7071 - 0.7071i   0.0000 + 0.0000i
   0.0000 + 0.0000i   0.7071 + 0.7071i

Create an array of three z-axis rotation gates. The first gate acts on qubit 1 with rotation angle pi/4, the next gate acts on qubit 2 with rotation angle pi/2, and the final gate acts on qubit 3 with rotation angle 3*pi/4.

g = rzGate(1:3,pi/4*(1:3))
g = 

  3×1 SimpleGate array with gates:

    Id   Gate   Control   Target   Angle
     1   rz               1        pi/4 
     2   rz               2        pi/2 
     3   rz               3        3pi/4

Input Arguments

collapse all

Target qubit of the gate, specified as a positive integer scalar index or vector of qubit indices.

Example: 1

Example: 3:5

Rotation angle, specified as a real scalar or vector.

Example: pi

Example: (1:3)*pi/2

More About

collapse all

Matrix Representation of z-Axis Rotation Gate

The matrix representation of a z-axis rotation gate applied to a target qubit with a rotation angle of θ is

[exp(iθ2)00exp(iθ2)].

Applying this gate with rotation angle θ=π is equivalent to applying a Pauli Z gate (zGate) up to a global phase factor.

This gate is also equivalent to the R1 gate (r1Gate) with a global phase difference.R1(θ)=exp(iθ2)[exp(iθ2)00exp(iθ2)]=exp(iθ2)Rz(θ)

Version History

Introduced in R2023a