User:Irvings1/Quantum algorithm for linear systems of equations

The Quantum algorithm for linear systems of equations, designed by Aram Harrow, Avinatan Hassidim, and Seth Lloyd, is a quantum algorithm for solving linear systems formulated in 2009. The algorithm estimates the result of a scalar measurement on the solution vector to a given linear system of equations.

The algorithm is one of the main fundamental algorithms expected to provide an exponential speedup over their classical counterparts, along with Shor's factoring algorithm and Feyman's quantum simulation algorithm. Provided the linear system is an sparse and has a low condition number $$\kappa$$, and the user is interested in the result of a scalar measurement on the solution vector, and not the values of the solution vector itself, the algorithm has a runtime of O(logN*k^2), offering an exponential speedup over the fastest classical algorithm, which runs in O(N*sqrt(k)), where $$N$$ is the number of variables in the linear system.

An implementation of the quantum algorithm for linear systems of equations was first demonstrated in 2013 by both Barz et al. and Pan et al in parallel. The demonstrations consisted of simple linear equations on specially designed quantum devices.

Due to the prevalence of linear systems in virtually all areas of science and engineering, the quantum algorithm for linear systems of equations has the potential to be the most practically useful quantum algorithms conceived so far. This is an important milestone for quantum computing, as previous algorithms offering exponential speedup do not have versatility or obvious real-world applications.

Procedure
The problem we are trying to solve is: given a Hermitian $$NxN$$ matrix $$A$$ and a unit vector $$\overrightarrow{b}$$, find the solution vector $$\overrightarrow{x}$$ satisfying $$A\overrightarrow{x}=\overrightarrow{b}$$. This algorithm assumes that the user is not interested in the values of $$\overrightarrow{x}$$ itself, but rather the result of applying some operator $$M$$ onto x, $$\langle x|M|x\rangle$$.

First, the algorithm represents the vector $$\overrightarrow{b}$$ as a quantum state of the form:
 * $$|b\rangle=\sum_{i \mathop =1}^N b_i|i\rangle$$.

Next, Hamiltonian simulation techniques are used to apply the unitary operator $$e^{iAt}$$ to $$|b\rangle$$ for a superposition of different times $$t$$. The ability to decompose $$|b\rangle$$ into the eigenbasis of $$A$$ and to find the corresponding eigenvalues $$\lambda_j$$ is facilitated by the use of quantum phase estimation.

The state of the system after this decomposition is approximately:
 * $$\sum_{j \mathop =1}^N \beta_j|u_j\rangle|\lambda_j\rangle$$,

where $$u_j$$ is the eigenvector basis of $$A$$, and $$|b\rangle=\sum_{j \mathop =1}^N \beta_j|u_j\rangle$$.

We would then like to perform the linear map taking $$|\lambda_j\rangle$$ to $$C\lambda^{-1}_j|\lambda_j\rangle$$, where $$C$$ is a normalizing constant. The linear mapping operation is not unitary and thus will require a number of repetitions as it has some probability of failing. After it succeeds, we uncompute the $$|\lambda_j\rangle$$ register and are left with a state proportional to:


 * $$\sum_{i \mathop =1}^N \beta_i\lambda^{-1}_j|u_j\rangle=A^{-1}|b\rangle=|x\rangle$$,

Where $$|x\rangle$$ is a quantum-mechanical representation of the desired solution vector $$x$$. To read out all components of x would require the procedure be repeated at least $$N$$ times. However, it is often the case that one is not interested in $$x$$ itself, but rather some expectation value of a linear operator M acting on x. By mapping M to a quantum-mechanical operator and performing the quantum measurement corresponding to M, we obtain an estimate of the expectation value $$\langle x|M|x\rangle$$. This allows for a wide variety of features of the vector x to be extracted including normalization, weights in different parts of the state space, and moments without actually computing all the values of the solution vector x.

Initialization
Firstly, the algorithm requires that the matrix $$A$$ be Hermitian so that it can be converted into a unitary operator. In the case were $$A$$ is not Hermitian, define
 * $$\mathbf{C} = \begin{bmatrix}

0 & A \\ A^t & 0 \end{bmatrix}. $$

As $$C$$ is Hermitian, the algorithm can now be used to solve $$Cy=\begin{bmatrix} b \\ 0   \end{bmatrix}. $$ to obtain $$y = \begin{bmatrix} 0 \\    x    \end{bmatrix} $$.

Secondly, The algorithm requires an efficient procedure to prepare $$|b\rangle$$, the quantum representation of b. It is assumed that there exists some linear operator $$B$$ that can take some arbitrary quantum state $$|initial\rangle$$ to $$|b\rangle$$ efficiently or that this algorithm is a subroutine in a larger algorithm and is given $$|b\rangle$$ as input. Any error in the preparation of state $$|b\rangle$$ is ignored.

