mimiqcircuits.operations.gates.standard.interactions

Interaction gates (RXX, RYY, RZZ, RZX, XX+YY, XX-YY).

Classes

GateRXX(theta)

Two qubit RXX gate, a rotation generated by \(X \otimes X\).

GateRYY(theta)

Two qubit RYY gate, a rotation generated by \(Y \otimes Y\).

GateRZX(theta)

Two qubit RZX gate, a rotation generated by \(Z \otimes X\).

GateRZZ(theta)

Two qubit RZZ gate, a rotation generated by \(Z \otimes Z\).

GateXXminusYY(theta, beta)

Two qubit parametric XX-YY gate.

GateXXplusYY(theta, beta)

Two qubit parametric XX+YY gate.

class GateRXX(theta)[source]

Bases: Gate

Two qubit RXX gate, a rotation generated by \(X \otimes X\).

The gate is symmetric in its two qubits and is maximally entangling at \(\theta = \frac{\pi}{2}\).

Matrix Representation

\[\begin{split}\operatorname{RXX}(\theta) = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 & 0 & -i\sin(\frac{\theta}{2}) \\ 0 & \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2}) & 0 \\ 0 & -i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) & 0 \\ -i\sin(\frac{\theta}{2}) & 0 & 0 & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:

theta – Rotation angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta = Symbol('theta')
>>> GateRXX(theta)
RXX(theta)
>>> GateRXX(theta).matrix()
[cos((1/2)*theta), 0, 0, -I*sin((1/2)*theta)]
[0, cos((1/2)*theta), -I*sin((1/2)*theta), 0]
[0, -I*sin((1/2)*theta), cos((1/2)*theta), 0]
[-I*sin((1/2)*theta), 0, 0, cos((1/2)*theta)]

>>> c = Circuit().push(GateRXX(theta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── RXX(theta) @ q[0:1]

>>> GateRXX(theta).power(2), GateRXX(theta).inverse()
(RXX(theta)**2, RXX(-theta))
>>> GateRXX(theta).decompose()
2-qubit circuit with 7 instructions:
├── H @ q[0]
├── H @ q[1]
├── CX @ q[0], q[1]
├── RZ(theta) @ q[1]
├── CX @ q[0], q[1]
├── H @ q[1]
└── H @ q[0]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

class GateRYY(theta)[source]

Bases: Gate

Two qubit RYY gate, a rotation generated by \(Y \otimes Y\).

The gate is symmetric in its two qubits and is maximally entangling at \(\theta = \frac{\pi}{2}\).

Matrix Representation

\[\begin{split}\operatorname{RYY}(\theta) = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 & 0 & i\sin(\frac{\theta}{2}) \\ 0 & \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2}) & 0 \\ 0 & -i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) & 0 \\ i\sin(\frac{\theta}{2}) & 0 & 0 & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:

theta – Rotation angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta = Symbol('theta')
>>> GateRYY(theta)
RYY(theta)
>>> GateRYY(theta).matrix()
[cos((1/2)*theta), 0, 0, I*sin((1/2)*theta)]
[0, cos((1/2)*theta), -I*sin((1/2)*theta), 0]
[0, -I*sin((1/2)*theta), cos((1/2)*theta), 0]
[I*sin((1/2)*theta), 0, 0, cos((1/2)*theta)]

