Home Algorithms Commercialization Data Science Information Theories Quantum Theories Lab Linear Algebra
<< Measurement on Basis Vectors PDF QASM U Operators Derivation >>

$\require{cancel} \newcommand{\Ket}[1]{\left|{#1}\right\rangle} \newcommand{\Bra}[1]{\left\langle{#1}\right|} \newcommand{\Braket}[1]{\left\langle{#1}\right\rangle} \newcommand{\Rsr}[1]{\frac{1}{\sqrt{#1}}} \newcommand{\RSR}[1]{1/\sqrt{#1}} \newcommand{\Verti}{\rvert} \newcommand{\HAT}[1]{\hat{\,#1~}} \DeclareMathOperator{\Tr}{Tr}$

QASM $U$ Gates

First created in June 2018

Ref: https://arxiv.org/pdf/1707.03429.pdf
Open Quantum Assembly Language
Andrew W. Cross, Lev S. Biship, John A. Smolin, Jay M. Gambetta
January 10th, 2017

There are three single-qubit Universal Gates in QASM. They are abstract of the lower level physical implementation of Quantum Experience (and other implementations).

The abstration is encapsulated in the file "qelib1.inc".

They are defined as rotation around the $Z$ and $Y$ axes, without a global phase shift. So sometimes you may find some odd angles in addition to the parameters to compensate the globl phase shift.

This is not due to the definition of the $U$ gates but the description of them. The global phase shift does not affect the physical implementation as phase is relative. Nevertheless, the standardisation by means of a global phase shift helps the mathematics and thinking.

The Universal Gate

$\displaystyle U(\theta,\phi,\lambda):=R_z(\phi)~R_y(\theta)~R_z(\lambda) =\begin{bmatrix} e^{-i(\phi+\lambda)/2}\cos(\theta/2) & -e^{-i(\phi-\lambda)/2}\sin(\theta/2)\\ e^{i(\phi-\lambda)/2}\sin(\theta/2) & e^{i(\phi+\lambda)/2}\cos(\theta/2) \end{bmatrix} ,$ \quad where $R_y(\theta)=e^{-i\frac{\theta}{2}Y}$ and $R_z(\phi)=e^{-i\frac{\phi}{2}Z}.$

Note: The angles are for Bloch Sphere rotation about an axis. The magnitude is twice that on the vector space (the exponents), hence the $\theta/2$ exponent.

The Three $U$ Gates

The three $U$ gates in QASM are $u1$, $u2$ and $u3$. They are all derived from $U$ as described above. Details can be found in the QASM U Operators Derivation page.

To visualise the effect of a $U$ gate, on the Bloch Sphere rotate $\lambda$ (arg3) about axis $Z$, $\theta$ (arg1) about $Y$, then again $\phi$ (arg2) about $Z$.


$u_1(\lambda)$

$u_1(\lambda):= \begin{bmatrix} 1 & 0\\ 0 & e^{i\lambda} \end{bmatrix} \sim U(0,0,\lambda)=R_z(\lambda).$


$u_2(\phi,\lambda)$

$u_2(\phi,\lambda) :=U(\pi/2,\phi,\lambda) =\begin{bmatrix} e^{-i(\phi+\lambda)/2}\cos(\pi/4) & -e^{-i(\phi-\lambda)/2}\sin(\pi/4)\\ e^{i(\phi-\lambda)/2}\sin(\pi/4) & e^{i(\phi+\lambda)/2}\cos(\pi/4) \end{bmatrix}\\ =\Rsr2\begin{bmatrix} e^{-i(\phi+\lambda)/2} & -e^{-i(\phi-\lambda)/2} e^{i(\phi-\lambda)/2} & e^{i(\phi+\lambda)/2} \end{bmatrix}\\ \sim\Rsr2\begin{bmatrix} 1 & -e^{i\lambda}\\ e^{i\phi} & e^{i(\phi+\lambda)} \end{bmatrix} .$


$u_3(\theta,\phi,\lambda)$

$u_3(\theta, \phi,\lambda):=U(\theta, \phi,\lambda) =R_z(\phi+3\pi)~R_x(\pi/2)~R_z(\theta+\pi)~R_x(\pi/2)~R_z(\lambda)\\ \sim\begin{bmatrix} \cos\theta & -e^{i\lambda}\sin\theta\\ e^{i\phi}\sin\theta & e^{i(\phi+\lambda)}\cos\theta\\ \end{bmatrix} .$

Implementation Using $U$ Gates

Gate     $\theta$             $\phi$                 $\lambda$         $u_i$
$I$ 0 0 0 -
$X$ $\pi$ 0 $\pi$ 3
$Y$ $\pi$ $\pi/2$ $\pi/2$ 3
$Z$ 0 0 $\pi$ 1
$H$ $\pi/2$ 0 $\pi$ 2
$S$ 0 0 $\pi/2$ 1
$S^\dagger$ 0 0 $-\pi/2$ 1
$T$ 0 0 $\pi/4$ 1
$T^\dagger$ 0 0 $-\pi/4$ 1
$R_x$ arg $-\pi/2$ $\pi/2$ 3
$R_y$ arg 0 0 3
$R_z$ 0 0 arg 1

Examples

Evaluate $U(\pi/2,\pi/2,\pi/2)=R_z(\pi/2)R_y(\pi/2)R_z(\pi/2)$

Visualisation

Let us use $+Z$ and $+X$ as reference. After rotating $\pi/2$ about $Z$-axis, then $Y$-axis, then $Z$-axis, $+Z$ will be at $+Y$ and $+X$ at $-X$.

That means $U$ sends $\Ket0$ to $\Rsr2(\Ket0+i\Ket1)$, so the first column of $U$ is $[1,i]^T$.

$U$ also sends $\Rsr2(\Ket0+\Ket1)$ to $\Rsr2(\Ket0-\Ket1)$, so the sum of the first and second column ${[1+u_{12},i+u_{22}]}$ should have the two elements equal in value but opposite in sign. By observation, $u_{12}=-i$ and $u_{22}=-1$.

$U\sim\Rsr2\begin{bmatrix} 1 & -i\\ i & -1 \end{bmatrix} =\Rsr2(Z+Y).$

Matrix Substitution

$U(\pi/2,\pi/2,\pi/2) =\begin{bmatrix} e^{-i\pi/2}\cos(\pi/4) & -e^0\sin(\pi/4)\\ e^0\sin(\pi/4) & e^{i\pi/2}\cos(\pi/4)\\ \end{bmatrix} =\Rsr2\begin{bmatrix} -i & -1\\ 1 & i\\ \end{bmatrix} =-i\Rsr2\begin{bmatrix} 1 & -i\\ i & -1\\ \end{bmatrix}\\ \sim\Rsr2\begin{bmatrix} 1 & -i\\ i & -1\\ \end{bmatrix} =\Rsr2(Z+Y).$

Matrix Product

$R_z(\pi/2)=e^{-i\pi Z/4}=\cos(-\pi/4)I+i\sin(-\pi/4)Z=\Rsr2(I-iZ)= \Rsr2 \begin{bmatrix} 1-i & 0\\ 0 & 1+i \end{bmatrix}$

$R_y(\pi/2)=e^{-i\pi Y/4}=\cos(-\pi/4)I+i\sin(-\pi/4)Y=\Rsr2(I-iY)= \Rsr2 \begin{bmatrix} 1 & -1\\ 1 & 1 \end{bmatrix}$

$U(\pi/2,\pi/2,\pi/2) =\Rsr2 \begin{bmatrix} 1-i & 0\\ 0 & 1+i \end{bmatrix} \Rsr2 \begin{bmatrix} 1 & -1\\ 1 & 1 \end{bmatrix} \Rsr2 \begin{bmatrix} 1-i & 0\\ 0 & 1+i \end{bmatrix}$

$={1\over2\sqrt2} \begin{bmatrix} 1-i & 0\\ 0 & 1+i \end{bmatrix} \begin{bmatrix} 1-i & -1-i\\ 1-i & 1+i \end{bmatrix} ={1\over2\sqrt2} \begin{bmatrix} -2i & -2\\ 2 & 2i \end{bmatrix} \sim\Rsr2 \begin{bmatrix} 1 & -i\\ i & -1 \end{bmatrix} =\Rsr2(Z+Y) .$

Exponents

$U(\pi/2,\pi/2,\pi/2)=e^{-iZ\pi/4}e^{-iY\pi/4}e^{-iZ\pi/4}$

$R_z(\pi/2)=e^{-i\pi Z/4}=\cos(-\pi/4)I+i\sin(-\pi/4)Z=\Rsr2(I-iZ)$

$R_y(\pi/2)=e^{-i\pi Y/4}=\cos(-\pi/4)I+i\sin(-\pi/4)Y=\Rsr2(I-iY)$

$U(\pi/2,\pi/2,\pi/2) =\Rsr2(I-iZ)\Rsr2(I-iY)\Rsr2(I-iZ)$

$={1\over2\sqrt2}(I-iZ-iY-YZ-iZ-Z^2-ZY+iZYZ)$

$={1\over2\sqrt2}(I-iZ-iY-iX-iZ-I+iX-iY) ={1\over2\sqrt2}(-iZ-iY-iZ-iY) \sim\Rsr2(Z+Y) .$

 

<< Measurement on Basis Vectors Top QASM U Operators Derivation >>