Overview

5 Analyze quantum operations

This chapter shifts from analyzing quantum states to learning properties of quantum operations themselves. It establishes a reusable pattern for such tasks: prepare a suitable initial state, apply the target unitary (and possibly its controlled or adjoint variants) interleaved with helper gates, then measure and, when needed, repeat to collect statistics. The chapter motivates why “operations as input data” matter (for example, in phase estimation subroutines used by major algorithms) and uses small, concrete problems and implementations in Q# and Qiskit to build up practical techniques.

The first set of problems focuses on identifying unknown gates from a small set. The core idea is to choose an input state and a short gate sequence so that each candidate unitary maps the system to distinguishable (ideally orthogonal) states. Simple examples include distinguishing X from Z in one shot using the |0⟩ state, converting the “X vs H” task into “X vs Z” by sandwiching with H and using the unknown gate twice, and exposing the otherwise unobservable global phase in “X vs −X” via a controlled application and phase kickback from a |++⟩ input, read out on the control qubit. When perfect single-shot separation is impossible, the chapter advocates designing states that maximize distinguishability and using multiple repetitions. Building on these ideas, it then shows how to reconstruct a real single-qubit unitary: estimate the first column by tomography of U|0⟩, then decide between diagonal and anti-diagonal structure by applying U again to that state and discriminating the two resulting possibilities, with practical sign handling and statistical refinement.

The final and largest part develops phase estimation: given a unitary and one of its eigenstates, infer the corresponding eigenphase. After defining eigenvectors, eigenvalues, and eigenphases, the chapter introduces phase kickback as the unifying trick that transfers eigenphase information to control qubits. Three complementary algorithms are presented: iterative phase estimation (a minimal, noise-robust circuit repeated many times, yielding a cosine-squared dependence for inference), adaptive phase estimation (learns phase bits from least to most significant using powers of the unitary and conditional phase corrections), and quantum phase estimation (encodes phase across multiple controls, then applies inverse quantum Fourier transform to convert phase to amplitudes and read out the bits in one shot). The trade-offs are clear: iterative uses the simplest circuits but many shots; adaptive reduces repetitions with modest circuits; quantum phase estimation minimizes repetitions but uses deeper, more noise-sensitive circuits. Throughout, compact Q# and Qiskit implementations and tests illustrate the methods on gates such as Z, INC, and T.

To learn a property of a given unitary operation, we choose an initial state, apply one or several quantum operations, including the operation we’re analyzing or its variants, and measure the resulting state. Depending on the problem we’re solving, we might have to repeat this sequence of steps multiple times to gather statistics about the measurement outcomes, and/or vary the initial state and the unitaries applied.
figure
To distinguish two unitaries in one experiment, we need to choose an initial state that can be converted to different orthogonal states by applying each of these two unitaries, possibly as part of a longer sequence of unitaries. We then run the experiment by preparing that initial state, applying that sequence of unitaries, and identifying which of the orthogonal states we got using measurements.
figure
Reconstructing a single-qubit unitary from multiple experiments. We start by running a series of experiments to estimate the coefficients in the first column of the matrix, and then a second series of different experiments to figure out the relative signs of the coefficients in the second column.
figure
An eigenvector of a unitary is a vector that is multiplied by a scalar when this unitary is applied to it. This scalar is called the eigenvalue. An eigenvalue of a unitary can only be a complex number with absolute value 1, so it can be represented as an exponent using the real-valued eigenphase.
figure
To use the phase kickback trick for phase estimation, we need a control qubit in a superposition state (the \(\ket{+}\) state is commonly used) and a target register of qubits in the state that is an eigenvector of the unitary we’re exploring. When we apply the controlled variant of this unitary, the target register remains unchanged, but the control qubit acquires a relative phase on the basis state \(\ket{1}\). This relative phase can be analyzed to extract information about the eigenphase that corresponds to the eigenvector.
figure
In iterative phase estimation, we come up with a fixed quantum circuit that produces measurement outcomes with probabilities that are a function of the eigenphase. The circuit starts with the qubits in a specific state, applies a controlled variant of the unitary to get the information about the eigenphase into the phase of the control qubit, and then performs a specific measurement. We run this circuit multiple times, gather enough statistics about the measurement outcomes to estimate the probabilities of measurement outcomes, and calculate the eigenphase from them.
figure
In adaptive phase estimation, we learn the phase one binary digit at a time. We start by running a circuit that allows us to learn the least significant binary digit. After this, we use a different circuit, parts of which depend on the information we’ve discovered so far, to learn the second least significant binary digit. If there are more digits to learn, the process is repeated, with different circuits for each digit.
figure
In quantum phase estimation algorithm, we use multiple control qubits to encode the information about the eigenphase in phases of their states. Then, we use inverse quantum Fourier transform to convert that information from phase encoding to amplitude encoding, increasing the amplitude of the basis state that encodes the eigenphase compared to the amplitudes of other states. Finally, we measure the control qubits, reading out the bits of the phase as measurement results with high probability.
figure

