Skip to content

Instantly share code, notes, and snippets.

@taketakeyyy
Created April 17, 2023 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taketakeyyy/8382c232214ee91e282a7ee5987ecfb1 to your computer and use it in GitHub Desktop.
Save taketakeyyy/8382c232214ee91e282a7ee5987ecfb1 to your computer and use it in GitHub Desktop.
グローバーのアルゴリズムの振幅増幅したときの振幅を計算
"""1回反復したときの「|w> の振幅」と「それ以外の振幅」を計算して返す"""
def calc_amplitude(n, w_amp, other_amp):
# |w>の符号を反転させる
w_amp = -w_amp
# 振幅の平均を求める
mu = (other_amp*(2**n-1) + w_amp) / (2**n)
# 平均周りで振幅を反転させる
w_amp = mu + (mu - w_amp)
other_amp = mu + (mu - other_amp)
return w_amp, other_amp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment