8.79: Solving Equations Using a Quantum Circuit
- Page ID
- 149080
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)This tutorial demonstrates the solution of two linear simultaneous equation using a quantum circuit. The circuit is taken from arXiv:1302.1210. See this reference for details on the experimental implementation of the circuit and also for a discussion of the potential of quantum solutions for systems of equations. Two other sources (arXiv:1302.1946 and 1302.4310) provide alternative quantum circuits and methods of implementation.
First we consider the conventional method of solving systems of linear equation for a particular matrix A and three different |b> vectors.
\[ \begin{matrix} A|x \rangle = b \rangle & |x \rangle = A^{-1} |b \rangle \end{matrix} \nonumber \]
\[ \begin{matrix} A = \begin{pmatrix} 1.5 & 0.5 \\ 0.5 & 1.5 \end{pmatrix} & b_1 = \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} & b_2 = \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} & b_3 = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \\ A^{-1} b_1 = \begin{pmatrix} 0.354 \\ 0.354 \end{pmatrix} & A^{-1} b_2 = \begin{pmatrix} 0.707 \\ -0.707 \end{pmatrix} & A^{-1} b_3 = \begin{pmatrix} 0.75 \\ -0.25 \end{pmatrix} \end{matrix} \nonumber \]
Next we show the quantum circuit (arXiv:1302.1210) that generates the same solutions. The Appendix considers two other equivalent circuits from this reference.
\[ \begin{matrix} |b \rangle & \triangleright & \fbox{R} & \cdot & \fbox{Rᵀ} & \triangleright & |x \rangle \\ ~ & ~ & ~ & | \\ |1 \rangle & \triangleright & \cdots & \fbox{Ry(θ)} & \fbox{M₁} & \triangleright & |1 \rangle \end{matrix} \nonumber \]
In this circuit, R is the matrix of eigenvectors of matrix A and RT its transpose. The last step on the bottom wire is the measurement of |1>, which is represented by the projection operator M1. The identity operator is required for cases in which a quantum gate operation is occurring on one wire and no operation is occurring on the other wire.
\[ \begin{matrix} \text{R = \eigenvecs(A)} & \text{R} = \begin{pmatrix} 0.707 & -0.707 \\ 0.707 & 0.707 \end{pmatrix} & \text{R}^T = \begin{pmatrix} 0.707 & 0.707 \\ -0.707 & 0.707 \end{pmatrix} & \text{M}_1 = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} \leftarrow \begin{pmatrix} 0 \\ 1 \end{pmatrix} \begin{pmatrix} 0 & 1 \end{pmatrix} & \text{I} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \end{matrix} \nonumber \]
The controlled rotation, CR(θ), is the only two-qubit gate in the circuit. The rotation angle required is determined by the ratio of the eigenvalues of A as shown below.
\[ \begin{matrix} \text{CR}( \theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos \left( \frac{ \theta}{2} \right) & - \sin \left( \frac{ \theta}{2} \right) \\ 0 & 0 & \sin \left( \frac{ \theta}{2} \right) & \cos \left( \frac{ \theta}{2} \right) \end{pmatrix} & \text{eigenvals(A)} = \begin{pmatrix} 2 \\ 1 \end{pmatrix} & \theta = -2 \text{acos} \left( \frac{1}{2} \right) \end{matrix} \nonumber \]
The input (|b>|1>) and output (|x>|1>) states are expressed in tensor format. Kronecker is Mathcad's command for the tensor product of matrices.
\[ \begin{matrix} \text{Input } |b \rangle |1 \rangle & \text{Quantum Circuit} & \text{Output } |x \rangle |1 \rangle \\ \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 1 \end{pmatrix} & \text{kronecker}(R^T,~ M_1) \text{CR} ( \theta) \text{kronecker(R, I)} \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.354 \\ 0 \\ 0.354 \end{pmatrix} & \begin{pmatrix} 0.354 \\ 0.354 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \\ \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ -1 \end{pmatrix} & \text{kronecker}(R^T,~ M_1) \text{CR} ( \theta) \text{kronecker(R, I)} \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ -1 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.707 \\ 0 \\ -0.707 \end{pmatrix} & \begin{pmatrix} 0.707 \\ -0.707 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \\ \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} & \text{kronecker}(R^T,~M_1) \text{CR} ( \theta) \text{kronecker(R, I)} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.75 \\ 0 \\ -0.25 \end{pmatrix} & \begin{pmatrix} 0.75 \\ -0.25 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \end{matrix} \nonumber \]
Appendix
The alternative two-wire circuit shown in Fig. 1C requires CNOT and Ry rotation matrices.
\[ \begin{matrix} |b \rangle & \triangleright & \fbox{R} & \cdot & \cdots & \cdot & \fbox{Rᵀ} & \cdots & \triangleright & |x \rangle \\ ~ & ~ & ~ & | & ~ & | \\ |1 \rangle & \triangleright & \cdots & oplus & \fbox{Ry(θ/2)} & \oplus & \fbox{Ry (θ/2)} & \fbox{M₁} & \triangleright & |1 \rangle \end{matrix} \nonumber \]
The quantum circuit is set up as follows. The input and output states are the same as the previous circuit.
\[ \text{QuantumCircuit} = \text{kronecker(I, M}_1) \text{kronecker} \left( \text{R}^T,~\text{Ry} \left( \frac{ \theta}{2} \right) \right) \text{CNOT kronecker} \left( \text{I, Ry} \left( \frac{- \theta}{2} \right) \right) \text{CNOT kronecker(R, I)} \nonumber \]
The three-wire circuit Fig. 1B produces the following transformation: \( |b \rangle |0 \rangle |1 \rangle \rightarrow |x \rangle |0 \rangle |1 \rangle\).
\[ \begin{matrix} |b \rangle & \triangleright & \fbox{R} & \cdot & \cdots & \cdot & \fbox{Rᵀ} & \cdots & \triangleright & |x \rangle \\ ~ & ~ & ~ & | & ~ & | \\ |0 \rangle & \triangleright & \cdots & \oplus & \cdot & \oplus & \cdots & \triangleright & |0 \rangle \\ ~ & ~ & ~ & ~ & | \\ |1 \rangle & \triangleright & \cdots & oplus & \fbox{Ry(θ/2)} & \oplus & \fbox{Ry (θ/2)} & \fbox{M₁} & \triangleright & |1 \rangle \end{matrix} \nonumber \]
\[ \begin{matrix} \text{Input } |b \rangle |0 \rangle |1 \rangle & \text{Quantum Circuit} & \text{Output } |x \rangle |0 \rangle |1 \rangle \\ \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} & \text{QC} \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.354 \\ 0 \\ 0 \\ 0 \\ 0.354 \\ 0 \\ 0 \end{pmatrix} & \begin{pmatrix} 0.354 \\ 0.354 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \\ \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ -1 \\ 0 \\ 0 \end{pmatrix} & \text{QC} \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ -1 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.707 \\ 0 \\ 0 \\ 0 \\ 0.707 \\ 0 \\ 0 \end{pmatrix} & \begin{pmatrix} 0.707 \\ -0.707 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \\ \frac{1}{ \sqrt{2}} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{pmatrix} & \text{QC} \frac{1}{ \sqrt{2}} \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 0.75 \\ 0 \\ 0 \\ 0 \\ -0.25 \\ 0 \\ 0 \end{pmatrix} & \begin{pmatrix} 0.75 \\ -0.25 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 \\ 1 \end{pmatrix} \end{matrix} \nonumber \]