Summary

  • We can use measurements to learn information not only about quantum states but also about quantum operations.
  • To learn a property of a given quantum operation, we use it as a part of a larger quantum experiment that chooses and prepares a certain initial state, applies a sequence of operations to it, and measures the result. After we run enough experiments, we analyze their results to extract the information we’re looking for.
  • Similarly to how we can distinguish quantum states using measurements, we can figure out which of the list of possible gates we are given by applying the given gate to a carefully selected initial state and analyzing the resulting state.
  • Quantum process tomography allows us to learn detailed information about an unknown unitary or a noisy process, similar to how quantum state tomography allows us to learn information about an unknown quantum state.
  • Phase estimation task focuses on finding the eigenvalue and eigenphase of the given unitary that correspond to its given eigenstate. It is an important building block of many quantum algorithms, most prominently Shor’s algorithm for integer factorization, quantum counting algorithm, and HHL algorithm for solving systems of linear equations.
  • The phase kickback trick relies on the fact that applying a controlled version of a unitary with the target qubit(s) in a special state can “kick” a relative phase back to the control qubit(s) instead of changing the state of the target. Phase kickback is broadly used in quantum algorithms, and all phase estimation algorithms rely on it.
  • There are multiple ways to approach solving phase estimation task. In this chapter, we considered three solutions that illustrated different classes of algorithms, each of them with their own advantages and disadvantages, depending on whether they will be executed on small noisy devices or on large fault-tolerant ones.
  • Iterative phase estimation algorithm constructs a very simple circuit and runs it a lot of times to estimate a function of the eigenphase. It uses the smallest circuit of all phase estimation algorithms but has to run it the most times to get a reasonable precision on the results.
  • Adaptive phase estimation algorithms construct a series of different small circuits that each learn a fragment of information we’re looking for, and run them one after another, tweaking the later circuits based on the information learned from the previous ones. These algorithms use fewer circuit runs compared to the iterative algorithm, but the circuits themselves are more complicated.
  • Quantum Fourier transform is a common primitive in quantum algorithms. It is used to convert information between amplitude encoding, in which the information is encoded in the absolute values of the amplitudes of the basis states, and phase encoding, in which the information is encoded in the phases of the complex numbers that represent the amplitudes.
  • Quantum phase estimation algorithm runs a single circuit that encodes the information about the eigenphase in relative phases of multiple control qubits and then applies inverse quantum Fourier transform to make sure that the basis states that are the closest to the binary representation of the eigenphase have the largest amplitudes and the highest probabilities of being measured. Quantum phase estimation uses the fewest circuit runs of all phase estimation algorithms, but it requires the most qubits and the most complicated circuit.

FAQ

