Quantum Computing Asked by Charly-V on August 13, 2021
I am trying to do the superposition of a subset of integers using qiskit. For instance: $|13rangle + |14rangle + … |Nrangle$ (uniform superposition) without the part $|0rangle + |1rangle + … + |12rangle$. Is it possible? How can I proceed?
I would do something like this :
n = 5 #number of qubits
N = 2**n #32
sup = [0.]*N
start = 12 #your 13, considering list index starts at 0
norm = N-start #used for normalisation of the vector we'll pass
for i in range(start, N):
#creation of the list where the 0s are at indices on the first part you don't want
sup[i]=np.sqrt(1/norm)
qc = QuantumCircuit(n)
qc.initialize(sup, range(n))
qc.draw()
Tell me if something isn't clear :)
Answered by Lena on August 13, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP