In Learning Quantum Computation using Qiskit chapter 3.4 I encountered the Deutsch-Josza Algorithm. At the end of the chapter I was presented with a homework problem where the code:

from qiskit_textbook.problems import dj_problem_oracle
oracle = dj_problem_oracle(1)

gives me a gate called 'oracle' and I was supposed to do find out whether it was balanced or constant. I encountered a problem when appending 'oracle' into my circuit, it kept telling me that 'The amount of qubit/clbit arguments does not match the gate expectation.'

After alot of headscratching and try and error I found out that the gate was stuck at a size of 5 (or n=4 if you've done the problem). Because the entire chapter was taught from the view of n qbits, I tried to solve the problem by writing an algorithm for n qbits(so that I can choose how many qbits my circuit contains).

I think that some more detail should be added into the text of that chapter so that things like this don't confuse newcomers like me, or just make it an n sized gate. I'd be grateful if someone could pass this message on to the good men and women managing the site.

  • 4
    $\begingroup$ I’m voting to close this question because it isn't a question. Seems like it could have been sorted by an email. $\endgroup$ – Dripto Debroy Jul 9 '20 at 14:51
  • $\begingroup$ The email to use seems to be francis.harkins@ibm.com $\endgroup$ – Dripto Debroy Jul 9 '20 at 15:22
  • $\begingroup$ Do you mean that if I have some feedback like this I should go to this email? Cuz I didn’t know where to go with my feedback. $\endgroup$ – BigFatKitty Meow Jul 10 '20 at 1:22
  • $\begingroup$ @BigFatKittyMeow you can give feedback on the textbook github, or email me with the above address if you prefer. I do agree it should be specified these oracles use n=4, plus 1 auxillary qubit. $\endgroup$ – Frank Jul 10 '20 at 8:48
  • $\begingroup$ I have created a PR to fix the problem here. $\endgroup$ – Frank Jul 10 '20 at 8:57

I think you misunderstood the problem here.

First notice that in each example of the notebook, when you are dealing with a length n you actually get in the end n+1 qubits to deal with in your circuit. Plus each of the function creates a circuit with n+1 qubits when dealing with length n. Therefore with n=4 the fact that the gate has a number of qubits equal to 5 is normal in this case.

Now, since the oracle that is created is a gate, you can access its number of qubits by doing oracle.num_qubits, here corresponding to n+1, and then to answer the question you run the same functions used in the examples (creating the algo from the oracle with the right number of qubits n, and executing the algo).
I tried this and it worked, let me know if you still need help! :)

  • 1
    $\begingroup$ That’s exactly what I tried, but it seems that the code I posted only gives gates with the size of 5 qubits( I checked with oracle.num_qubits) so that’s why I had this problem. $\endgroup$ – BigFatKitty Meow Jul 10 '20 at 1:20

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