回答編集履歴

3

edit

2018/05/08 12:31

投稿

mkgrei
mkgrei

スコア8560

test CHANGED
@@ -15,3 +15,117 @@
15
15
  wikipedia先生によると対称になるのは[1,i]/sqrt(2)の時ですが…
16
16
 
17
17
  それが正しければ、ノルムの計算方法もまずいです。
18
+
19
+
20
+
21
+ ---
22
+
23
+
24
+
25
+ ```python
26
+
27
+ import numpy as np
28
+
29
+ import matplotlib.pyplot as plt
30
+
31
+
32
+
33
+ n = 100
34
+
35
+ H = np.array([[1, 1],[1, -1]]) / np.sqrt(2)
36
+
37
+ P = np.zeros((2, 2)); P[0, :] = H[0, :]
38
+
39
+ Q = np.zeros((2, 2)); Q[1, :] = H[1, :]
40
+
41
+
42
+
43
+ pos = np.zeros((2*n+1, 2), dtype=np.complex)
44
+
45
+ pos[n, :] = np.array([1, 1j], dtype=np.complex) / np.sqrt(2)
46
+
47
+ x = np.arange(-n, n+1)
48
+
49
+
50
+
51
+ history = np.zeros((n, 2*n+1, 2), dtype=np.complex)
52
+
53
+ history[0, :, :] = pos[:, :]
54
+
55
+ prob = np.zeros((n, 2*n+1))
56
+
57
+ prob[0, :] = np.sum(np.conj(history[0, :, :]) * history[0, :, :], axis=-1)[:]
58
+
59
+ for t in range(1, n):
60
+
61
+ history[t, :-1, :] += np.inner(history[t-1, 1:, :], P.T)
62
+
63
+ history[t, 1:, :] += np.inner(history[t-1, :-1, :], Q.T)
64
+
65
+ prob[t, :] = np.sum(np.conj(history[t, :, :]) * history[t, :, :], axis=-1)[:]
66
+
67
+
68
+
69
+ history_ = np.zeros((n, 2*n+1))
70
+
71
+ history_[0, n] = 1.
72
+
73
+ for t in range(1, n):
74
+
75
+ history_[t, :-1] += history_[t-1, 1:]/2.
76
+
77
+ history_[t, 1:] += history_[t-1, :-1]/2.
78
+
79
+
80
+
81
+ def show(x, y, y_=None, nonzeros=True):
82
+
83
+ if nonzeros:
84
+
85
+ s = 1
86
+
87
+ ss = 2
88
+
89
+ else:
90
+
91
+ s = 0
92
+
93
+ ss = 1
94
+
95
+ plt.xlabel("x")
96
+
97
+ plt.ylabel("probability")
98
+
99
+ plt.ylim((0, np.max(y)*1.1))
100
+
101
+ plt.xlim((np.min(x), np.max(x)))
102
+
103
+ plt.plot(x[s::ss], y[s::ss], color="red", linewidth=1.0)
104
+
105
+ if y_ is not None:
106
+
107
+ plt.plot(x[s::ss], y_[s::ss], color="blue", linewidth=1.0)
108
+
109
+ plt.grid()
110
+
111
+ plt.savefig('q.png')
112
+
113
+ plt.show()
114
+
115
+
116
+
117
+ show(x, prob[-1], y_=history_[-1])
118
+
119
+ ```
120
+
121
+
122
+
123
+ 参考:
124
+
125
+ https://arxiv.org/pdf/quant-ph/0303081.pdf
126
+
127
+ Google画像: Quantum Random Walk
128
+
129
+
130
+
131
+ ![QRW:赤、RW:青](c016c0a68f52e5719291a801f3fd99bf.png)

2

edit

2018/05/08 12:31

投稿

mkgrei
mkgrei

スコア8560

test CHANGED
@@ -5,3 +5,13 @@
5
5
 
6
6
 
7
7
  端の場所がおかしいのも問題ですね…
8
+
9
+
10
+
11
+ ---
12
+
13
+
14
+
15
+ wikipedia先生によると対称になるのは[1,i]/sqrt(2)の時ですが…
16
+
17
+ それが正しければ、ノルムの計算方法もまずいです。

1

Edit

2018/05/07 23:53

投稿

mkgrei
mkgrei

スコア8560

test CHANGED
@@ -1,3 +1,7 @@
1
1
  s_listの更新のタイミングが悪いことと、
2
2
 
3
3
  確保してあるs_listのサイズが足りないことが問題だと思います。
4
+
5
+
6
+
7
+ 端の場所がおかしいのも問題ですね…