What does it mean to analyze a quantum operation, and what is the general experiment pattern?Analyzing a quantum operation means learning properties of a unitary U (e.g., which gate it is, its matrix, its eigenphases) by preparing states, applying U (and related variants like controlled or adjoint), and measuring the resulting states. The general loop is: - Prepare a chosen initial state - Apply a sequence of unitaries that includes U (possibly multiple times, controlled, or conjugated by helper gates) - Measure; repeat to gather statistics and/or vary inputs This mirrors the standard algorithm template: prepare, transform, measure.
How can two unitaries be distinguished in a single experiment?Design the experiment so the two candidate unitaries map the same initial state to two orthogonal final states, then measure to tell them apart. Two key steps: - Choose an initial state and a helper sequence so that plugging in unitary A or unitary B yields orthogonal outputs. - Choose a measurement that discriminates those outputs (often computational-basis measurement after a short decoding). Examples: - Distinguish X vs Z by applying the unknown to |0> and measuring in the computational basis (outcomes 1 vs 0). - Distinguish X vs H by sandwiching the unknown with an X in the middle (U–X–U): if U=X the net is X; if U=H the net is Z, then read out as in the X vs Z case.
Why can’t we tell X from −X on a single qubit, and how does phase kickback fix this?On a single qubit, −X differs from X only by a global phase (−1), which is unobservable in any measurement. Using a controlled version of the gate turns the global phase into a relative phase (phase kickback) that is detectable: - Prepare control in |+> and target in |+> - Apply controlled-(unknown gate) - If the gate is X, the control remains |+>; if it is −X, the control flips to |−> (a relative phase on |1>), which you can read out with a Hadamard + measurement.
How do you reconstruct an unknown single-qubit unitary’s matrix (real coefficients)?Use two phases: - Phase 1 (first column): Apply U to |0> to get a|0>+b|1>. Use simple state tomography to estimate a and b (including signs). This gives the first column of U. - Phase 2 (sign pattern of the second column): Prepare exactly a|0>+b|1> by reapplying U to |0>, then apply U again. If U has the diagonal pattern [[a,b],[b,−a]], the state maps to |0>. If U has the anti-diagonal pattern [[a,−b],[b,a]], it maps to (a^2−b^2)|0>+2ab|1>. Distinguish these non-orthogonal states with a minimum-error strategy (as in state discrimination). If b is negative, insert a Z to flip the sign before measuring. Combining both steps yields the full matrix up to the assumed conventions.
Why are controlled, adjoint, and repeated applications of U useful in analysis?- Controlled-U turns eigenvalues into relative phases on the control (phase kickback), making them measurable. - Adjoint (U†) and basis-change conjugations (e.g., H U H) let you convert a problem into one with easier readouts (e.g., turning X into Z). - Repeated applications (U^k) amplify or isolate specific phase digits (e.g., in adaptive phase estimation you use powers 1, 2, 4, … to learn successive bits).
What is phase kickback, in simple terms?When you apply a controlled-U with the control in a superposition and the target in an eigenstate of U, the target stays unchanged while the control’s |1> basis state acquires the eigenvalue as a relative phase. That phase encodes the eigenphase information in the control qubit’s amplitudes. Subsequent single-qubit gates (e.g., Hadamard or phase gates) convert that phase into measurable probability differences.
How do iterative, adaptive, and quantum phase estimation differ?- Iterative phase estimation: Use one control qubit and a fixed circuit; repeat many times to estimate a probability (often cos^2(pi·theta)), then derive the phase from the statistics. Pros: shallow circuit, few qubits. Cons: needs many shots; ambiguity for some phase ranges unless tweaked. - Adaptive phase estimation: Learn the phase bit-by-bit (least significant to most), using powers of controlled-U and conditional phase corrections based on previously learned bits. Pros: far fewer repetitions than iterative; shallower than QPE. Cons: requires classical adaptivity across runs. - Quantum phase estimation (QPE): Use multiple control qubits at once, encode phase pieces in their relative phases, apply inverse QFT to convert phase info into amplitudes, then measure all bits in one run (ideally). Pros: few repetitions; direct readout. Cons: more qubits, deeper circuits, more noise-sensitive.
What role does Quantum Fourier Transform (QFT) play in quantum phase estimation?QFT (more precisely, its inverse) converts information encoded in the relative phases of a multi-qubit control register into amplitude peaks at the basis state corresponding to the best binary approximation of the eigenphase. For 1 qubit, QFT is just a Hadamard. For 2 qubits, QFT is H on MSB, a controlled-S, then H on LSB, with a final SWAP to fix bit order. In QPE, after encoding with controlled-U^k, inverse QFT maps the phase pattern to a computational-basis bit string you can measure.
What are practical differences between Q# and Qiskit when implementing these analyses?- Return values: Q# operations can return arbitrary classical types directly (e.g., which unitary index), while Qiskit circuits return measurement counts only; mapping of outcomes to answers must be handled in classical post-processing (or by adding swap/extra X gates so measurement bits directly encode the answer). - Controlled gates: Both support controlled variants, but APIs differ (e.g., Qiskit’s .control, Q#’s Controlled keyword). - State preparation: Qiskit often uses initialize with amplitude arrays; Q# often uses preparation operations (e.g., PrepareArbitraryStateCP) or custom prep logic. - Tests: In Qiskit you typically compile, run, and check counts; in Q# you can write assertions and return classical values directly from quantum subroutines.
How should I test these algorithms, and what pitfalls should I watch for?- Use gates with known eigenvectors/eigenphases at different precisions: Z (1 bit), a 2-qubit increment (INC, 2 bits), T (3 bits) to exercise precision behavior. - Verify that provided eigenvectors really are eigenvectors (e.g., apply U then unprepare to get back |0…0>, or compare statevectors). - Run enough shots to get reliable statistics; more shots are needed when amplitudes are small or states aren’t perfectly orthogonal. - Be mindful of sign conventions (e.g., negative b in reconstruction) and basis order (big-endian vs little-endian) when interpreting measured bit strings. - Expect rounding behavior when the true phase cannot be exactly represented with the chosen number of bits; iterative/adaptive need more shots, QPE needs cleaner circuits.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Quantum Programming in Depth ebook for free