Created
April 17, 2023 17:31
-
-
Save taketakeyyy/8382c232214ee91e282a7ee5987ecfb1 to your computer and use it in GitHub Desktop.
グローバーのアルゴリズムの振幅増幅したときの振幅を計算
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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