Normalize the second qubit as . Since a Pauli X gate changes to , the Boolean quantum oracle acts asThis quantum phase kickback leaves the second qubit uncorrelated with the first. Put : for a constant function and for a balanced Boolean function. Apart from the irrelevant global phase , the first qubit and environment reachThe population-preserving interaction commutes with the quantum oracle on this answer-register input, so its placement before or after the oracle, between the two Hadamard gates, gives the same result. Substitute into b:The printed Deutsch algorithm uses the rule zero means constant function; one means balanced Boolean function. With that rule, the Deutsch algorithm with pure dephasing succeeds for either class withFor real nonnegative environment overlap this is , ranging from certainty at to random guessing at . For general complex overlap, a coherent shift can invert the printed answer: for example makes the printed rule always wrong. If the overlap is known but the printed quantum measurement is retained, choose the better labeling of its outcomes; this givesThere is a further improvement if a known can be compensated by the phase gate before the final Hadamard gate. It removes the coherent shift without reversing any actual quantum decoherence, and yieldsThis is optimal when only the first qubit is accessible, with equal prior probabilities for the two classes. Before the final Hadamard gate, their reduced density matrices areThe difference has eigenvalues , giving trace distance . The Holevo–Helstrom theorem therefore bounds the success probability by , exactly attained by the compensated procedure. A known phase shift and loss of coherence have different effects: at the two density matrices coincide and no measurement on the available qubit can reveal the answer.
For one input bit, a Boolean function is specified by the pair , and counts its satisfying assignments. In the ordered computational basis , the supplied phase oracle convention givesHere is exclusive or: the oracle changes the sign of the inputs with . With the identity matrix and the Pauli Z gate, all four cases areThe two middle cases are balanced Boolean functions; the others are constant functions. The specified zero-state sign change and the Hadamard gate are
Use the top qubit as the first tensor product factor. Write the controlled unitary gate as . Reading the bracketed quantum circuit from left to right, its four operations are , , , . Thus the target operation in its control-one branch iswhere the rightmost matrix acts first. The control-zero branch is the identity operator. The Hadamard conjugation of a controlled gate identity givesIndeed, on control zero the replacement applies to the target, while on control one both sides apply . By linearity, the identity holds on every quantum superposition and therefore in every repetition of the bracket. This replaces the two internal controlled Hadamard gates as a pair.
The global phase of a controlled quantum gate must be preserved: , whereas . Consequently the minus signs in and the special phase oracles cannot be discarded as an unobservable global phase of the complete quantum circuit.