Karatsuba digit-operation cost 2026-10-13
Count a fixed-base digit addition, subtraction, digit copy, or single-digit multiplication as constant cost. Base stays fixed as grows; an entire arbitrary-length integer multiplication is not one constant-cost step. With this model, splitting, sum formation, shifts and recombination require digit operations. Ordinary digit-by-digit multiplication forms digit products for two -position operands. The GMP base-case description uses this rectangular product arrangement.[ref]
Basecase Multiplication. GNU MP 6.3.0 manual, §15.1.1 Basecase Multiplication: rectangular cross-products and O(NM) cost
The ideal equal-half recurrence relation isFor , level has calls of size . If each internal call incurs exactly times its size in additional digit work, that level contributes . There are leaves. The geometric series of internal work isThus fixed positive leaf cost plus this internal work grows on the order of . In Big O notation, . Removing one of four products at every level matters much more than saving just one at the root.
Karatsuba recursion levels and an explicitly stipulated cost comparison
. Left: the ideal equal-half recursion for , with three children per internal call. Right: model counts for , one unit per leaf and internal overhead for size with . The resulting count is , compared with ordinary digit products. This illustrates the recurrence relation; its constants and crossover are stipulated, rather than measured execution times. Details.The literal sum-based implementation instead admits the upper boundfor a nondecreasing worst-case cost envelope above a fixed base-case threshold. The extra digit does not change the exponent: since , subtracting three from the size makes each child's adjusted size at most half its parent's. Stop this comparison at any fixed threshold greater than three; its recursion depth is and the level-work sum is bounded by the same geometric series up to constant factors. Exact call counts can depend on carries, zero shortcuts and the threshold, so they need not equal the ideal at each depth.
Karatsuba multiplication Created 2026-09-28 Updated 2026-10-13
Karatsuba multiplication is a divide-and-conquer algorithm for multiplication of integers. Splitting each operand into two blocks seems to require four smaller products; the Karatsuba three-product identity recovers the two cross terms together from just three products. Repeating that saving through recursion changes the time complexity from quadratic to , where counts digits in a fixed positional notation. The exponent is about : the benefit comes from the algorithm, even though each splitting step needs more addition and subtraction.
The Karatsuba worked multiplication below computes using , , and . The last operand already shows why “half-size” needs care: Karatsuba carry handling and Karatsuba recursion termination account for the extra digit. Karatsuba digit-operation cost states the operation model; Karatsuba practical crossover explains why the asymptotic saving alone does not select a useful threshold.
The original 1962 paper presents a binary numeral system automaton construction: its Theorem 2 and proof reduce multiplication to taking squares of numbers, then reduce a larger square of a number to three smaller squares of numbers. Its footnote explicitly addresses the extra digit in a sum of halves. The sequential time complexity analysis below uses a different operation model from that paper's automaton size and depth bounds, including its Boolean circuit realization without feedback.[ref]
Multiplication of many-digital numbers by automatic computers by A. Karatsuba and Yu. Ofman. Karatsuba and Ofman, Multiplication of many-digital numbers by automatic computers, original Russian article, 1962, pp. 293–294: Theorem 2, its proof, and the footnote on p. 294
Karatsuba practical crossover 2026-10-13
Karatsuba digit-operation cost explains eventual scaling, while a practical base-case threshold depends on the costs of addition, subtraction, copying and function calls relative to small integer multiplication. Using for a base-case cost, one Karatsuba level costs : the quadratic coefficient falls to , but the linear contribution includes . Small operands can therefore cost more despite the smaller exponent. This comparison and the effect of implementation improvements on the threshold are described in the GMP manual.[ref]
The plotted crossover belongs only to the stipulated constants in its caption; its ordinary-method curve counts digit products alone, while the Karatsuba curve includes the chosen internal overhead. Selecting a threshold for real software requires measuring the actual implementation on its intended machine. With base for a fixed machine digit width , the same analysis counts machine digits; it does not establish a universal crossover in decimal digits, bits, or elapsed time.
Karatsuba three-product identity 2026-10-13
Compute exactly three smaller products,The distributive property gives , so the cross coefficient is . Recombine byThe saving is that and are never separately multiplied. Multiplying a digit block by or shifts its position in positional notation; it does not require another general integer multiplication. Addition of the shifted results still requires Karatsuba carry handling.
Three products recover the Karatsuba cross coefficient
. The arrows carry exact integer values for the Karatsuba worked multiplication. Only the three coloured product boxes require recursive multiplication; the lower boxes use subtraction, digit shifts and addition. Details. LU factorization and solve costs 2026-10-14
For classical dense Gaussian elimination over the real numbers, count each scalar addition, subtraction, multiplication or division as one arithmetic operation. At step , there are elimination multipliers to divide out and remaining entries, each requiring one multiplication and one subtraction. Thus this implementation's unpivoted factorization count isHere uses Big O notation. Partial pivoting adds comparisons and row movement, leaving the leading arithmetic count unchanged. The leading count agrees with the standard dense LU decomposition analysis.[ref]
With unit , forward substitution uses arithmetic operations. Back substitution uses another plus diagonal divisions. Together these cost per right-hand side; applying a stored row permutation moves entries and requires no scalar arithmetic. In Big O notation, Reusing LU factors for multiple right-hand sides therefore costswhereas refactorizing for each of the right-hand sides costs . For and , the leading counts are about versus arithmetic operations, nearly a tenfold saving. These are operation counts, not measured runtimes: memory access and optimized matrix multiplication also affect speed.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.5.2, Important note after Definition 2.5.2: flop counts are a rough runtime model; the numerical comparison here is an original calculation
Operator associativity 2026-10-14
The syntactic grouping convention for successive operators of the same precedence. Left grouping of subtraction makes
a-b-c mean (a-b)-c; it does not make subtraction an associative operation.Represent the data bits, most significant first, by a polynomial whose polynomial coefficients lie in the field with two elements . Here addition and subtraction are both exclusive or, with no carries. Choose a fixed CRC generator polynomial of polynomial degree , with leading and constant polynomial coefficients one. Both endpoints know and the bit ordering.
Multiply by , which appends zero bits. Use polynomial division to obtainReplace the appended zeros by the bits of the polynomial remainder , retaining leading zeros when necessary. The transmitted polynomial isThe last equality holds because adding cancels the existing polynomial remainder in the field with two elements. It is the simple systematic cyclic redundancy check convention used here; practical variants can add agreed initialization and final transformations.
The receiver divides the entire received polynomial by . A nonzero polynomial remainder detects corruption. If the received word is , where the ones in the error polynomial mark flipped bits, its polynomial remainder is . Thus the undetected nonzero errors are exactly the multiples of ; a zero result does not prove that transmission was error-free. Operationally, polynomial long division repeatedly cancels a leading one using a shifted copy of , implemented with exclusive or operations.
Executive functions should contribute most when learning or assessment requires keeping several pieces of information active, suppressing an attractive error, coordinating successive operations or changing strategy. This predicts particularly strong links with multistep mathematics, mathematical problem solving and reading comprehension, alongside classroom engagement and following instructions. It predicts a smaller direct contribution to well-practised fact retrieval or fluent decoding once those operations are automated. That is a task-demand hypothesis, not a claim that every mathematics score must correlate more strongly with executive functions than every literacy score.
Working memory maintains goals and intermediate results: a child doing a subtraction with borrowing must retain both the original problem and its updated intermediate state. Inhibitory control helps suppress a larger-number answer that is tempting but irrelevant, or a familiar operation when the problem requires another. Cognitive flexibility supports switching between representations or abandoning an unsuccessful strategy. In reading, maintaining earlier propositions and rejecting an initially plausible interpretation should matter especially for comprehension and inference; knowledge of letter–sound correspondences is not itself an executive function. Repeated practice can change which process is the bottleneck, so developmental stage and familiarity matter.
Historically, the unity-and-diversity framework helped replace an undifferentiated “executive ability” with correlated but distinguishable processes. Akira Miyake and colleagues used several tasks per proposed component and latent variable analysis to separate common executive variance from individual task demands. Their influential study tested adults: its factor structure cannot simply be assumed to describe preschool children. It nevertheless supplies a crucial methodological lesson. A single executive task measures the intended control process together with perception, language, motor speed and task-specific strategies. Treating a raw score as a pure capacity risks attributing the wrong source of variance to school achievement.[ref]
More directly, Clancy Blair and Rachel Peters Razza followed 141 children from low-income homes, measuring preschool self-regulation and later kindergarten mathematics and literacy. Their inhibition measure required children to tap once when the experimenter tapped twice and twice after one tap: the apparatus is simple, but the rule requires suppressing imitation and maintaining an opposite response mapping. Inhibitory control was associated with emerging mathematics and reading after accounting for intelligence. This supports the importance of regulation during early learning, but the design was observational, not random assignment to different inhibitory capacities. Shared language, family circumstances or classroom experience could influence both performances.[ref]
Relating effortful control, executive function, and false belief understanding to emerging math and literacy ability in kindergarten by Clancy Blair and Rachel Peters Razza. Child Development 78, 647–663; Measures and academic-outcome regressions
Lucy Cragg and colleagues provided a more differentiated mathematical analysis. Their sample of 293 participants aged eight to twenty-five completed executive tasks and measures of factual knowledge, procedures and conceptual understanding. Working memory had both an association with overall mathematics and indirect associations through mathematical component skills; inhibition measured in a numerical context was linked to factual and procedural knowledge. This is more informative than treating “mathematics” as one outcome. However, statistical mediation in an age-spanning observational sample does not establish that changing the putative mediator would change attainment. Numerically framed executive tasks can also share content with the achievement measures, increasing the apparent specificity of the association.[ref]
Direct and indirect influences of executive functions on mathematics achievement by Lucy Cragg and others. Cognition 162, 12–26; abstract, executive-function battery and mediation models
Kate Cain and colleagues supply a corresponding literacy result. In assessments at ages eight, nine and eleven, working memory and comprehension components such as inference and monitoring predicted reading comprehension after controls for word reading and verbal ability. Sentence-span and digit-working-memory measures helped avoid defining the entire construct by one task. This supports a contribution beyond decoding, but the reported concurrent relations at successive ages are not an experimental demonstration of causal direction; comprehension itself can affect performance on verbally loaded memory tasks.[ref]
Children's reading comprehension ability: concurrent prediction by working memory, verbal ability, and component skills by Kate Cain and others. Journal of Educational Psychology 96, 31–42; longitudinal assessments at eight, nine and eleven years, concurrent prediction models
Evidence across populations qualifies the temptation to make executive functions the master explanation of achievement. Greg J. Duncan and colleagues compared six longitudinal datasets while controlling earlier child skills and family background. School-entry mathematics and reading were strong predictors of subsequent attainment; attention added prediction, whereas several socioemotional measures did not. Attention ratings are not interchangeable with laboratory inhibition or working memory measures. The result supports a classroom-regulation pathway while showing that already acquired domain knowledge remains central. Learning also exercises executive control, so baseline-adjusted longitudinal associations do not eliminate reciprocal influence or unmeasured confounding.[ref]
School readiness and later achievement by Greg J. Duncan and others. Developmental Psychology 43, 1428–1446; abstract and cross-dataset models; corrected version
Intervention offers a sharper causal test, but its target and outcome must be distinguished. Darren L. Dunning and colleagues randomly allocated seven- to nine-year-olds with low working memory to adaptive computerised training, low-load nonadaptive training or no training. The adaptive condition improved several untrained working memory tests, with some gains maintained over time, but did not produce corresponding academic or classroom-analogue benefits. The active comparison helps separate memory-load effects from attention, computer practice and expectations. Crucially, improvement on an untrained but structurally similar memory test is near transfer; improved reading or mathematics would be far transfer. One does not entail the other.[ref]
Does working memory training lead to generalized improvements in children with low working memory? by Darren L. Dunning and others. Developmental Science 16, 915–925; three-arm randomised trial, Results and Discussion
This trial does not show that working memory is irrelevant to achievement. A resource can constrain performance even when practising isolated tasks fails to change how it is deployed in a classroom. Nor does one intervention test all executive components, age groups or teaching methods. It does undermine the stronger inference from correlation to a promise that generic executive training will raise school attainment. Supporting instruction through shorter directions, external reminders and staged problems can reduce executive demands; whether any particular classroom support improves learning still requires an appropriately controlled outcome study.
The most defensible answer is therefore conditional and specific. Executive differences are especially plausible influences on managing novel, attentionally demanding, multistep learning and demonstrating that learning under load. They operate alongside knowledge, language, motivation and opportunity. Strong evidence would combine reliable multi-task executive measures, differentiated academic outcomes, repeated measurements with comparable meaning across ages, and interventions with active controls and delayed achievement tests. Existing prospective and experimental evidence supports executive functions as contributors to learning, while limiting claims that they are a single cause of educational success.
Past exam of the mathematics course of the University of Cambridge 2022 ii Paper 2 18H a Solution Created 2026-09-24 Updated 2026-09-25
If the minimal polynomial of has degree , then
has elements and is an intermediate field of
. The tower law for field extensions givesso .
has elements and is an intermediate field of
. The tower law for field extensions givesso .
The multiplicative group of a finite field is cyclic. Choose a generator
of , of order . If lay in a proper intermediate field of degree , its order would divide , a contradiction. Thus
and its minimal polynomial has degree .
of , of order . If lay in a proper intermediate field of degree , its order would divide , a contradiction. Thus
and its minimal polynomial has degree .
For arbitrary , let be the splitting field of
over . Its roots form a field: the Frobenius endomorphism shows they are closed under addition, subtraction, multiplication, and inversion. The derivative is , so there are exactly distinct roots. Thus this root field has order . Applying the preceding generator argument supplies an element whose minimal polynomial over has degree , proving that an irreducible polynomial of every positive degree exists.
over . Its roots form a field: the Frobenius endomorphism shows they are closed under addition, subtraction, multiplication, and inversion. The derivative is , so there are exactly distinct roots. Thus this root field has order . Applying the preceding generator argument supplies an element whose minimal polynomial over has degree , proving that an irreducible polynomial of every positive degree exists.
Maintain a stack of values of the complete subexpressions encountered so far, with the newest value at its head:The left fold processes tokens in their order. A number pushes its own value; an operator replaces the two latest subexpression values by their combination. The top value is the right operand, so preserving the order in
evalRP :: RPolish -> Int
evalRP = finish . foldl push []
where
push :: [Int] -> Elem -> [Int]
push stack (Number n) = n : stack
push (right:left:stack) (Operator op) =
applyOp op left right : stack
push _ (Operator _) = error "missing operand"
finish :: [Int] -> Int
finish [value] = value
finish _ = error "malformed expression"applyOp op left right is necessary for subtraction and division. Induction on the consumed token prefix proves this stack machine invariant. A complete valid expression finishes with exactly one value.Evaluate the recurrence relation successively, retaining only the preceding two values. Each of the updates uses three multiplications and one subtraction. Hence arithmetic operations and auxiliary storage suffice, excluding the stored input. Naively branching into two recursive calls would repeat work; the sequential computation is essential. This is an arithmetic-operation bound, not a bit-complexity bound for arbitrarily large exact integers.
Prefix sum Created 2026-09-24 Updated 2026-10-14
A prefix sum stores the accumulated sum through a specified position in a finite sequence or array. For inputs , include the empty sum and setFor the original input , the prefix array including is . A negative entry makes the accumulated sum decrease; a prefix sum does not have to be monotone. Conversely, the original entry is recovered by subtraction: .
The useful cancellation is that any contiguous block has sumBoth prefixes include the entries before ; subtracting cancels those entries. In the example, the sum from positions two through four is , recovered as . The arithmetic mean of that block is , obtained by dividing its sum by its length. Prefix sums therefore make many repeated questions about an unchanged array cheap: reuse accumulated totals instead of resumming every block.
The sequential recurrence builds all prefixes in time complexity and storage; each block query needs two reads and one subtraction, hence time complexity. These counts assume constant-cost arithmetic and access to array entries. If one input changes, all later stored prefixes change, so this simple representation is most useful when queries outnumber updates. For integer inputs, sufficient numeric capacity must be retained; with floating-point arithmetic, subtracting large nearby prefixes can lose relative accuracy for a small block total. The exact mathematical identity does not eliminate representation error.
The apparently sequential recurrence also motivates a prefix scan: associativity permits a tree of partial calculations that yields all accumulated results in parallel. Guy E. Blelloch's 1990 technical report systematically develops this operation and its applications; its authored chapter version explains the two tree sweeps used to obtain all prefixes. [ref]
https://www.cs.cmu.edu/afs/cs.cmu.edu/project/scandal/public/papers/CMU-CS-90-190.html. Blelloch, Prefix Sums and Their Applications, CMU-CS-90-190, November 1990
. [ref]https://www.cs.cmu.edu/~guyb/papers/Ble93.pdf. Blelloch, authored chapter version, §§1.1–1.2: sequential scans and parallel tree sweeps
. Primitive recursive pairing function Created 2026-10-06 Updated 2026-10-14
A primitive recursive pairing function is a pairing function whose encoding function and both coordinate functions of its inverse function are primitive recursive functions. Thus the bijection can be used in either direction inside a construction by primitive recursion and function composition in recursion theory. A decoder that is merely a computable function would not establish this stronger closure property. Sutner's definition of a primitive recursive pairing system explicitly includes the decoding functions; his more general systems need only be injective, whereas a pairing function here is a bijection.[ref]
https://www.cs.cmu.edu/~cdm/resources/02-coding.pdf. Klaus Sutner, Primitive Recursion, slide 9: primitive recursive encoding and unpairing functions
The Cantor pairing function is a primitive recursive pairing function. For its encoding, construct the triangular numbers directly by primitive recursion:Since addition is primitive recursive, so are and by primitive recursion and function composition in recursion theory. This establishes the claim without treating division by two as an unexplained primitive operation.
For decoding, use bounded minimization to defineThe bound is valid for every natural number : , so the candidate always succeeds. The search includes zero; when , it immediately returns . If , the preceding candidate failed, which gives ; when , that lower inequality follows from . Thus this search finds exactly the diagonal in the Cantor pairing function inverse, withThe comparison is primitive recursive, and bounded minimization of a primitive recursive predicate is primitive recursive. Therefore is a primitive recursive function. Recover the coordinates byIn constructions on the natural numbers, implement these subtractions using the primitive recursive operation : apply the predecessor function times to by primitive recursion. On these inputs it agrees with ordinary subtraction, since the diagonal inequalities imply . Consequently and are primitive recursive functions, and . Zimmermann proves the relevant closure under bounded minimization and the primitive recursive character of the Cantor encoding and coordinate decoding; his convention adds the first coordinate, so its coordinates are exchanged relative to here.[ref]
https://tore.tuhh.de/bitstream/11420/1312/1/book.pdf. Karl-Heinz Zimmermann, Computability Theory, §2.3, Proposition 2.26 and Propositions 2.32–2.34, printed pages 18 and 21–22
For a worked bounded minimization, take . Candidates give , none exceeding . Candidate gives , so , , and . The search bound was ; it terminates much earlier in this example. The bound proves membership in the primitive recursive functions; it is not a claim that scanning all candidates is the fastest implementation.
For each fixed , define a tuple encoder byEach and each coordinate decoder is primitive recursive, by finitely many applications of function composition in recursion theory to . For the three-entry tuple encoded as , applying returns , applying returns , and then , . The tuple length remains part of the agreed convention, as explained for a general pairing function.
This makes primitive recursive pairing functions useful for encoding several evolving values as one state in primitive recursion. For example, store consecutive Fibonacci numbers as and update byThe codes start , decoding to . Every step uses primitive recursive encoding, decoding and addition; a single numerical state therefore carries the two values needed for the next step. This is also the reason a suitable Gödel numbering should permit sufficiently simple decoding: representation should preserve the class of functions being studied.
Subtraction Created 2026-09-24 Updated 2026-10-13
Subtraction adds the additive inverse: . On the number line, is a shift three units left from . Reversing the two inputs changes the sign: , so subtraction is generally not commutative. Solving gives the same answer by adding to both sides; the operation preserves equality while undoing the added amount.
Tiny-pivot roundoff in Gaussian elimination 2026-10-18
A nonzero pivot element can still be a poor numerical choice. Partial pivoting bounds the absolute values of the elimination multipliers by one in exact arithmetic, because each numerator is no larger than the selected denominator. This usually improves numerical stability, but does not prevent every possible growth of intermediate entries or guarantee accurate answers for every linear system.[ref]
2.6 Row pivoting. Fundamentals of Numerical Computation by Tobin A. Driscoll and others; §2.6.4, Example 2.6.6, equation (2.6.3) and concluding discussion: small-pivot instability and the limits of pivoting
To see the mechanism without depending on hardware, define a toy floating-point arithmetic model. The operator rounds an exact real number to the nearest value with three significant decimal digits; halfway cases choose the even final digit, and . Allow an unbounded exponent range. Round the inputs and the result of every addition, subtraction, multiplication and division separately; a product followed by a subtraction rounds twice. This is a prescribed arithmetic model, not a measurement of a physical computer. All inputs in the following original example are represented exactly:Without a row interchange, the elimination multiplier is . The last coefficient and right-hand side becomeTwo distinct exact values now have the same rounded representation. Back substitution therefore returnsThe small difference carrying information about was lost during elimination; the final subtraction only exposes that loss. Dividing by the tiny pivot element amplifies sensitivity to the lost information.
With partial pivoting, interchange the two rows, including their right-hand sides, to start from . Now , and the rounded updates areBack substitution gives and . Both paths round intermediate values, but only the first creates million-sized entries and then divides a lost difference by .
The true solution follows from the original second equation :Evaluate the linear-system residual against the original data in exact arithmetic, separately from the three-digit solve. With , the maximum norm, the results areThe respective relative linear-system residuals are and . Computing the diagnostic in higher precision matters: a check made only against the rounded reduced equations would miss the original error.
The same three-digit floating-point arithmetic model gives without a row interchange and with partial pivoting; exact linear-system residuals expose the difference
. Details. This matrix is well conditioned in the maximum norm: its induced matrix norm is , whileThe failure therefore belongs to this unpivoted algorithm, rather than a large condition number. In general, however, partial pivoting cannot remove sensitivity inherent in the data. For any approximate solution of an invertible matrix system, ; the induced matrix norm inequality and giveA small linear-system residual controls solution error only in conjunction with the condition number; numerical stability and sensitivity are different questions.[ref]
Tridiagonal solve costs 2026-10-14
For the displayed unpivoted Thomas algorithm with one right-hand side, count each scalar addition, subtraction, multiplication or division as one arithmetic operation. Forming takes five arithmetic operations per forward step. The last unknown takes one division; each remaining back substitution step takes three arithmetic operations. ThusThis is an operation-count model, excluding assignments, indexing, pivot checks and any special simplifications of the coefficients. It is not a timing benchmark. The original tridiagonal matrix needs scalar entries, and its right-hand side another . Overwriting with and with , then with , keeps storage ; the arrays, rather than the few loop temporaries, determine the total space complexity.
For repeated right-hand sides, retain the LU decomposition: computing once costs arithmetic operations, and each subsequent pair of forward substitution and back substitution sweeps costs . Hence right-hand sides cost arithmetic operations. This is the banded counterpart of Reusing LU factors for multiple right-hand sides.
Unit roundoff 2026-10-14
For floating-point arithmetic with precision in radix and rounding to nearest, unit roundoff is the half-gap scale . If a nonzero exact real number lies in the normal finite range, its nearest rounded value satisfiesIndeed, the absolute distance to the nearest value is at most , and gives the bound. For a correctly rounded addition, subtraction, multiplication or division, apply this estimate to the exact result of that one operation on the stored operands. The bound does not include earlier roundoff error or automatically bound a whole algorithm. Results outside the finite range and tiny subnormal numbers require separate treatment. Rounding in a directed mode also changes the bound.[ref]
https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html. Goldberg, 1991, §§Relative Error and Ulps, Exactly Rounded Operations