Finally, the algorithm assumes that the state $$| \psi_0 \rangle $$ can be prepared efficiently. Where


 * $$| \psi_0 \rangle := \sqrt{2/T}*\sum_{\tau \mathop =0}^{T-1} sin{\pi(\tfrac{\tau+\tfrac{1}{2}}{T}})*|\tau\rangle$$

for some large $$T$$. The coefficients of $$| \psi_0 \rangle $$ are chosen to minimize a certain quadratic loss function which induces error in the $$U_{invert}$$ subroutine described below.

Phase Estimation
Phase estimation is used to transform the Hermitian matrix $$A$$ into a unitary operator, which can then be applied at will. This is possible if A is s-sparse and efficiently row computable, meaning it has at most s nonzero entries per row and given a row index these entries can be computed in time O(s). Under these assumptions, quantum phase estimation allows $$e^iAt$$ to be simulated in time $$O(log(N)s^2t)$$.

Uinvert Subroutine
The key subroutine to the algorithm, denoted $$U_{invert}$$, is defined as follows:

1. Prepare $$|\psi_0\rangle^C$$ on register C

2. Apply the conditional Hamiltonian evolution (sum)

3. Apply the Fourier transform to the register C. Denote the resulting basis states with $$|k\rangle$$ for k = 0,...,T-1. Define $$\lambda_k:=2\pi k/t_0$$.

4. Adjoin a three-dimensional register S in the state
 * $$|h(\lambda_k)\rangle^S := \sqrt{1-f(\lambda_k)^2-g(\lambda_k)^2}|nothing\rangle^S+f(\lambda_k)|well\rangle^S+g(\lambda_k)|ill\rangle^S$$,

5. Reverse steps 1-3, uncomputing any garbage produced along the way.

where functions f, g, are filter functions. The states 'nothing', 'well' and 'ill' are used to instruct the loop body on how to proceed; 'nothing' indicates that the desired matrix inversion has not yet taken place, 'well' indicates that the inversion has taken place and the loop should halt, and 'ill' indicates that part of $$|b\rangle$$ is in the ill-conditioned subspace of A and the algorithm will not be able to produce the desired inversion.

Main Loop
The body of the algorithm follows the amplitude amplification procedure: starting with $$U_{invert}B|initial\rangle$$, the following operation is repeatedly applied:
 * $$U_{invert}BR_{init}B^\dagger U^\dagger_{invert}R_{succ}$$

Where


 * $$R_{succ}=I^2-2|well\rangle\langle well|^2$$,

and


 * $$R_{init}=I^2-2|initial\rangle\langle initial|$$,

After each repetition, $$S$$ is measured and will produce a value of 'nothing', 'well', or 'ill' as described above. This loop is repeated until $$S$$ is measured, which occurs with a probability $$p$$. Rather than repeating $$\frac{1}{p}$$ times to minimize error, amplitude amplification is used to achieve the same error resilience using only $$O(\frac{1}{\sqrt{p}})$$ repetitions.

Scalar Measurement
After successfully measuring 'well' on $$S$$ the system will be in a state proportional to:


 * $$\sum_{i \mathop =1}^N \beta_i\lambda^{-1}_j|u_j\rangle=A^{-1}|b\rangle=|x\rangle$$.

Finally, we perform the quantum-mechanical operator corresponding to M and obtain an estimate of the value of $$\langle x|M|x\rangle$$.

Classical Efficiency
The best classical algorithm which produces the actual solution vector $$\overrightarrow{x}$$ is Gaussian Elimination, which runs in $$O(N^3)$$ time.

If A is s-sparse, where s is significantly smaller than N, then the Conjugate Gradient method can be used to find the solution vector $$\overrightarrow{x}$$ can be found in $$O(N*Log(N))$$ time by minimizing the quadratic function $$|A\overrightarrow{x} -\overrightarrow{b}|^2$$.

When only a summary statistic of the solution vector $$\overrightarrow{x}$$ is needed, as is the case for the quantum algorithm for linear systems of equations, a classical computer can find an estimate of $$\overrightarrow{x}^\dagger M \overrightarrow{x}$$ in $$O(N\sqrt{\kappa})$$.

Quantum Efficiency
The quantum algorithm for solving linear systems of equations originally proposed by Harrow et. al was shown to be $$O(\kappa^2logN)$$. The runtime of this algorithm was subsequently improved to $$O(\kappa log^3\kappa logN)$$ by Andris Ambainis.

