CHAPTER 01
Information, probability, and computation
Learning goals. Encode information in bits, calculate conditional probabilities, distinguish reversible computation, and compare algorithms using stated costs.
1.1 Bits and representations
A bit labels one of two distinguishable alternatives. The labels do not specify the implementation: voltage, magnetization, or optical path may carry a bit if the alternatives can be prepared and read reliably. An -bit string labels possibilities because every new position doubles the count.
The string 10110 represents
It could instead label a color or database record. Encoding is a convention shared by the algorithm and its users. Confusing a number with its representation causes complexity errors. An integer requires about bits; a procedure using operations can be exponential in the input length.
NOT exchanges 0 and 1. XOR, written , is addition modulo two: and . AND gives 1 exactly when both inputs are 1. A half adder outputs sum and carry . For , is binary 10, decimal two.
1.2 Probability and shots
A distribution assigns nonnegative values summing to one. For a noisy bit, and . A probability does not mean the bit has a fractional value; it predicts outcome frequencies across repeated preparations.
For independent trials, the probability of a particular sequence multiplies. Exactly ones in trials has probability
The binomial coefficient counts the sequences with that many ones. The sample proportion has mean and variance . Its standard deviation decreases as . Four times the shots approximately halves statistical uncertainty.
Worked example. For and ,
An observed proportion 0.27 is unsurprising. The calculation assumes identically distributed, independent shots. Drift or correlated noise can invalidate the assumption without changing the arithmetic.
Conditional probability is
If 60 of 100 runs are accepted and 54 accepted runs are correct, conditional accuracy is . The probability of an accepted correct result per attempted run is . Both numbers matter when evaluating postselection.
Writing the joint probability in two ways gives Bayes’ rule:
A decoder uses this idea to infer which error likely produced an observed syndrome. The most likely error need not involve the fewest flipped bits if the prior probabilities differ.
1.3 Entropy and redundancy
Shannon entropy is
with by continuity. A fair bit has entropy one; a known bit has entropy zero. This measures uncertainty in a distribution, not memory size or energy [2].
Repeat a bit three times as 000 or 111. Under independent flips of probability , majority voting fails when two or three bits flip:
At the failure probability is 0.028. Protection costs extra physical bits and assumes reliable encoding and decoding. A common disturbance flipping all three bits defeats the independent-noise model. Quantum codes will preserve arbitrary amplitudes rather than copies of an unknown state, but the need to specify noise remains.
1.4 Reversibility and workspace
A reversible transformation is one-to-one. NOT is reversible. AND alone is not: 00, 01, and 10 produce the same output. A function can be embedded in a reversible map by preserving its input:
Applying it twice restores , because . When the target starts at zero, it contains afterward. The retained input prevents information loss.
CNOT maps to . Toffoli maps to . Toffoli computes AND into a zero target while retaining the inputs. Its action permutes eight basis strings, so its matrix is also a quantum unitary.
Intermediate workspace can remain entangled with an answer. The compute–use–uncompute pattern calculates a function, uses it coherently, then reverses the calculation to clear temporary data. This is not housekeeping: distinguishable workspace can destroy interference between alternatives [3].
Laboratory L01 — Reversible logic and repetition. Explore CNOT and Toffoli truth tables. Change the flip probability and compare unencoded and three-bit failure probabilities. Identify the independence assumption.
1.5 Comparing algorithms
Costs include gates, sequential depth, oracle calls, shots, memory, and elapsed time. Low depth can require many parallel qubits. Few queries can hide an expensive oracle. An accurate estimate may require many executions of the entire circuit.
means constants exist with for . It is an asymptotic upper bound, not an exact runtime. includes a matching lower bound. Small-input overhead and constants remain relevant in practice.
P contains decision problems with polynomial-time deterministic classical algorithms. BPP permits bounded-error classical randomization. BQP permits bounded-error quantum computation with uniform polynomial-size circuits. NP means that yes-instances have efficiently verifiable certificates; it does not stand for “not polynomial.” Whether BPP equals BQP is open. No theorem says quantum computers efficiently solve all NP-complete problems.
Factoring has a polynomial-time quantum algorithm but is not known to be NP-complete. Grover gives a quadratic query improvement in unstructured search, not an automatic exponential improvement in every optimization task. A useful comparison specifies the problem, encoding, accuracy, and best applicable classical method.
1.6 Exercises
1.1. Convert 45 to six-bit binary and count the possible strings.
Show solution / guidance
, giving 101101. Six bits label strings.
1.2. For outcome probability 0.8, find the standard deviation of the observed proportion in 100 and 1,600 shots.
Show solution / guidance
and . Sixteen times the shots gives four times smaller standard deviation.
1.3. Factor . When does repetition help?
Show solution / guidance
It is , negative for . It vanishes at . A known channel with can first have its outputs relabeled.
1.4. Explain why AND alone cannot be unitary and Toffoli can.
Show solution / guidance
AND merges orthogonal inputs and changes dimension. A unitary preserves inner products and dimension. Toffoli is a bijective basis permutation with orthonormal matrix columns.
1.5. An algorithm calls an oracle times; each call costs elementary operations. What work is hidden by a query count?
Show solution / guidance
The calls alone cost elementary operations. An oracle-call bound does not include implementation, preparation, or other algorithmic work unless explicitly stated.