Home | Algorithms | Commercialization | Data Science | Information Theories | Quantum Theories | Lab | Linear Algebra |
<< Controlled Gates | Error Bars >> |
$\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}$
First created in September 2018
Can we express various controlled operations as an eigenvalue, like $cZ\Ket{x_1x_2}=(-1)^{x_1x_2}\Ket{x_1x_2}~$?
In the following, $\Ket x=\Ket{x_1x_2\ldots x_n}$ and $\Ket y=\Ket{y_1y_2\ldots y_n}$.
$cZ=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&-1\end{bmatrix}.~~~~ cZ\Ket x=(-1)^{x_1x_2}\Ket x =\left\{ \begin{matrix} [1,0,0,0]^T\ldots\text{when }\Ket x=\Ket{00}\\ [0,1,0,0]^T\ldots\text{when }\Ket x=\Ket{01}\\ [0,0,1,0]^T\ldots\text{when }\Ket x=\Ket{10}\\ [0,0,0,-1]^T\ldots\text{when }\Ket x=\Ket{11} \end{matrix} \right. .$
So all basis vector $\Ket x$ is an eigenvector with eigenvalue $(-1)^{x_1x_2}.$
$c^nZ\Ket x=(-1)^{x_1x_2\ldots x_n}\Ket x.~~$ This means a negative phase is generated when all qubits are $\Ket1$.
$cS=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&i\end{bmatrix}.~~~~ cS\Ket x=i^{x_1x_2}\Ket x =\left\{ \begin{matrix} [1,0,0,0]^T\ldots\text{when }\Ket x=\Ket{00}\\ [0,1,0,0]^T\ldots\text{when }\Ket x=\Ket{01}\\ [0,0,1,0]^T\ldots\text{when }\Ket x=\Ket{10}\\ [0,0,0,i]^T\ldots\text{when }\Ket x=\Ket{11} \end{matrix} \right. .$
So all basis vector $\Ket x$ is an eigenvector with eigenvalue $i^{x_1x_2}.$
$c^nS\Ket x=i^{x_1x_2\ldots x_n}\Ket x.~~$ This means a phase of $\pi/2$ is generated when all qubits are $\Ket1$.
Generally, a controlled-phase shift gate $cR_\phi=\begin{bmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&e^{i\phi}\end{bmatrix}.~~~~ cR_\phi\Ket x=e^{i\phi\cdot x_1x_2}\Ket x .$
$c^nR_\phi\Ket x=e^{i\phi\cdot x_1x_2\ldots x_n}\Ket x.~~$ This means a phase of $\phi$ is generated when all qubits are $\Ket1$.
# Initialisation
import sys
sys.path.append('../')
from qtol import *
# Iteration
# Number of qubits
qbNum = 1
# Define the Quantum and Classical Registers
q = QuantumRegister(qbNum)
c = ClassicalRegister(qbNum)
qc = QuantumCircuit(q, c)
# Preparation
qc.iden(q)
# Circuit building
# ...
# Finalisation
# ...
show_me(qc, q, c, show_latex=True, show_bloch_vector=True, show_histogram=True)
circuit_drawer(qc)
<< Controlled Gates | Top | Error Bars >> |