Optimise implementation of a quantum algorithm when an input is fixed - Quantum Computing Stack Exchange most recent 30 from quantumcomputing.stackexchange.com 2020-01-21T00:00:38Z https://quantumcomputing.stackexchange.com/feeds/question/5632 https://creativecommons.org/licenses/by-sa/4.0/rdf https://quantumcomputing.stackexchange.com/q/5632 2 Optimise implementation of a quantum algorithm when an input is fixed Nelimee https://quantumcomputing.stackexchange.com/users/1386 2019-03-05T13:11:52Z 2019-03-05T15:25:33Z <p>I need to implement a quantum comparator that, given a quantum register <span class="math-container">$a$</span> and a real number <span class="math-container">$b$</span> <strong>known at generation time</strong> (i.e. when the quantum circuit is generated), set a qubit <span class="math-container">$r$</span> to the boolean value <span class="math-container">$(a &lt; b)$</span>.</p> <p>I successfully implemented a comparator using 2 quantum registers as input by following <a href="http://arxiv.org/abs/quant-ph/0410184v1" rel="nofollow noreferrer">A new quantum ripple-carry addition circuit (Steven A. Cuccaro and Thomas G. Draper and Samuel A. Kutin and David Petrie Moulton, 2004)</a>. This means that given two quantum registers <span class="math-container">$a$</span> and <span class="math-container">$b$</span>, the circuit set a qubit <span class="math-container">$r$</span> to the boolean value <span class="math-container">$(a &lt; b)$</span>. </p> <p>I could use an ancilla quantum register that will be initialised to the constant value <span class="math-container">$b$</span> I am interested in and then use the implementation I already have, but this sounds quite inefficient.</p> <p>The only gate that use the quantum register <span class="math-container">$b$</span> (the one fixed at generation time) is the following:</p> <p><a href="https://i.stack.imgur.com/ha5Wr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ha5Wr.png" alt="MAJ gate as described by Cuccaro&#39;s paper"></a></p> <p>When this gate is used, the qubits of <span class="math-container">$b$</span> are given as the second input (i.e. the middle line in the circuit representation above) and the value of each of the qubit of <span class="math-container">$b$</span> is known at circuit generation.</p> <p><strong>My questions</strong>: </p> <ol> <li>Is there a way to remove completely the quantum register <span class="math-container">$b$</span> by encoding the constants values of each <span class="math-container">$b_i$</span> in the quantum circuit generated?</li> <li>Can the fact of knowing the value of the second entry of the gate at generation time be used to optimise the number of gates used (or their complexity)?</li> </ol> <p>I already have a partial answer for question n°2: the Toffoli gate may be simplified to one CX gate when <span class="math-container">$b_i = 1$</span> and to the identity (i.e. no gate) when <span class="math-container">$b_i = 0$</span>. There is still a problem with the first CX gate that prevent this optimisation, but this may be a track to follow?</p> https://quantumcomputing.stackexchange.com/questions/5632/-/5633#5633 1 Answer by Nelimee for Optimise implementation of a quantum algorithm when an input is fixed Nelimee https://quantumcomputing.stackexchange.com/users/1386 2019-03-05T15:25:33Z 2019-03-05T15:25:33Z <p>Let's answer my own question: it is not possible.</p> <p>After some research I ended up computing the "truth table" for the two possible cases:</p> <ol> <li><span class="math-container">$b = 0$</span>: <ul> <li><span class="math-container">$\vert 00 \rangle\rightarrow\vert 00 \rangle$</span></li> <li><span class="math-container">$\vert 01 \rangle\rightarrow\vert 10 \rangle$</span></li> <li><span class="math-container">$\vert 10 \rangle\rightarrow\vert 10 \rangle$</span></li> <li><span class="math-container">$\vert 11 \rangle\rightarrow\vert 01 \rangle$</span></li> </ul></li> <li><span class="math-container">$b = 1$</span>: <ul> <li><span class="math-container">$\vert 00 \rangle\rightarrow\vert 00 \rangle$</span></li> <li><span class="math-container">$\vert 01 \rangle\rightarrow\vert 11 \rangle$</span></li> <li><span class="math-container">$\vert 10 \rangle\rightarrow\vert 11 \rangle$</span></li> <li><span class="math-container">$\vert 11 \rangle\rightarrow\vert 01 \rangle$</span></li> </ul></li> </ol> <p>It is clearly visible in the above truth tables that the operation I want to produce is not reversible (two different input give the same output) and so not unitary.</p> <p>I will have to find another algorithm to do what I am searching for. I am still open to suggestions on interesting algorithms.</p>