Quantum
Challenge
2021
静岡県立磐田南高校
理数科2年木村宇恭
2021年3月
今回使う重要な回路
①回路の分解~transpile~
以下の回路を用いると既存の回路を任意のゲートのみを使った回路で
表現することができる。
In [1]:
from qiskit.compiler import transpile
transpile(qc, basis_gates=['sx','rz', 'cx','x'], optimization_level=3).draw()
この回路で使いたいゲートを指定
0から3までのlevelがあり数字が大きいほど
少ないゲートでまとめることができる
既存の回路の名前をここで指定
※以降[transpiler]とおく
②行列表示・係数表示
その回路の状態を以下の回路を用いて行列の状態にする
In [2]:
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()
print(result.get_unitary(qc, decimals=3).○○)
ここを
realにすると実数部分の行列を表せる
imagにすると虚数部分の行列を表せる
※以降[unitary_simulator]とおく
解法①
行列表示・係数表示
𝑐𝑐𝑥 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0 0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1 0
𝑐𝑐𝑥 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0 1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0 0
⑴ QuantumChallengeの
解説上の表記
⑵ unitary_simulatorでの表記
⑴の行列は上から|000>,|001>,|010>…
⑵の行列は上から|000>,|100>,|110>…
というように対応するため行列の表記に差が生じる。
QiskitChallenge Q.1
基本ゲートを使ってトフォリゲートを同じように構築しなさい。
ただし、IBM Quantumシステムの基本ゲートはCX、RZ、SX、Xであり、そのほかのゲートは使えない。
QiskitChallenge Q.1
この回路を作るにあったって以下の回路を参考にする
①制御回転
任意の軸周りの回転をさせる。
この回路では、Y軸まわりの制御回転の構築方法。
q0が1の時に𝜋回転させる。
②制御制御回転
ある軸まわりに制御回転できると仮定し、そこからトフォリゲートのよ
うに二つの制御量子ビットが1のときのみその軸周りに回転をさせる。
この回路では、位相を𝜋回転する。
ただし、θ=180であるためこの行列は以下のようになり、
『-』の符号の影響がある行列になる。
QiskitChallenge Q.1
量子ビット(q0,q1)が|11〉の時のみ
ターゲットビット(q2)を|1〉にしたいので…
RXゲートを用いると虚数が出て来てしまうので、
実数のみで、扱いやすいRYゲートを用いた。
Ry 𝜃 =
0 −1
1 0
『-』の符号の影響で、
この回路は以下のような行列と
なってしまう
QiskitChallenge Q.1
を に置き変えると、
よって〇(|110>が入力)のときだけ
さらに符号が反転する回路を作る
ただし、この表記方法はunitary_simulatorでの表記である。
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0 1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
−1
0
0
0
0 0
回路の作成とその行列
回路①の行列
ただし、この表記方法はunitary_simulatorでの表記である。
𝑈0 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0 1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
−1
0
0
0
0 0
CCXゲートの働きを再現するため、
〇(|110>が入力)のときだけ符号が
反転する回路を作る
回路②の行列
ただし、この表記方法はunitary_simulatorでの表記である。
ここでは|111>のときに符号が反転しているが、
|110>が入力のときだけ符号が反転する回路を
作る必要があるので…
𝑈1 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0 0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0 −1
回路③の行列
ただし、この表記方法はunitary_simulatorでの表記である。
回路②の両側にXゲートを置いたことで、
|110>が入力のときだけ符号が反転する
回路を作ることができた。
これを回路①と組み合わせると
𝑈2 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
−1
0
0
0
0 0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0 1
以下の回路の行列
𝑐𝑐𝑥 =
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0 0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0 1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0 0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0 0
ただし、この表記方法はunitary_simulatorでの表記である。
①,②の回路よりq0,q1が|1>のときのみ反転する
この回路では、
二つともの量子ビットが1の場合のみ、𝜋回転になる。
よってCCXゲートの働きを表すことができる。
|111>の時だけ符号が反転
QiskitChallenge Q.1
使えるゲートのみに修正①
transpilerを用いる
In [1]:
from qiskit.compiler import transpile
transpile(qc, basis_gates=['sx','rz', 'cx','x'], optimization_level=3).draw()
CRy(𝜋/2) CRy(−𝜋/2)
CRy(𝜋/2)
…
…
使えるゲートのみに修正②
transpilerを用いる
CP(−𝜋/2)
CP(𝜋/2)
CP(𝜋/2)
In [1]:
from qiskit.compiler import transpile
transpile(qc, basis_gates=['sx','rz', 'cx','x'], optimization_level=3).draw()
よってtranspilerを用いることで最終的に回路は以下のようになる
QiskitChallenge Q.1
transpilerを用いる
In [1]:
from qiskit.compiler import transpile
transpile(qc, basis_gates=['sx','rz', 'cx','x'], optimization_level=3).draw()
この回路を示す行列
[unitary_simulator]を使ってこの回路の行列を表すと…
In [2]: backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()
print(result.get_unitary(qc, decimals=3).real)
よってCCXゲートの行列と一致するのでこの回路は
CCXゲートを表すことができている
解法②
CCXゲートの分解
回路𝛼を用いることでCCXゲート自体を分解する
transpilerを用いる
この回路を示す行列
[unitary_simulator]を使ってこの回路の行列を表すと…
In [2]: backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()
print(result.get_unitary(qc, decimals=3).real)
よってCCXゲートの行列と一致するのでこの回路は
CCXゲートを表すことができている

More Related Content

PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PPTX
K-Means Clustering Algorithm.pptx
PPTX
Early Software Development through Palladium Emulation
PPTX
[総まとめ] 量子コンピュータに関する課題研究.pptx
PPTX
量子回路上でのパズルゲーム解法プログラムの構築
PPTX
Quantum computer Qiskit challenge 2020 Nov week2 a
PPTX
Quantum computer adder grover
Storytelling For The Web: Integrate Storytelling in your Design Process
2024 Trend Updates: What Really Works In SEO & Content Marketing
K-Means Clustering Algorithm.pptx
Early Software Development through Palladium Emulation
[総まとめ] 量子コンピュータに関する課題研究.pptx
量子回路上でのパズルゲーム解法プログラムの構築
Quantum computer Qiskit challenge 2020 Nov week2 a
Quantum computer adder grover

Recently uploaded (20)

PPT
Geologic Time for studying geology for geologist
DOCX
search engine optimization ppt fir known well about this
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Hybrid model detection and classification of lung cancer
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Getting Started with Data Integration: FME Form 101
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Chapter 5: Probability Theory and Statistics
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
STKI Israel Market Study 2025 version august
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Hindi spoken digit analysis for native and non-native speakers
Geologic Time for studying geology for geologist
search engine optimization ppt fir known well about this
sustainability-14-14877-v2.pddhzftheheeeee
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
A comparative study of natural language inference in Swahili using monolingua...
Getting started with AI Agents and Multi-Agent Systems
DP Operators-handbook-extract for the Mautical Institute
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
NewMind AI Weekly Chronicles – August ’25 Week III
Module 1.ppt Iot fundamentals and Architecture
Hybrid model detection and classification of lung cancer
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Getting Started with Data Integration: FME Form 101
Assigned Numbers - 2025 - Bluetooth® Document
Chapter 5: Probability Theory and Statistics
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
STKI Israel Market Study 2025 version august
WOOl fibre morphology and structure.pdf for textiles
A contest of sentiment analysis: k-nearest neighbor versus neural network
Hindi spoken digit analysis for native and non-native speakers
Ad
Ad

Quantum challenge2021 Ex1