はじめに
こちらの本を読みつつ、演習・実験を試してみます。
![q.jpg q.jpg](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fe67e0ddc-ba9e-e647-a277-7cd216410bb5.jpeg?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=d699e428ec026398782bc7cbe624f765)
4 位相シフトゲートの量子実験
4.1 位相シフト演算とは
4.1.4 位相シフト演算 T でのアダマール変換
演習 4-6
量子シミュレータで、$ H|0\rangle $、$ T^{\dagger}H|0\rangle $、$ HT^{\dagger}H|0\rangle $ を確かめる量子回路を作成し、どのように量子ビットが回転するか行列計算とともに比較して確かめよ。
行列計算
H|0\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 1 \\ 0 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 \\ 1 \end{bmatrix}
=
\frac{ |0\rangle + |1\rangle }{ \sqrt{2} }
T^\dagger H|0\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{-i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 1 \\ 0 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 \\ e^{-i(\pi/4)} \end{bmatrix}
=
\frac{ |0\rangle + e^{-i(\pi/4)} |1\rangle }{ \sqrt{2} }
測定
量子回路
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F3b91ec39-9b3f-7d44-eddd-9df79842cc84.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=07018e38e31c0cf598e014c923c1d491)
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F4d0a89d0-bd4f-998b-3430-5ce925b522bf.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=a8dd4c051f3bdf30e2bee850dabf08e9)
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F6d2ad48b-4459-35d0-d87d-706a2ff9ba8d.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=fcad83041d970a440911c340fa6233be)
ブロッホ球
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F88794c87-6928-fba7-b3b3-9048355ef9cd.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=ff4475bb990786f7380bd23ba9a6339d)
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fca05b1de-6efa-b0c7-171b-836b9c21ba4f.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=0edc3de19b5ed342b82c47232b54abbf)
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F7152660b-3360-5237-b53b-b9a73fdda3ff.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=efdb10d5dc629a84026812a7b5e624af)
演習 4-7
量子シミュレータで、$ H|1\rangle $、$ TH|1\rangle $、$ HTH|1\rangle $ を確かめる量子回路を作成し、どのように量子ビットが回転するか行列計算とともに比較して確かめよ。
行列計算
H|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 \\ -1 \end{bmatrix}
=
\frac{ |0\rangle - |1\rangle }{ \sqrt{2} }
T^\dagger H|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{-i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 \\ -e^{-i(\pi/4)} \end{bmatrix}
=
\frac{ |0\rangle - e^{-i(\pi/4)} |1\rangle }{ \sqrt{2} }
HT^\dagger H|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{-i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{2}
\begin{bmatrix} 1 - e^{-i(\pi/4)} \\ 1 + e^{-i(\pi/4)} \end{bmatrix}
=
\frac{ (1 - e^{-i(\pi/4)})|0\rangle + (1 + e^{-i(\pi/4)})|1\rangle }{2}
測定
量子回路
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F0ce2007b-b240-d543-696d-18197f427e84.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=75c258b3805a2cd69d848b45f2594ffe)
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F255757e2-5943-a47e-9830-402d0613a990.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=b5f3c88e96db224172c4c642a95fc902)
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fc8844bde-2892-d1ad-b53c-8ff734f02653.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=9398d48829564277b5547ab88bd9597b)
ブロッホ球
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fc1460c70-df8a-124b-2a8a-417aafab0097.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=9d1d53cc3deeb763bf87c5ae6d30ddfc)
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F815ed8fc-eb34-3eaa-986b-1cd39328d1db.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=b377ff5f656515a596c2504653c52b7c)
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F2cefd682-7f29-b215-9ec0-43eff7ab75b9.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=32f1aac2f28f38a7e122f24a1b0864a4)
演習 4-8
量子シミュレータで、$ H|1\rangle $、$ T^{\dagger}H|1\rangle $、$ HT^{\dagger}H|1\rangle $ を確かめる量子回路を作成し、どのように量子ビットが回転するか行列計算とともに比較して確かめよ。
行列計算
H|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 \\ -1 \end{bmatrix}
=
\frac{ |0\rangle - |1\rangle }{ \sqrt{2} }
TH|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 \\ -1 \end{bmatrix}
=
\frac{ |0\rangle - e^{i(\pi/4)} |1\rangle }{ \sqrt{2} }
HTH|1\rangle
=
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{2}
\begin{bmatrix} 1 - e^{i(\pi/4)} \\ 1 + e^{i(\pi/4)} \end{bmatrix}
=
\frac{ (1 - e^{i(\pi/4)})|0\rangle + (1 + e^{i(\pi/4)})|1\rangle }{2}
測定
量子回路
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fb275b654-625f-1d32-9640-42445d4702b6.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=47bf7095c3c21b51a8629c7f717bc524)
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F9cdd69ea-2b82-d6ad-7bc8-c819fbfe019a.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=6a87bcd36e84c1b4604afd54cd61b8fd)
ブロッホ球
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fe0c19db8-4342-bb2e-34ea-9e0b4fb74a96.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=6ea2201a53d33bd1a71a1961c719967f)
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2F2029f3d1-da3b-a54b-3951-469d3acbd812.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=0e0ac4024afda9313dfd50c0eed66687)
演習 4-9
量子シミュレータで、初期状態 $ |1\rangle $ に対してアダマール演算 H と位相シフト演算 T との組み合わせを連続で作用させるとどうなるか、$ H|1\rangle $、$ TH|1\rangle $、$ HTH|1\rangle $、$ THTH|1\rangle $ として量子回路を作成して行列計算とともに比較して確かめよ。
行列計算
THTH|1\rangle
=
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\frac{1}{ \sqrt{2} }
\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}
\begin{bmatrix} 0 \\ 1 \end{bmatrix}
=
\frac{1}{2}
\begin{bmatrix} 1 & 0 \\ 0 & e^{i(\pi/4)} \end{bmatrix}
\begin{bmatrix} 1 - e^{i(\pi/4)} \\ 1 + e^{i(\pi/4)} \end{bmatrix}
=
\frac{ (1 - e^{i(\pi/4)})|0\rangle + (e^{i(\pi/4)} + i)|1\rangle }{ \sqrt{2} }
測定
量子回路
![visualIBMQASM.png visualIBMQASM.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fa976affb-0d16-9d4c-2b74-12dfd5b6e49b.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=ae122f615016b62d28d476d2bec83657)
ブロッホ球
![qSphere.png qSphere.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F20418%2Fe943b173-8789-25bd-b8cb-77aaaa306a44.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=7e9ef4571658e9aaf0fd3d11f9a4888b)