Skip to main content
Chemistry LibreTexts

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}}\)

    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 \]


    This page titled 8.79: Solving Equations Using a Quantum Circuit is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Frank Rioux via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.