以下の行列を時間ごとに作用させる、単純で簡単なはずのコードがなぜか計算されず、理由がわからずに悩んでいます。
python
1 2import numpy as np 3import matplotlib.pyplot as plt 4import math 5 6n=3 7m=3 8 9x_list=[] 10t_list=[] 11theta=3*(math.pi)/12 12new_phi=[] 13new_new_phi=[] 14final_phi=[] 15 16for i in range(0,2*n+1): 17 a=[0,0] 18 new_phi.append(a) 19 new_new_phi.append(a) 20 final_phi.append(a) 21 22def quantumcoin(theta): #この行列をn回作用させたい 23 C = [[np.cos(theta),-np.sin(theta)],[np.sin(theta),np.cos(theta)]] 24 return C 25#print(quantumcoin(3*(math.pi)/12)) 26 27def initPhi(): 28 phi_list=[] 29 a=1 30 b=0 31 phi = [a,b] 32 othersphi=[0,0] 33 for i in range(0,2*n+1): 34 if i == n: #nの位置だけ値を持つとします。 35 phi_list.append(phi) 36 else: 37 phi_list.append(othersphi) 38 return phi_list 39 40for t in range(0,2*m+1): #ここが作用させるコード 41 if t==0: 42 new_phi= initPhi() 43 else: 44 new_phi[n]=np.inner(quantumcoin(theta),new_phi[n]) 45 print(t,new_phi)
結果は、
0 [[0, 0], [0, 0], [0, 0], [1, 0], [0, 0], [0, 0], [0, 0]] 1 [[0, 0], [0, 0], [0, 0], array([0.70710678, 0.70710678]), [0, 0], [0, 0], [0, 0]] 2 [[0, 0], [0, 0], [0, 0], array([0., 1.]), [0, 0], [0, 0], [0, 0]] 3 [[0, 0], [0, 0], [0, 0], array([-0.70710678, 0.70710678]), [0, 0], [0, 0], [0, 0]] 4 [[0, 0], [0, 0], [0, 0], array([-1., 0.]), [0, 0], [0, 0], [0, 0]] 5 [[0, 0], [0, 0], [0, 0], array([-0.70710678, -0.70710678]), [0, 0], [0, 0], [0, 0]] 6 [[0, 0], [0, 0], [0, 0], array([ 0., -1.]), [0, 0], [0, 0], [0, 0]]
となっており、大きさが各要素1/√2ずつ小さくなっていくはずなのに、t=1秒までの値しか会っていません。defで定義した関数が原因で時間発展の計算が、初期状態から抜け出せてない感じがします。自分で定義した作用素quantumcoinをt乗として表すpow(,t)はダメなので、for文でやるしかないのかと感じました。
ご指導の程、宜しくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/10 12:29