Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Pdf format

Rating
-
Sold
-
Pages
3
Uploaded on
17-08-2024
Written in
2024/2025

Summary of 3 pages for the course Tamilnadu at Tamilnadu (70)

Institution
Course

Content preview

Quantum Counting Algorithm

April 7, 2024


[1]: from qiskit import QuantumCircuit, transpile
from qiskit.circuit.library import QFT
from qiskit_aer import Aer
from qiskit.visualization import plot_histogram


0.1 Quantum Counting Algorithm
[2]: def grover_operator(n_iterations):
"""Grover iteration circuit for oracle with 5/16 solutions
Args:
n_iterations (int): number of times to repeat the circuit
Returns:
Gate that implements n_iterations of the Grover operator
"""
from qiskit.circuit.library import Diagonal, GroverOperator
oracle = Diagonal([1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1])
grover_it = GroverOperator(oracle).repeat(n_iterations).to_gate()
grover_it.label = f"Grover$^{n_iterations}$"
return grover_it

qft_dagger = QFT(4, inverse=True).to_gate()
qft_dagger.label = "QFT†"

[3]: # Create QuantumCircuit
t = 4 # no. of counting qubits
n = 4 # no. of searching qubits
qc = QuantumCircuit(n+t, t) # Circuit with n+t qubits and t classical bits

# Initialize all qubits to |+>
for qubit in range(t+n):
qc.h(qubit)

# Begin controlled Grover iterations
n_iterations = 1
for qubit in range(t):
cgrit = grover_operator(n_iterations).control()
qc.append(cgrit, [qubit] + list(range(t, n+t)))



1

Written for

Course

Document information

Uploaded on
August 17, 2024
Number of pages
3
Written in
2024/2025
Type
SUMMARY

Subjects

$1,001.50
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vasanths1

Get to know the seller

Seller avatar
vasanths1
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions