Overview

1 The advantages and challenges of programming quantum computers

Quantum computing promises substantial gains for carefully chosen tasks by exploiting forms of speedup that outpace classical scaling, as in Fourier-transform-based workloads and other compute-intensive problems. Beyond raw acceleration, quantum devices can tackle computations that are impractical or impossible classically, such as simulating quantum physical and chemical systems or producing truly random samples from complex probability distributions. Since the late 1980s, ideas from Feynman and Manin catalyzed interest in quantum advantage; today, maturing hardware and manufacturing are accelerating adoption and creating demand for developers who can recognize where quantum, classical, or hybrid approaches fit. This chapter sets expectations: it emphasizes applied mathematics and software techniques over physics, so practitioners can become “quantum ready” and translate familiar computer science abstractions into quantum programs.

The chapter identifies two pillars of quantum advantage: quantum parallelism and measurement. Quantum parallelism lets a single instruction act on many value pairs at once, akin to an unlimited SIMD model, which can yield dramatic reductions in the number of required operations; however, its broad-brush action often requires compensating steps to prevent unwanted side effects. Measurement is inherently non-deterministic: a single run yields one outcome drawn from a probability distribution defined by the quantum state, and repeated “shots” reveal the distribution. Results are typically read as binary strings (and often interpreted as integers), enabling either digital encodings of answers or probabilistic estimates. Together, these properties enable both speed and capability gains, while introducing practical considerations like repeated runs, verification, and careful control of how parallel updates shape the final outcome probabilities.

From a programmer’s perspective, a quantum computation evolves a state—a list of probabilities-with-direction over all possible outcomes—through sequences of elementary operations that recombine pairs of values (a “butterfly” pattern), then performs a measurement that collapses the superposition to a single outcome. The number of outcomes grows exponentially with qubits, but operations still update all relevant pairs in parallel; programming becomes the art of choosing the right sequence of elementary instructions so that measurement statistics encode the solution. The chapter closes by outlining three recurring patterns: sampling from hard-to-generate distributions; searching for digitally encoded solutions (e.g., Grover’s algorithm, and period-finding in Shor’s algorithm); and estimating probabilities for analog encodings via many shots, sometimes at significant cost if converted to digital form. These concepts equip developers to spot problems suited to quantum or hybrid solutions and to work in a hardware- and library-agnostic way as the ecosystem matures.

Comparison of the increase in computational complexity for computing Fourier transforms.
CH01 F01 gonciulea
Visualization of the classical implementation for swapping consecutive values.
CH01 F02 gonciulea
Visualization of the quantum implementation for swapping consecutive values.
CH01 F03 gonciulea
A circle divided into equal sectors, where the sectors represent each possible outcome of a certain quantum computation.
CH01 F05 gonciulea
A classical bit works like a toggle or switch between 0 and 1.
CH01 F06 gonciulea
The stages of a computation using a classical bit.
CH01 F07 gonciulea
A quantum bit, or variable-bias coin, works like a slider that changes the probability of getting heads or tails.
CH01 F08 gonciulea
The stages of a computation with a quantum bit.
CH01 F09 gonciulea
The steps of a quantum computation.
CH01 F10 gonciulea
A wheel representation of a three-qubit quantum state in its initial state.
CH01 F11 gonciulea
A rose chart representation of the probabilities associated with the outcomes of a three-qubit quantum system.
CH01 F12 gonciulea
The possible pair combinations of a three-qubit system.
CH01 F13 gonciulea
The possible pair combinations of a four-qubit system.
CH01 F14 gonciulea
The steps of a quantum computation.
CH01 F15 gonciulea
A Galton board showing physical pegs driving marbles into bins according to the binomial distribution.
CH01 F16 gonciulea

Summary

  • To be “quantum ready” you need to understand the mechanisms of quantum advantage and which problem types they can help with versus classical computing.
  • Quantum parallelism and measurement can provide a quantum advantage over classical methods.
  • In a quantum computation, pairs of probabilities are changed simultaneously, and computation outcomes are selected according to these probabilities. Quantum computations have the following distinct characteristics:
    • The state of a quantum computation consists of a probability-with-direction for each possible outcome.
    • Elementary computing instructions change pairs of probabilities-with-direction in parallel (using the butterfly computational model/pattern).
    • Quantum measurement is like sampling all possible outcomes according to their probabilities through repeating the same computation.
  • There are three main quantum computing patterns: sampling from probability distributions, searching for optimal values, and estimating the probability of certain computation outcomes.

FAQ

What is “quantum advantage” and where does it come from?Quantum advantage is a speed and/or accuracy improvement over classical algorithms for the same task. It primarily stems from two phenomena: quantum parallelism (many pairwise updates applied at once) and probabilistic measurement. For some problems, such as Fourier transforms, this yields exponential speedups, and certain tasks (like simulating quantum systems or generating truly random samples) may be infeasible classically.
How do quantum and classical computing differ at a high level?Classical programs deterministically update bits and registers step by step. Quantum programs manipulate a state that encodes outcome–probability pairs and then perform a measurement that stochastically returns one n-bit outcome. Quantum instructions update many pairs of state values in parallel, and repeated runs are often required to gather useful information.
What is quantum parallelism, and how is it different from classical SIMD?Quantum parallelism lets a single instruction update all relevant pairs of state values simultaneously, without a fixed width limit. Unlike classical SIMD, which processes a small number of elements in parallel, quantum operations can affect an unbounded number of pairs at once. This power may require extra steps to restrict or correct unintended changes.
Why are Fourier transforms highlighted as an example of quantum speedup?Fourier transforms exemplify a setting where quantum parallelism aligns with the “butterfly” computation pattern, enabling substantial (often exponential) speedups over classical growth in time and memory. Because Fourier transforms underpin many tasks in signal processing, physics, and engineering, these speedups have broad impact.
What does measurement mean in quantum computing, and why are repeated runs needed?Measurement returns one outcome according to the state’s probability distribution and collapses the state to that outcome. Since results are non-deterministic, repeating the same computation (“shots”) is needed to estimate probabilities or to verify a specific answer with confidence.
What is a quantum state, superposition, and collapse?A quantum state assigns a probability-with-direction (phase) to every possible outcome. Before measurement, the system is in superposition—probability spread across outcomes. A measurement collapses the state so the measured outcome has probability 1 and all others 0; only the measured outcome is directly observable.
How many outcomes can an n‑qubit system produce, and how are results represented?An n‑qubit system has 2^n possible outcomes. A measurement returns one n‑bit string (often interpreted as an integer). By default, systems start in the all‑zeros outcome with probability 1 before any operations are applied.
What are “butterfly” operations and why do they matter?Butterfly operations recombine pairs of state values while conserving their total probability, with the target qubit determining the pairing. All such pairs are updated in parallel by a single quantum instruction. This pattern underlies elementary quantum gates and connects to the structure of the Fast Fourier Transform.
What main patterns of quantum computation does the chapter introduce?The chapter highlights three patterns: sampling from probability distributions (leveraging efficient, truly random sampling), searching for digitally encoded answers (e.g., Grover’s search, period finding in Shor’s algorithm), and estimating probabilities for specific outcomes (analog encoding) via many shots.
What does it mean to become “quantum ready,” and who should learn this?Being quantum ready means understanding when quantum, classical, or hybrid approaches fit; being able to model problems in outcome–probability terms; and implementing small-scale examples today. The material targets developers, ML practitioners, and CS students, emphasizing programming and mathematical techniques over hardware specifics, so skills transfer across platforms.

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
$399.99
only $33.33 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
  • Building Quantum Software with Python ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 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
  • Building Quantum Software with Python ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 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
  • Building Quantum Software with Python ebook for free