1
$\begingroup$

I am trying to do the superposition of a subset of integers using qiskit. For instance: $|13\rangle + |14\rangle + ... |N\rangle$ (uniform superposition) without the part $|0\rangle + |1\rangle + ... + |12\rangle$. Is it possible? How can I proceed?

$\endgroup$
2
$\begingroup$

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 :)

$\endgroup$
1
  • $\begingroup$ Thank you very much Mr. for your answer. It's really good $\endgroup$
    – Charly-V
    Jun 7 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.