>>> c = Circuit().push(GateRYY(theta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── RYY(theta) @ q[0:1]

>>> GateRYY(theta).power(2), GateRYY(theta).inverse()
(RYY(theta)**2, RYY(-theta))
>>> GateRYY(theta).decompose()
2-qubit circuit with 7 instructions:
├── RX((1/2)*pi) @ q[0]
├── RX((1/2)*pi) @ q[1]
├── CX @ q[0], q[1]
├── RZ(theta) @ q[1]
├── CX @ q[0], q[1]
├── RX((-1/2)*pi) @ q[0]
└── RX((-1/2)*pi) @ q[1]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

class GateRZZ(theta)[source]

Bases: Gate

Two qubit RZZ gate, a rotation generated by \(Z \otimes Z\).

The gate is symmetric in its two qubits and is maximally entangling at \(\theta = \frac{\pi}{2}\).

Matrix Representation

\[\begin{split}\operatorname{RZZ}(\theta) = \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0 \\ 0 & e^{i\frac{\theta}{2}} & 0 & 0 \\ 0 & 0 & e^{i\frac{\theta}{2}} & 0 \\ 0 & 0 & 0 & e^{-i\frac{\theta}{2}} \end{pmatrix}\end{split}\]
Parameters:

theta – Rotation angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta = Symbol('theta')
>>> GateRZZ(theta)
RZZ(theta)
>>> GateRZZ(theta).matrix()
[exp(-1/2*I*theta), 0, 0, 0]
[0, exp(1/2*I*theta), 0, 0]
[0, 0, exp(1/2*I*theta), 0]
[0, 0, 0, exp(-1/2*I*theta)]

>>> c = Circuit().push(GateRZZ(theta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── RZZ(theta) @ q[0:1]

>>> GateRZZ(theta).power(2), GateRZZ(theta).inverse()
(RZZ(theta)**2, RZZ(-theta))
>>> GateRZZ(theta).decompose()
2-qubit circuit with 3 instructions:
├── CX @ q[0], q[1]
├── RZ(theta) @ q[1]
└── CX @ q[0], q[1]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

class GateRZX(theta)[source]

Bases: Gate

Two qubit RZX gate, a rotation generated by \(Z \otimes X\).

The \(Z\) acts on the first qubit and the \(X\) on the second. The gate is maximally entangling at \(\theta = \frac{\pi}{2}\).

Matrix Representation

\[\begin{split}\operatorname{RZX}(\theta) = \begin{pmatrix} \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2}) & 0 & 0 \\ -i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) & 0 & 0 \\ 0 & 0 & \cos(\frac{\theta}{2}) & i\sin(\frac{\theta}{2}) \\ 0 & 0 & i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:

theta – Rotation angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta = Symbol('theta')
>>> GateRZX(theta)
RZX(theta)
>>> GateRZX(theta).matrix()
[cos((1/2)*theta), -I*sin((1/2)*theta), 0, 0]
[-I*sin((1/2)*theta), cos((1/2)*theta), 0, 0]
[0, 0, cos((1/2)*theta), I*sin((1/2)*theta)]
[0, 0, I*sin((1/2)*theta), cos((1/2)*theta)]

>>> c = Circuit().push(GateRZX(theta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── RZX(theta) @ q[0:1]

>>> GateRZX(theta).power(2), GateRZX(theta).inverse()
(RZX(theta)**2, RZX(-theta))
>>> GateRZX(theta).decompose()
2-qubit circuit with 5 instructions:
├── H @ q[1]
├── CX @ q[0], q[1]
├── RZ(theta) @ q[1]
├── CX @ q[0], q[1]
└── H @ q[1]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

class GateXXplusYY(theta, beta)[source]

Bases: Gate

Two qubit parametric XX+YY gate.

Also known as an XY gate. It rotates coherently between \(|01\rangle\) and \(|10\rangle\) and leaves \(|00\rangle\) and \(|11\rangle\) unchanged.

Matrix Representation

\[\begin{split}\operatorname{(XX+YY)}(\theta, \beta)= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2})e^{i\beta} & 0\\ 0 & -i\sin(\frac{\theta}{2})e^{-i\beta} & \cos(\frac{\theta}{2}) & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]
Parameters:
  • theta – Rotation angle in radians, numeric or symbolic.

  • beta – Phase angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta, beta = symbols('theta beta')
>>> GateXXplusYY(theta, beta)
XXplusYY(theta, beta)
>>> GateXXplusYY(theta, beta).matrix()
[1.0, 0, 0, 0]
[0, cos((1/2)*theta), -I*exp(I*beta)*sin((1/2)*theta), 0]
[0, -I*exp(-I*beta)*sin((1/2)*theta), cos((1/2)*theta), 0]
[0, 0, 0, 1.0]

>>> c = Circuit().push(GateXXplusYY(theta, beta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── XXplusYY(theta, beta) @ q[0:1]

>>> GateXXplusYY(theta, beta).power(2), GateXXplusYY(theta, beta).inverse()
(XXplusYY(theta, beta)**2, XXplusYY(-theta, beta))
>>> GateXXplusYY(theta, beta).decompose()
2-qubit circuit with 14 instructions:
├── RZ(beta) @ q[0]
├── RZ((-1/2)*pi) @ q[1]
├── SX @ q[1]
├── RZ((1/2)*pi) @ q[1]
├── S @ q[0]
├── CX @ q[1], q[0]
├── RY((-1/2)*theta) @ q[1]
├── RY((-1/2)*theta) @ q[0]
├── CX @ q[1], q[0]
├── S† @ q[0]
├── RZ((-1/2)*pi) @ q[1]
├── SX† @ q[1]
├── RZ((1/2)*pi) @ q[1]
└── RZ(-beta) @ q[0]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

class GateXXminusYY(theta, beta)[source]

Bases: Gate

Two qubit parametric XX-YY gate.

It rotates coherently between \(|00\rangle\) and \(|11\rangle\) and leaves \(|01\rangle\) and \(|10\rangle\) unchanged.

Matrix Representation

\[\begin{split}\operatorname{(XX-YY)}(\theta, \beta)=\begin{pmatrix} \cos(\frac{\theta}{2}) & 0 & 0 & -i\sin(\frac{\theta}{2})e^{-i\beta} \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ -i\sin(\frac{\theta}{2})e^{i\beta} & 0 & 0 & \cos(\frac{\theta}{2}) \end{pmatrix}\end{split}\]
Parameters:
  • theta – Rotation angle in radians, numeric or symbolic.

  • beta – Phase angle in radians, numeric or symbolic.

Examples

>>> from mimiqcircuits import *
>>> from symengine import *
>>> theta, beta = symbols('theta beta')
>>> GateXXminusYY(theta, beta)
XXminusYY(theta, beta)
>>> GateXXminusYY(theta, beta).matrix()
[cos((1/2)*theta), 0, 0, -I*exp(-I*beta)*sin((1/2)*theta)]
[0, 1.0, 0, 0]
[0, 0, 1.0, 0]
[-I*exp(I*beta)*sin((1/2)*theta), 0, 0, cos((1/2)*theta)]

>>> c = Circuit().push(GateXXminusYY(theta, beta), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── XXminusYY(theta, beta) @ q[0:1]

>>> GateXXminusYY(theta, beta).power(2), GateXXminusYY(theta, beta).inverse()
(XXminusYY(theta, beta)**2, XXminusYY(-theta, beta))
>>> GateXXminusYY(theta, beta).decompose()
2-qubit circuit with 14 instructions:
├── RZ(-beta) @ q[1]
├── RZ((-1/2)*pi) @ q[0]
├── SX @ q[0]
├── RZ((1/2)*pi) @ q[0]
├── S @ q[1]
├── CX @ q[0], q[1]
├── RY((1/2)*theta) @ q[0]
├── RY((-1/2)*theta) @ q[1]
├── CX @ q[0], q[1]
├── S† @ q[1]
├── RZ((-1/2)*pi) @ q[0]
├── SX† @ q[0]
├── RZ((1/2)*pi) @ q[0]
└── RZ(beta) @ q[1]
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.