HHL算法的QISKit实现

本实现基于IBM QISKit 0.7.0版本,python 3.7版本。

HHL Experiment (Quantum Algorithm for linear systems of equations)

This experiment is implemented based on IBM QISKit version 0.7.0. It is a quantum implementation of finding x ⃗ \vec{x} x satisfying A x ⃗ = b ⃗ A\vec{x}=\vec{b} Ax =b , and only for the case when A A A is a 2 by 2 matrx, while b ⃗ \vec{b} b is a 2 by 1 vector.

The whole process can be divided into several steps:

  1. Quantum phase estimation
  2. Controlled rotation
  3. Inverse quantum phase estimation

The quantum circuit for this experiment is (from reference3):

circuit

The first qubit ∣ x 1 ⟩ |x_1 \rangle x1 is the ancilla register for controlled rotation. The second and third qubit ∣ x 2 x 3 ⟩ |x_2x_3\rangle x2x3 (the register C) will save the superposition of the eigenvalues of A, after the quantum phase estimation. The forth qubit ∣ x 4 ⟩ |x_4 \rangle x4 is used to save ∣ b ⟩ |b \rangle b, and after the whole process of HHL, it will save the approximate value of x ⃗ \vec{x} x .

# Import packages
%matplotlib inline
from qiskit import QuantumCircuit, ClassicalRegister, QuantumRegister
from qiskit import execute
from qiskit import BasicAer
from math import pi
from qiskit.tools.visualization import plot_histogram

import warnings  # Ignore the warning message
warnings.filterwarnings('ignore')

The known A A A and b ⃗ \vec{b} b are set like this in this experiment:

A = 1 2 ( 3 1 1 3 ) A=\frac{1}{2}\begin{pmatrix} 3 & 1\\ 1 & 3 \end{pmatrix} A=21(3113) and b ⃗ = ( b 1 b 2 ) \vec{b}=\begin{pmatrix} b_1\\ b_2 \end{pmatrix} b =(b1b2).

b ⃗ \vec{b} b can be encoded in a quantum state that ∣ b ⟩ = b 1 ∣ 0 ⟩ + b 2 ∣ 1 ⟩ |b \rangle = b_1|0 \rangle+b_2|1 \rangle b=b10+b21, which fulfills b 1 2 + b

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值