質問編集履歴
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -144,9 +144,9 @@
|
|
144
144
|
|
145
145
|
|
146
146
|
|
147
|
-
return (p_map[x,y])
|
147
|
+
return (p_map[x,y])#←ここは違うので無視してください。
|
148
|
-
|
149
|
-
|
148
|
+
|
149
|
+
|
150
150
|
|
151
151
|
|
152
152
|
|
@@ -198,7 +198,7 @@
|
|
198
198
|
|
199
199
|
#plt.show()
|
200
200
|
|
201
|
-
|
201
|
+
|
202
202
|
|
203
203
|
|
204
204
|
|
2
全体修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,72 @@
|
|
6
6
|
|
7
7
|
```python
|
8
8
|
|
9
|
+
import numpy as np
|
10
|
+
|
11
|
+
import matplotlib.pyplot as plt
|
12
|
+
|
13
|
+
import math
|
14
|
+
|
15
|
+
from mpl_toolkits.mplot3d import Axes3D
|
16
|
+
|
17
|
+
from matplotlib import cm
|
18
|
+
|
19
|
+
import matplotlib.colors as colors
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
n=10 #tの範囲
|
24
|
+
|
25
|
+
m=15 #偶数
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
p=1/2
|
30
|
+
|
31
|
+
q=1-p
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
#quantum coin
|
36
|
+
|
37
|
+
P = [[-p, q, math.sqrt(p*q), math.sqrt(p*q)],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
|
38
|
+
|
39
|
+
Q = [[0,0,0,0],[q, -p, math.sqrt(p*q), math.sqrt(p*q)],[0,0,0,0],[0,0,0,0]]
|
40
|
+
|
41
|
+
R = [[0,0,0,0],[0,0,0,0],[math.sqrt(p*q), math.sqrt(p*q), -q, p],[0,0,0,0]]
|
42
|
+
|
43
|
+
S = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[math.sqrt(p*q), math.sqrt(p*q), p, -q]]
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
t_list = []
|
48
|
+
|
49
|
+
x_list = []
|
50
|
+
|
51
|
+
y_list = []
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
phi_map = np.zeros((2*m+1, 2*m+1,4)) #縦横2m+1の座標平面上にいる波動状態をセット np.zeros((行,列,[]の中身の数))
|
56
|
+
|
57
|
+
phi_map[0,0]= np.array([1/2,1/2,-1/2,-1/2])
|
58
|
+
|
59
|
+
p_map=np.zeros([2*m+1,2*m+1])
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
for i in range(0,2*m+1):
|
64
|
+
|
65
|
+
p = np.dot(phi_map[i,i], np.conj(phi_map[i,i]))
|
66
|
+
|
67
|
+
p_map[i,i]=p
|
68
|
+
|
69
|
+
x_list.append(i)
|
70
|
+
|
71
|
+
y_list.append(i)
|
72
|
+
|
73
|
+
|
74
|
+
|
9
75
|
def prob(t,x,y):
|
10
76
|
|
11
77
|
for t in range(0,n+1):
|
@@ -22,7 +88,7 @@
|
|
22
88
|
|
23
89
|
next_phi_map = np.zeros((2*m+1,2*m+1, 4))
|
24
90
|
|
25
|
-
for x in range(0,2*m+1):
|
91
|
+
for x in range(0,2*m+1):
|
26
92
|
|
27
93
|
if x == 0:
|
28
94
|
|
@@ -78,16 +144,72 @@
|
|
78
144
|
|
79
145
|
|
80
146
|
|
147
|
+
return (p_map[x,y])
|
148
|
+
|
149
|
+
print(prob(3,3,3))
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
fig = plt.figure()
|
154
|
+
|
155
|
+
ax = Axes3D(fig)
|
156
|
+
|
157
|
+
X,Y = np.meshgrid(x_list, y_list)
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
ax.set_xlabel("x")
|
162
|
+
|
163
|
+
ax.set_ylabel("y")
|
164
|
+
|
165
|
+
ax.set_zlabel("probability")
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
ax.set_xlim(2*m,0)
|
172
|
+
|
173
|
+
ax.set_ylim(0,2*m)
|
174
|
+
|
175
|
+
ax.set_zlim(0,0.015)
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
#Z軸の色を設定
|
180
|
+
|
181
|
+
offset = p_map.ravel() + np.abs(p_map.min())
|
182
|
+
|
183
|
+
fracs = offset.astype(float)/offset.max()
|
184
|
+
|
185
|
+
norm = colors.Normalize(fracs.min(), fracs.max())
|
186
|
+
|
187
|
+
clrs = cm.cool(norm(fracs))
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
ax.bar3d(X.ravel(), Y.ravel(), p_map.ravel() ,0.1, 0.1, -p_map.ravel(),color =clrs)#,cmap=cm.hot)
|
192
|
+
|
193
|
+
ax.w_xaxis.set_pane_color((0, 0, 0, 0))
|
194
|
+
|
195
|
+
ax.w_yaxis.set_pane_color((0, 0, 0, 0))
|
196
|
+
|
197
|
+
ax.w_zaxis.set_pane_color((0, 0, 0, 0))
|
198
|
+
|
199
|
+
#plt.show()
|
200
|
+
|
81
201
|
return (t,p_map[x,y]) #←ここが全然違うのはわかっている
|
82
202
|
|
83
203
|
|
84
204
|
|
85
205
|
```
|
86
206
|
|
87
|
-
|
207
|
+
言葉足らずで申し訳ないです。コードをすべて掲載しました。
|
88
|
-
|
208
|
+
|
89
|
-
|
209
|
+
以下のような、座標にそれぞれの確率の値がでます。この時間、座標に依存した、特定の箇所の確率だけを取り出したい場合、def関数、prob(t,x,y)として行うと良いのでしょうか?
|
210
|
+
|
90
|
-
|
211
|
+
(すいません、これで良いでしょうか?)
|
212
|
+
|
213
|
+
![イメージ説明](71e92ef261bce80a685aa4026cd37b6c.png)
|
214
|
+
|
91
|
-
|
215
|
+
上図は一例です(コードの結果とは少し違うかもしれません)。
|
92
|
-
|
93
|
-
宜しくお願い致します。
|
1
文字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
next_phi_map = np.zeros((2*m+1,2*m+1, 4))
|
24
24
|
|
25
|
-
for x in range(0,2*m+1): #以下は
|
25
|
+
for x in range(0,2*m+1): #以下は2m×2mの正方格子上の境界条件に沿って計算しています。
|
26
26
|
|
27
27
|
if x == 0:
|
28
28
|
|