PennyLane
Install
Install
  1. Compilation/
  2. Efficient Adjoint Operations

Efficient Adjoint Operations

OverviewDetailsAdjoint QROMResources

Derivation

Derivation of the adjoint elbow

Figure 1: Derivation of the adjoint Elbow. (a) Definition of the adjoint Elbow, where the target qubit terminates to |0\rangle. (b) \mathrm{Toffoli} gate may be written as a CCZ gate sandwiched by Hadamard gates. (c) The CCZ gate is symmetric, so we can re-write the form to have the Z gate in the centre. (d). Earlier measurement leads to a classically controlled CZ gate.

The derivation is shown in the panels of Figure 1. The Toffoli gate in Figure 1a be written as a CCZ gate sandwiched by Hadamard gates, as in Figure 1b. By symmetry, a CCZ may be rewritten to have the Z gate execute on the middle qubit instead, as in Figure 1c. Based on the deferred measurement principle and that the final state of the target qubit must be |0\rangle, we can move the measurement and the Hadamard gate before the multi-controlled Z gate, creating a CZ gate that is classically controlled instead, as shown in Figure 1d.

Proof

Initial state and the Toffoli gate

In order to prove the equivalence, we will begin with an arbitrary 3-qubit state |\phi\rangle and check that the \mathrm{Toffoli} |\phi\rangle = \mathrm{Adjoint(Elbow)}|\phi\rangle. However, note that we cannot begin with a completely arbitrary state because we must ensure that the output of the target qubit is |0\rangle. It can be proven that the general initial state can be written as:

|\psi_1\rangle = \alpha_0 |000\rangle + \alpha_1 |010\rangle + \alpha_2 |100\rangle + \alpha_3 |111\rangle,

where the target qubit is furthest on the right. Thus, the state desired after the Toffoli gate is

|\psi_2\rangle = \alpha_0 |000\rangle + \alpha_1 |010\rangle + \alpha_2 |100\rangle + \alpha_3 |110\rangle.

Now, we will check that the circuit indeed creates |\psi_2\rangle.

Step-by-step walkthrough of the circuit

As mentioned above, the goal of this section is to work through the circuit step-by-step to see how the input state |\psi_1\rangle becomes |\psi_2\rangle. The particular decomposition of the measurement-based adjoint Elbow is depicted in Figure 2.

Definition of the adjoint Elbow with measurements

Figure 2. Implementation of the adjoint Elbow with zero T gates, assuming the target qubit must become state |0\rangle.

After the Hadamard gate, the state |\psi_1\rangle becomes:

\frac{1}{\sqrt{2}} \Big[ \alpha_0 |000\rangle + \alpha_0 |001\rangle + \alpha_1 |010\rangle + \alpha_1 |011\rangle + \alpha_2 |100\rangle + \alpha_2 |101\rangle - \alpha_3 |111\rangle + \alpha_3 |110\rangle\Big]

Now, qubit 3 must be measured. If the outcome is 0, then the state collapses to:

\alpha_0 |000\rangle + \alpha_1 |010\rangle + \alpha_2 |100\rangle + \alpha_3 |110\rangle

It is clear that this is equivalent to |\psi_2\rangle, so we do not need to implement any classical control.

However, if the outcome of the measurement of 1, then the state collapses to:

\alpha_0 |001\rangle + \alpha_1 |011\rangle + \alpha_2 |101\rangle - \alpha_3 |111\rangle

If we apply a CZ gate onto the main register, the state is

\alpha_0 |001\rangle + \alpha_1 |011\rangle + \alpha_2 |101\rangle + \alpha_3 |111\rangle

Then, we apply a X gate to set qubit 3 to obtain |0\rangle. That yields the desired state, |\psi_2\rangle.

Finally, it is clear that the adjoint Elbow gate and the circuit involving measurements in Figure 2 are equivalent. The latter eliminates all T gates, which are very expensive to execute on hardware.

PennyLane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Built by researchers, for research. Created with ❤️ by Xanadu.

Research

  • Research
  • Performance
  • Hardware & Simulators
  • Demos
  • Compilation Hub
  • Quantum Datasets

Education

  • Teach
  • Learn
  • Codebook
  • Coding Challenges
  • Videos
  • Glossary

Software

  • Install PennyLane
  • Features
  • Documentation
  • Catalyst Compilation Docs
  • Development Guide
  • API
  • GitHub
Stay updated with our newsletter

© Copyright 2026 | Xanadu | All rights reserved

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.

Privacy Policy|Terms of Service|Cookie Policy|Code of Conduct