Optimality
An important factor in the performance of the matrix inversion algorithm is the condition number of $$A$$ $$\kappa$$, which represents the ratio of $$A$$'s largest and smallest eigenvalues. As the condition number increases, the ease with which the solution vector can be found using gradient descent methods such as the conjugate gradient method decreases, as $$A$$ becomes closer to a matrix which cannot be inverted and the solution vector becomes less stable. This algorithm assumes that all elements of the matrix $$A$$ lie between $$\frac{1}{\kappa}$$ and 1, in which case the claimed run-time proportional to $$\kappa^2$$ will be achieved. Therefore, the speedup over classical algorithms is increased further when $$\kappa$$ is a $$poly(Log(N))$$.

If the run-time of the algorithm were made poly-logarithmic in $$\kappa$$ then problems solvable on n qubits could be solved in poly(n) time, causing the complexity class BQP to be equal to PSPACE.

Error Analysis
Performing the phase estimation, which is the dominant source of error, is done by simulating $$e^{iAt}$$. Assuming that $$A$$ is s-sparse, this can be done with an error bounded by a constant $$\epsilon$$, which will translate to the additive error achieved in the output state $$|x\rangle$$.

The phase estimation step errs by $$O(\frac{1}{t_0})$$ in estimating $$\lambda$$, which translates into a relative error of $$O(\frac{1}{\lambda t_0})$$ in $$\lambda^{-1}$$. If $$\lambda >= 1/\kappa $$, taking $$t_0=O({\kappa}{\epsilon})$$ induces a final error of $$\epsilon$$. This requires that the overall run-time efficiency be increased proportional to $$O(\frac{1}{\epsilon})$$ to minimize error.

Experimental Realization
While there does not yet exist a quantum computer that can truly offer a speedup over a classical computer, implementation of a "proof of concept" remains an important milestone in the developement of a new quantum algorithm. Demonstrating the quantum algorithm for linear systems of equations remained a challenge for years after its proposal until 2013 when it was demonstrated by both Barz et al. and Pan et al. in parallel.

Barz et al.
On February 5, 2013 Barz et al. demonstrated the quantum algorithm for linear systems of equations on a photonic quantum computing architecture. This implementation used two consecutive entangling gates ont he same pair of polarization-encoded qubits. Two separately controlled-NOT gates were realized where the successful operation of the first was heralded by a measurement of two ancillary photons. Barz et al. found that the fidelity in the obtained output state ranged from 64.7% to 98.1% due to the influence of higher-order emissions from spontaneous parametric down-conversion.

Pan et al.
On February 8, 2013 Pan et. al reported a proof-of-concept experimental demonstration of the quantum algorithm using a 4-qubit nuclear magnetic resonance quantum information processor. The implementation was tested using simple linear systems of only 2 variables. Across three experiments they obtain the solution vector with over 96% fidelity.

Applications
Quantum computers are devices that harness quantum mechanics to perform computations in ways that classical computers cannot. For certain problems, quantum algorithms supply exponential speedups over their classical counterparts, the most famous example being Shor's factoring algorithm. Few such exponential speedups are known, and those that are (such as the use of quantum computers to simulate other quantum systems) have so far found limited use outside the domain of quantum mechanics. This algorithm provides an exponentially faster method of estimating features of the solution of a set of linear equations, which is a problem ubiquitous in science an engineering, both on its own and as a subroutine in more complex problems.

Linear Differential Equation Solving
Domic Berry proposed a new algorithm for solving linear time dependent differential equations as an extension of the quantum algorithm for solving linear systems of equations. Berry provides an effcient algorithm for solving the full time evolution under sparse linear differential equations on a quantum computer.

Least-Squares Fitting
Wiebe et al. provide a new quantum algorithm to determine the quality of a least-squares fit in which a continuous function is used to approximate a set of discrete points by extending the quantum algorithm for linear systems of equations. As the amount of discrete points increases, the time required to produce a least-squares fit using even a quantum computer running a quantum state tomography algorithm becomes very large. Wiebe et al. find that in many cases, their algorithm can efficiently find a concise approximation of the data points, eliminating the need for the higher-complexity tomography algorithm.

Machine Learning and Big Data Analysis
Machine learning is the study of systems that can identify trends in data. Tasks in machine learning frequently nivolve manipulating and classifying a large volume of data in high-dimensional vector spaces. The runtime of classical machine learning algorithms is limited by a polynomial dependance on both the volume of data and the dimensions of the space. Quantum computers are capable of manipulating high-dimensional vectors using tensor product spaces are are thus the perfect platform for machine learning algorithms.

The quantum algorithm for linear systems of equations has been applied to a support vector machine, which is an optimized linear or non-linear binary classifier. A support vector machine can be used for supervised machine learning, in which training set of already classified data is available, or unsupervised machine learning, in which all data given to the system is unclassified. Rebentrost et al. show that a quantum support vector machine can be used for big data classification and achieve an exponential speedup over classical computers.