3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sympy で量子フーリエ変換

Posted at

量子フーリエ変換

量子フーリエ変換は、ただの量子ゲートである。特にカスタマイズポイントや、バリエーションがないので、sympy で簡単に利用できる。

>>> from sympy.physics.quantum.qft import QFT
>>> QFT2 = QFT(0,1) # QFT for 1-qubit
>>> QFT4 = QFT(0,2) # QFT for 2-qubit
>>> QFT8 = QFT(0,3) # QFT for 3-qubit

量子フーリエ変換に親しむ

Lesson1. QFT2 はアダマールゲートである

>>> from sympy.physics.quantum.qft import QFT
>>> from sympy.physics.quantum.qubit import Qubit
>>> from sympy.physics.quantum.qapply import qapply
>>> from sympy.physics.quantum.represent import represent

>>> QFT2 = QFT(0,1)
>>> qapply(QFT2 * Qubit('0'))
sqrt(2)*|0>/2 + sqrt(2)*|1>/2
>>> qapply(QFT2 * Qubit('1'))
sqrt(2)*|0>/2 - sqrt(2)*|1>/2

Lesson2. QFT は周期の逆数を導出する

周期2 の状態 (例: |0> + |4>) を入れると周期が 4の状態 が出てくるなど。

>>> from sympy.physics.quantum.qft import QFT
>>> from sympy.physics.quantum.qubit import Qubit
>>> from sympy.physics.quantum.qapply import qapply
>>>
>>> QFT8 = QFT(0,3) # QFT for 3-qubit
>>> qapply( QFT8*(Qubit('000')))
sqrt(2)*|000>/4 + sqrt(2)*|001>/4 + sqrt(2)*|010>/4 + sqrt(2)*|011>/4 + sqrt(2)*|100>/4 + sqrt(2)*|101>/4 + sqrt(2)*|110>/4 + sqrt(2)*|111>/4
>>> qapply( QFT8*(Qubit('000')+Qubit('100')))
sqrt(2)*|000>/2 + sqrt(2)*|010>/2 + sqrt(2)*|100>/2 + sqrt(2)*|110>/2
>>> qapply( QFT8*(Qubit('000')+Qubit('010')+Qubit('100')+Qubit('110')))
sqrt(2)*|000> + sqrt(2)*|100>

Lesson3. 入力にオフセットをつけるとよく似た出力になる

オフセットの違う入力(例: |0> + |4>|1> + |5> ) を入れると、よく似た出力が得られる。

>>> from sympy.physics.quantum.qft import QFT
>>> from sympy.physics.quantum.qubit import Qubit
>>> from sympy.physics.quantum.qapply import qapply

>>> QFT8 = QFT(0,3) # QFT for 3-qubit
>>> qapply( QFT8*(Qubit('000')+Qubit('100')))
sqrt(2)*|000>/2 + sqrt(2)*|010>/2 + sqrt(2)*|100>/2 + sqrt(2)*|110>/2
>>> qapply( QFT8*(Qubit('001')+Qubit('101')))
sqrt(2)*|000>/2 + sqrt(2)*I*|010>/2 - sqrt(2)*|100>/2 - sqrt(2)*I*|110>/2
>>> qapply( QFT8*(Qubit('010')+Qubit('110')))
sqrt(2)*|000>/2 - sqrt(2)*|010>/2 + sqrt(2)*|100>/2 - sqrt(2)*|110>/2

参考: https://www.appi.keio.ac.jp/Itoh_group/abe/pdf/qc6.pdf

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?