0
$\begingroup$

I would like to implement the Deutsch-Jozsa algorithm myself using cirq. However, I faced the problem of the implementation of the oracle.

I endeavored to apply the Deutsch-Jozsa algorithm for $n+1$-qubits circuit, but I got the wrong answer. I found the analytical implementation of oracle here Implementing an oracle, so I try to program it. You can see below my implementation:

def qunatum_oracle (input_qubits, output_qubit, secret_string, quibit_number):
 for qubit, bit in zip(input_qubits, secret_string):
  if bit and qubit != input_qubits[quibit_number - 1]: 
    yield [CNOT(qubit, output_qubit), X(output_qubit)] 
  
  if bit and qubit == input_qubits[quibit_number - 1]:
    yield CNOT(qubit, output_qubit) 

where input_qubits are the circuit of input qubits, out output_qubit is the output qubit, secret_string is an input x of the oracle, and qubit_number is the number of qubits.

My oracle is acting on the $n + 1$ qubit and implements a CNOT gate. My oracle returns 1 instead of 0 for a constant string. I have no idea what was wrong. I was inspired by the realization of the Deutsch algorithm by cirq team https://github.com/quantumlib/Cirq/blob/master/examples/deutsch.py but still didn't get my mistake. Unfortunately, I haven't found the solution to my problem on the forum.

Could you provide me any clue or what I did wrong or could you share the link where I can find the solution?

My idea is I would like to implement a general oracle that finds whether a function is balanced or constant for $n+1$ circuit without dividing for balanced and constant cases.

Best regards,

Elijah

 

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.