1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

IBM Qiskit:量子回路の作成・可視化 〜 バックエンド定義 まで & 量子ゲートに関する調査

Last updated at Posted at 2022-11-21

IBM Qiskit の試用

from qiskit-tutorials/qiskit/tutorials/circuits/1_getting_started_with_qiskit.ipynb in IBMQuantum Lab

量子回路の作成・可視化バックエンド定義 まで実施

パッケージのインポート

import numpy as np
from qiskit import *

量子回路の作成

# Create a Quantum Circuit acting on a quantum register of three qubits
circ = QuantumCircuit(3)

ゲートの追加

追加したゲートの役割は「量子ゲートに関する調査」の項に記載

# Add a H gate on qubit 0, putting this qubit in superposition.
circ.h(0)
# Add a CX (CNOT) gate on control qubit 0 and target qubit 1, putting
# the qubits in a Bell state.
circ.cx(0, 1)
# Add a CX (CNOT) gate on control qubit 0 and target qubit 2, putting
# the qubits in a GHZ state.
circ.cx(0, 2)
# <qiskit.circuit.instructionset.InstructionSet at 0x7f13df5667c0>

量子回路の可視化

circ.draw('mpl')

▼ 出力された回路図
image.png

Qiskit Aer(量子回路シミュレータ)のバックエンド定義

from qiskit import Aer

# 回路を実行するためのバックエンドを定義
backend = Aer.get_backend('statevector_simulator')

# <frozen importlib._bootstrap>:219: RuntimeWarning: scipy._lib.messagestream.MessageStream size changed, may indicate binary incompatibility. Expected 56 from C header, got 64 from PyObject

参考

IBM の Qiskit ドキュメント
Introduction to Qiskit - Qiskit 0.39.2 documentation

量子ゲートに関する調査

代表的なゲート

  1. パウリゲート
  2. アダマールゲート

Why: 1, 2 と共に自己随伴行列

アダマールゲート

基底状態の量子ビットを重ね合わせの状態へ移すために用いる

Why: アダマールゲートの定義(回転行列?)と状態遷移(基底 → 重ね合わせ)の対応付け

定義

$$
\boldsymbol H =
\frac{1}{\sqrt{2}}
\begin{bmatrix}
1 & 1 \\
1 & -1
\end{bmatrix}
$$

参考

Microsoft/QuantumKatas の Binder Notebook
GitHub: Microsoft/QuantumKatas/42ee33b0001df1f74682c9ac0f5523d644708bdd

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?