Main Content

crxGate

Controlled x-axis rotation gate

Since R2023a

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

Description

example

g = crxGate(controlQubit,targetQubit,theta) applies a controlled x-axis rotation gate to a target qubit based on the state of a control qubit and returns a quantum.gate.SimpleGate object. If the control qubit is in the |0 state, then this gate does nothing. If the control qubit is in the |1 state, then this gate rotates the target qubit state around the x-axis by an angle of theta.

  • If controlQubit, targetQubit, and theta are vectors of the same length, crxGate returns a column vector of gates, where g(i) represents a controlled x-axis rotation gate applied to the ith element triplet of controlQubit, targetQubit, and theta.

  • If any of controlQubit, targetQubit, or theta is a scalar, and at least one of the inputs is a vector, then MATLAB® expands the scalar to match the size of the vector input.

  • The qubit indices in each element pair of controlQubit and targetQubit must not be the same.

Examples

collapse all

Create a controlled x-axis rotation gate that acts on a control qubit with index 1 and a target qubit with index 2 using a rotation angle of pi/2.

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

  SimpleGate with properties:

             Type: "crx"
    ControlQubits: 1
     TargetQubits: 2
           Angles: 1.5708

Get the matrix representation of the gate.

M = getMatrix(g)
M =

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

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

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

  3×1 SimpleGate array with gates:

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

Input Arguments

collapse all

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

Example: 2

Example: 6:8

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 Controlled x-Axis Rotation Gate

The matrix representation of a controlled x-axis rotation gate applied to control qubit 1 and target qubit 2 with a rotation angle of θ is

[1000010000cos(θ2)isin(θ2)00isin(θ2)cos(θ2)].

Version History

Introduced in R2023a