Past exam of the mathematics course of the University of Cambridge 2007 iii Paper 30 6 Solution Created 2026-10-03 Updated 2026-10-14
Extend by zero outside . Here is a dyadic endpoint convention for small Type I and Type II sums. Write , with a power of two. Type I sums are -small if, for every , dyadic with , and arbitrary integer intervals ,Type II sums are -small if, for all dyadic and sequences ,Zero extension handles boxes crossing the endpoint . Fixed choices of open or closed dyadic endpoints do not matter, but interval uniformity and uniformity in both bounded coefficient sequences do matter. These are the estimates used in the Vinogradov Type I–II method.
An interesting technical step is Fourier separation of interval cutoffs. For an integer interval , let . Discrete Fourier inversion givesThe exponential geometric sum bound gives a common envelope , with . Divide the interval transform by this envelope: at each frequency it is a bounded coefficient depending on , and is a bounded coefficient depending on . The Type II sum assumption therefore bounds the interval-cutoff sum by . Choosing the outer unit phases to turn each inner sum into its modulus extends the Type I sum bound to boxes where both variables are in the Type II range.
Take . With subscripts denoting truncation of arithmetic functions, the Vaughan identity iswhere now means Dirichlet convolution. For completeness it follows from and : expand , cancel the short terms, and retain . The short first term contributes to the sum against .
The next two terms give Type I sums. The logarithmic term has outer coefficient , , and inner factor , removed by partial summation at a cost . In the other term the outer variable is with coefficientThis logarithmic coefficient bound in Vaughan identity avoids a loss from a divisor weight. On boxes with short outer variable use the hypothesis directly; on boxes where both variables are at least use the extended bound proved above. Boxes with inner variable less than contain at most pairs in total and are treated trivially. All remaining inner scales are at most whenever the outer scale exceeds .
For the final convolution, group the variables asBoth variables lie between constant multiples of and , well inside the Type II range. Divide by , and apply the Type II sum estimate. If the product cutoff is kept explicitly, Fourier separation of interval cutoffs costs only one extra logarithm; zero extension also permits its omission. There are boxes in the dyadic decomposition. The coefficient bound and, where needed, partial summation cost at most one more logarithm. These estimates give the convenient boundWith , each term is , proving the assertion. The grouping of the long term uses the nonnegativity of the Von Mangoldt function; more usual groupings instead control a divisor coefficient by a second-moment truncation. Ben Green's notes, Sections 2.3–2.4 describe that standard alternative.
Now take the sign version of the Thue–Morse sequence, . Concatenation of binary digits gives for . Expanding over all choices of digits proves the Thue–Morse Fourier productPair adjacent factors. If , their modulus issince the maximum on occurs at . Thus uniformly, where .
Every integer interval is a disjoint union of aligned binary blocks with at most two blocks of each length. On such a block the digit concatenation identity and the Thue–Morse Fourier product give the same bound, up to a unit phase. Summing the geometric series proves the uniform interval cancellation for binary digit parityFor a fixed , the sum is a sum over multiples of in an integer interval . The additive character orthogonality filter givesIts modulus is , independently of and the interval. Summing at most outer values proves the small Type I sums for binary digit parity:This is smaller than for sufficiently large . It proves the required Type I cancellation; the substantially harder Type II cancellation is not needed for this final clause.
For a normal half-precision floating-point number, write the stored fields as sign , biased exponent and ten-bit fraction . The value is for . The leading one is implicit: the ten stored fraction bits give eleven significant binary digits including that one. The normalized binary representations and stored fields are
| Value | Normalized binary representation | Sign, biased exponent, fraction |
|---|---|---|
0 01110 0000000000 | ||
0 01110 0100000000 | ||
1 01100 1000000000 | ||
0 10010 1111000000 |
Thus the four 16-bit words areEvery conversion is exact: all four numbers have terminating binary representations within the available precision.
Store a second array For the second loop, write . Immediately before processing , its loop invariant isInitially the failed squaring guard gives ; this also holds when , since then . The test succeeds exactly when . If successful, adding selects that binary digit; otherwise the upper bound tightens to . Either way the invariant holds for the next smaller . At , , so
weight with weight[k] = 2^k. Descending through the binary digits of the answer gives this greedy algorithm:PROCEDURE FastLog(b, n: INTEGER): INTEGER;
VAR b2, weight: ARRAY enough OF INTEGER;
top, k, i, p: INTEGER;
BEGIN
b2[0] := b; weight[0] := 1; top := 0;
WHILE b2[top]*b2[top] <= n DO
b2[top+1] := b2[top]*b2[top];
weight[top+1] := weight[top]+weight[top];
top := top+1
END;
i := 0; p := 1; k := top;
WHILE k >= 0 DO
IF p*b2[k] <= n THEN
p := p*b2[k]; i := i+weight[k]
END;
k := k-1
END;
RETURN i
END FastLog;i = L.There are squarings and descending tests. For fixed , this is arithmetic operations, hence logarithmic in the bit length of , and also within the weaker bound. This counts arithmetic operations on integers as unit cost; bit complexity would also charge for the growing operands. No division is used.
Repeated integer division by two generates the binary digits from least significant to most significant. Reverse the accumulated characters once, and treat zero separately.
def binaryCon(n: Int): String = {
require(n >= 0, "n must be nonnegative")
if (n == 0) return "0"
var remaining = n
val digits = new StringBuilder
while (remaining > 0) {
digits.append(if (remaining % 2 == 0) '0' else '1')
remaining /= 2
}
digits.reverse.toString
}Zero produces
"0"; positive inputs produce a binary number without leading zeros. No library routine performs the number-to-base conversion. Appending to the builder and reversing once gives linear work in the number of binary digits and uses that much output storage.Validate the complete input before doing the addition. The arrays use most-significant-digit-first positional notation. The result has one extra leading position, which contains either zero or the final carry.
def binaryAddition(x: Array[Int], y: Array[Int]): Array[Int] = {
require(x != null && y != null, "arrays must not be null")
require(x.length == y.length, "lengths must match")
val n = x.length
var k = 0
while (k < n) {
require((x(k) == 0 || x(k) == 1) &&
(y(k) == 0 || y(k) == 1), "digits must be 0 or 1")
k += 1
}
val answer = new Array[Int](n + 1)
var carry = 0
var j = n - 1
while (j >= 0) {
val column = x(j) + y(j) + carry
answer(j + 1) = column % 2
carry = column / 2
j -= 1
}
answer(0) = carry
answer
}A failed
require throws IllegalArgumentException, covering mismatched lengths, invalid binary digits and null arrays. The largest column sum is three, so the carry always lies in . The binary-addition carry invariant says that the already processed input suffixes equal the written result suffix plus the carry shifted to the next column. After the final column, placing that carry at position zero proves the returned value is the sum. Neither input array is modified. Equal empty inputs are accepted as zero and return Array(0); the specification imposes no positive-length restriction. Running time and result storage are . Rudin-Shapiro sequence 2026-10-20
For a nonnegative integer , let count overlapping occurrences of in its binary expansion. The Rudin-Shapiro sign sequence is . Appending a binary digit gives and .
Simply normal number 2026-10-14
A real number is simply normal in base if each individual digit in its positional notation has limiting digit block frequency . This is the length-one part of the definition of a normal number. It places no equal-frequency requirement on longer words.
For example, is a simply normal number in base two: each binary digit has frequency . But and never occur, and and each have frequency . Thus is not a normal number in base two. Even a sequence that looks more complicated, such as the deterministic Thue–Morse sequence, must be tested against the actual digit block frequency definition; visual complexity is no substitute for it.
The decimal representation makes the same point in base ten. Every digit has frequency , yet the only adjacent pairs areEach has limiting digit block frequency ; the other ninety pairs have frequency zero. A normal number in base ten requires for every one of the hundred pairs. This rational number is a simply normal number in base ten, but it is not a normal number in that base.
Thue–Morse Fourier product 2026-10-14
Each binary digit independently contributes either or , proving the product. Two adjacent factors have modulus . Consequently the product is , with . This two-factor estimate suffices for a power saving, though its exponent is not optimal.
Thue–Morse sequence Created 2026-10-14 Updated 2026-10-20
Here is the sum of the binary digits of the nonnegative integer . The sign version is . Concatenating binary digits gives for . It supplies cancellation controlled by binary blocks rather than multiplicative factorization.
Wilson's theorem 2026-10-14
For an integer , Wilson's theorem characterizes prime numbers by a factorial:The right side is an integer congruence, so the least nonnegative remainder is . For example, certifies that five is a prime number, whereas rules out six. [ref]
For an odd prime number , each nonzero congruence class has a unique modular multiplicative inverse. Pair each class with its inverse: each distinct pair contributes one. A class is its own inverse exactly when ; since , Euclid's lemma leaves only . Their product is . The prime number two needs a separate check: . Conversely, a proper divisor divides both and , so the displayed integer congruence would force , a contradiction. [ref]
The composite numbers have an even sharper pattern: for every composite number , but . To check the zero claim, write with . If , both occur as different factors in the factorial. If , the different factors and both occur since , and their product is divisible by . The only excluded case is . Thus four is an exception to the zero pattern, but still fails Wilson's theorem: its required remainder would be three.
This is an exact primality testing criterion, but direct evaluation is expensive: even reducing modulo after every multiplication still takes a number of multiplications proportional to , which grows exponentially with the number of binary digits of . The problem is not merely storing a huge factorial. The more useful role of Wilson's theorem is simplifying factorial expressions in modular arithmetic. For instance, if is a prime number, then gives by a modular multiplicative inverse.
