Round-trip testing 2026-10-24
Test a conversion together with its intended inverse. Equality of representations may need normalization, while equality of numerical values can be limited by floating-point rounding or truncation. Distinct strings can encode the same value, so a value round trip and a character-for-character round trip are different properties.
An independent oracle is still needed: the wrong functions and satisfy both composition identities on integers, although neither implements an intended identity conversion. Thus passing inverse-consistency tests does not alone establish the specification of either conversion.
Sample depth 2026-10-14
The sample depth is the number of bits allocated to one stored sample. An unsigned -bit integer has codes, . This is per component, not automatically per pixel: three eight-bit components require 24 payload bits per pixel. A raster image with pixels and such components requires payload bits before data compression, padding or a file header.
For a toy normalized shade , define uniform quantization with endpoints included byThe floor function implements rounding to the nearest code, with exact halves rounded upward. The reconstruction step is , and . For , the levels are ; for they are . Increasing sample depth refines this value grid without changing the spatial grid. These levels are uniform in ; if is encoded sRGB, they are not uniform in relative luminance.
PNG uses a bit-depth field per sample or palette index. Its grayscale type without alpha permits 1, 2, 4, 8 or 16 bits per sample; its truecolour type permits 8 or 16 bits per component. These are format-specific restrictions, not a rule for every raster image.[ref]
https://www.w3.org/TR/png-3/#11IHDR. W3C, PNG Specification, Third Edition, section 11.2.1, IHDR, Table 12
Sampling a discrete uniform distribution 2026-10-14
Let the numerical support of a probability distribution be . Its cumulative distribution function counts how many values have been passed:It is zero below , equals on for , and is one at and above . Every jump is , even when the horizontal gaps differ.
For inverse transform sampling, take an ideal continuous uniform distribution for on . Partition that interval into intervals of width and outputEach interval has probability , proving the desired discrete uniform distribution. Using the floor function, the index is ; for consecutive integer values the output is . With the usual quantile function convention , one instead writes for , using the ceiling function. The endpoint conventions differ only at a finite set of points with probability zero under the ideal continuous uniform distribution.
For , the four intervals , , , and select , respectively. Thus selects , while selects . The upper half of the interval selects values at least four, recovering probability . Equal widths refer to the sampling probability coordinate, not to distances between output values. This is an exact mathematical construction assuming an ideal continuous uniform distribution; a finite computer random-number source needs its own justification of equal output chances.
Scala 2.12 BigInt API documentation 2026-10-24
Official archived documentation: www.scala-lang.org/api/2.12.8/scala/math/BigInt.html
Relevant locators: remainder
%, gcd, isValidInt and toInt. Scala's BigInt provides arbitrary-precision integer arithmetic; representability must be checked before conversion to a fixed-width integer because narrowing conversion need not preserve the exact value. The archived API corroborates the operations used in the solution without claiming a particular installed Oxford course library version. Schinzel-Tijdeman exponent theorem Created 2026-10-14 Updated 2026-10-20
For a fixed polynomial with at least two distinct complex roots, integer solutions with and have an effectively bounded exponent. Factorization over a splitting field and the fixed differences between distinct roots control common ideal divisors. Outside a fixed set of primes, each factor's valuation is divisible by , where is its root multiplicity. The generalized power-equation estimates from linear forms in logarithms of algebraic numbers, including unit and exceptional-prime factors, give the exponent bound. A single-root polynomial and the values cannot be included: , and for , give infinite exponent families.
Semidiscrete Fourier transform Created 2026-10-24 Updated 2026-10-31
For a sequence indexed by the integers, its semidiscrete Fourier transform is the displayed Fourier series in . For square-summable data the series is interpreted in the L2 norm. Its inversion and Parseval identity areThe physical-frequency convention uses and on . This is distinct from the discrete Fourier transform of a finite vector. Translation-invariant finite difference operators become Fourier multipliers, making Fourier stability analysis possible.
Semigroup Created 2026-09-24 Updated 2026-10-14
A semigroup is an algebraic magma whose binary operation has the associative property. Its products can be regrouped while preserving the order of their elements. An identity element and inverse elements are not required.
For example, the positive integers with addition form a semigroup, since and a sum of positive integers is positive. They have no identity element: it would have to be zero, which is outside that set. Nonempty words over an alphabet with concatenation give a noncommutative example without an identity element. Including the empty word instead gives a free monoid.
Semistandard Young tableau Created 2026-10-05 Updated 2026-10-14
A semistandard Young tableau fills a Young diagram with positive integers, permitting repeated entries, so that entries weakly increase along rows and strictly increase down columns. Its content records the number of occurrences of each entry. The Kostka number counts such fillings of shape and content .
Separate chaining Created 2026-10-13 Updated 2026-10-20
With separate chaining, each hash bucket in a hash table contains a collection of records, often a linked list. Lookup computes the bucket index, then follows that chain until a key equality comparison succeeds or the chain ends. A hash collision therefore affects the search work without merging unequal keys. Deletion searches the same chain and unlinks the matching record; in a singly linked list, remembering the preceding record during the search permits the unlink.[ref]
For the four-key integer example in hash table, insert a new record at the head of its chain after checking that its key is absent. Inserting in that order makes hash bucket hold , hash bucket hold , and the other two hash buckets empty. All five subsequent operations below select hash bucket because :
Separate chaining traces lookup, replacement, deletion and insertion through key equality
. Original deterministic model with . The table counts actual keys inspected, not elapsed machine time. Operations occur from top to bottom; only an absent key adds a new record, and the untouched record remains in hash bucket . Details.get(5) rejects key , accepts key , and returns after two key equality comparisons. get(13) rejects and reports absence after three comparisons. put(5,B*) examines and replaces the value without changing . delete(9) examines just the head record, removes it, and gives . Finally, put(13,E) rejects before inserting the new head record; returns to and the chain is . The successive hash table load factors are . These counts follow from the stipulated chain order; a different insertion policy changes the successful-search counts.For a chain of length , lookup and deletion by key take time complexity in Big O notation. The same applies to
put before any resizing, since replacement semantics require checking for an existing equal key. Head insertion alone is if absence is already known; that is a different precondition. These bounds assume bucket-index hashing, array access, key equality comparisons, allocation and link updates. A long string or large integer can make hashing or comparison depend on its encoded length, so counting record visits alone does not establish constant running time.Under simple uniform hashing, each distinct key's bucket index is an independent random variable with a uniform distribution on a finite set of indices. The keys and query are fixed independently of this random assignment. Then lookup has expected time complexity, where is the hash table load factor; it is expected when stays bounded. These are model assumptions, not an automatic consequence of using a deterministic hash function.[ref]
Lecture 8: Hashing I. 6.006 Introduction to Algorithms, Fall 2011 by Massachusetts Institute of Technology, 6.006 course staff; pp. 4–5, chaining worst case and simple uniform hashing assumption
Here is the short calculation. For an absent query and stored keys , let be the indicator random variable of . The number of records inspected has expected valueby linearity of expectation. For a present fixed query, scanning its entire chain inspects at most itself plus all other colliding records, with expected value ; stopping at the match only decreases this upper bound. Adding constant hashing and bucket access yields expected for either query. The argument needs pairwise collision bounds; it does not require all the indicator random variables to be independent. A universal hash family can provide a related bound by random choice of a hash function for a fixed key set, as explained in that article.
The worst case remains , and an absent query takes comparisons if all records occupy its hash bucket. For instance, all collide under . Separate chaining remains correct, but a sequence of insertions that each checks the existing chain can take quadratic total work. Amortized analysis of resizing does not remove this search cost, and an adaptive choice of keys based on a known hash function is outside the stated simple uniform hashing model.
Sequence Created 2026-09-24 Updated 2026-10-14
A sequence assigns a value to each position in an ordered index list. For an infinite sequence in a set , one standard convention is a function , written with . Some applications start the index at zero, and a finite sequence has only finitely many positions. Values may repeat; both order and repetition matter. [ref].
For example, begins , whereas begins . Their sets of values are both , but these are different sequences. A subsequence keeps selected positions in increasing order; the subsequence of at its even integers is the constant sequence . A tail of a sequence retains all positions from one index onward.
Sequences express successive approximations, repeated observations, and the iterates of a recurrence relation. A limit of a sequence describes where its terms eventually concentrate. Finite observations alone cannot establish that behaviour: for any positive integer , the all-zero sequence and the sequence with for and for agree through index , yet have different limits of sequences. A formula or bound controlling the entire future, such as the tail diameter of a sequence in the Cauchy sequence condition, supplies information that a finite list cannot.
Set without natural density 2026-10-14
Include the positive integers in , and exclude the intervening integer intervals and zero. Equivalently, include for . Each included block is large enough to raise the running proportion; the following excluded block lowers it again.
With , the exact boundary counts follow from a geometric series:The first sum is empty at . Dividing by the corresponding boundary, rather than using one denominator for both, givesFor example, , whereas , yielding proportions and . For , the exact count is ; for it stays . Hence the proportion increases through each included block and decreases through each excluded block. These boundary subsequences give the actual limit inferior and limit superior:Since these differ, has no natural density. Its upper asymptotic density still records its largest limiting proportion.
Shapley value denominator in a simple game 2026-10-25
In an -player simple cooperative game, every marginal contribution along a player permutation is zero or one. The Shapley value is its average over the equally likely permutations. Thus counts the orders in which player changes a losing coalition into a winning one and is an integer. In lowest terms, the coordinate's denominator divides . This is a necessary constraint on a proposed Shapley value vector, not a sufficient one.
Shortest-path pursuit distance bound 2026-10-25
Suppose two pieces occupy a common connected component of a graph in an unweighted undirected graph. For integers , in each round an evader moves at most edges, then a pursuer moves up to edges along a shortest path to the new evader position, stopping upon capture. Let be their finite graph distance at a surviving round boundary.
The triangle inequality bounds the separation after the evader moves by . If that separation is at most , the pursuer captures it. Otherwise the pursuer reduces it by exactly , givingHence every surviving history has at most rounds. With a finite branching factor, the surviving search tree is finite and depth-first tree search becomes a complete search algorithm. This does not make its first goal optimal for arbitrary rewards. Initial reachability is essential: an infinite graph distance supplies no decreasing finite bound.
Sieve of Eratosthenes 2026-10-14
The sieve of Eratosthenes finds all prime numbers at most an integer . Start with the integers marked as candidates. For each surviving candidate in increasing order, mark the multiples up to as composite numbers. Stop processing candidates once : the surviving candidates are exactly the prime numbers. Starting at saves work because any smaller proper multiple of already has a smaller prime factor. [ref]
https://web.stanford.edu/class/cs106aj/res/handouts/36-Section-6.pdf. Jerry Cain, Stanford CS106AJ, Section Handout 6, Problem 4: the sieve of Eratosthenes
.For a complete run with , the only prime numbers at most are , since . Exclude one before starting; it is not a prime number. The four marking passes are:
- : mark , removing 29 candidates.
- : mark . The nine newly removed candidates are ; the even integers were already marked.
- : mark . Only are newly removed.
- : mark . Only is newly removed.
There are surviving prime numbers:The next surviving candidate is , and , so no further marking pass is necessary. A prime number used for marking remains a candidate: starting at never marks itself.
Four passes of the sieve of Eratosthenes through 60 leave seventeen prime numbers
. Blue cells are newly marked composite numbers; gray cells were removed earlier. White cells are candidates in the first three panels, and green cells are the final prime numbers. The outlined cell identifies the prime number used for that pass. One is excluded throughout. Details.The saving from starting at is justified by the smaller multiplier: if with , then has a prime factor , so has already marked . For , the earlier multiples have already been marked using or . The first new possibility is .
For , only the prime numbers need marking passes. They remove all the composite numbers, leaving 25 prime numbers. The diagram colors each composite number by its smallest prime factor, so it shows which marking pass removes it first. The excluded integer one is shown separately.
Why does the algorithm work? A surviving candidate cannot be a composite number, since its smaller prime factor would already have removed it. Conversely, marking proper multiples never removes a prime number. Every composite number at most has a prime factor at most , so no later pass is needed. The sieve of Eratosthenes is useful when an entire bounded list is wanted; primality testing of one large integer is a different computational task.
The historical name is supported by a surviving primary account: Nicomachus, in Book I, chapter 13 of Introduction to Arithmetic, names Eratosthenes and describes separating prime numbers from composite numbers by marking multiples among the odd integers beginning with three. That passage documents the sieve tradition; the bounded algorithm above and its starting rule are the formulation explained here, rather than instructions quoted from Euclid's Elements. [ref]
https://stoicheiamath.com/wp-content/uploads/2025/09/Nicomachus-Introduction-to-Arithmetic-Student-Edition.pdf#page=28. Nicomachus, Introduction to Arithmetic I.13.2–8, Martin Luther D'Ooge translation (1926), revised classroom edition by Nathanael Hahn (2025), pp. 24–25
Sign-bracketing binary search 2026-10-24
Suppose integer endpoints satisfy and . Repeatedly test an interior midpoint and replace the endpoint with its matching sign. The loop invariant is the ordered opposite-sign bracket. The positive integer width is a loop variant, and at termination . Thus an adjacent sign transition can be located in evaluations without assuming that is monotone. If extends continuously between the endpoints, the intermediate value theorem associates the sign bracket with a zero. This is different from finding the first true position of a globally monotone predicate.
Signed power-of-two division by biasing 2026-10-25
For signed two's complement integers, a conditional positive bias converts the rounding behaviour of an arithmetic right shift into C integer division. It can be formed without a conditional branch by turning the sign bit into either zero or a low--bit bit mask.
Proof. Nonnegative needs no adjustment. If , write , . Then , whose quotient rounded down is , exactly the quotient truncated towards zero. The bias fits safely for in an -bit signed word: it is added only to negative inputs, and the largest possible adjusted input is . The corresponding remainder is , where .
Sign extension 2026-10-24
To widen an -bit two's complement integer to bits, preserve the original low bits and fill the new high positions with the old sign bit . The change in signed positional weights is , so the represented signed value is unchanged. Zero extension instead preserves the unsigned interpretation, and changes the signed value of negative inputs.
Simple random walk Created 2026-09-24 Updated 2026-10-14
A simple random walk on a locally finite graph chooses each vertex in the current vertex's graph neighbourhood with equal probability, assuming there is at least one available neighbour. On the integer line there are two choices, one unit left or right, so each has probability . This is the one-dimensional simple symmetric random walk. Terminology varies: a simple random walk on the integer line is also often allowed unequal step probabilities, with “symmetric” specifying the fair case.
For a simple symmetric random walk starting at , each increment has the Rademacher distribution, with expected value zero and variance one. Thus linearity of expectation and the variance of a sum of independent random variables giveFor example, after steps the expected value is zero, the variance is , and the standard deviation is . Doubling the typical distance scale takes four times as many steps. This square-root growth explains why a random walk can wander far even when there is no preferred direction.
Four fair and two biased unit-step random-walk paths, with their expected values and bands one standard deviation wide on either side.
Details. The colored curves are illustrative sample paths, not averages over all possible walks. The dashed curves show the expected values; the shaded bands show the expected value plus or minus one standard deviation at each time. These bands are a scale of spread, not confidence intervals, and give no guarantee that an entire sample path stays inside them.
Zero expected value does not make this a stationary process: its one-time probability distribution changes with , as the increasing variance already proves. It does have stationary increments and independent increments, because blocks of fresh steps have the same probability distribution at any starting time and disjoint blocks use independent random variables. This separation of position from increment is one reason the random walk is such a useful first example of a stochastic process.
Simple random walk on the integer line Created 2026-09-24 Updated 2026-10-14
A simple random walk on the integer line starts at and takes independent and identically distributed random variables as unit increments, withThe simple symmetric random walk has ; a biased random walk has . At or every step is deterministic, giving or respectively.
Count the rightward steps using indicator functions:Thus the endpoint is a shifted and rescaled random variable with a binomial distribution. For a worked example, at the endpoint means exactly three rightward steps and one leftward step. There are possible orders, so its probability is , equal to in the fair case. More generally the binomial coefficient counts the orders, giving the exact probability mass functionIn particular, the endpoint must have the same integer parity as : . For the support of a probability distribution is exactly . At only even integers in are reachable; at only odd integers are reachable. This restriction is easy to lose if one draws a smooth curve instead of discrete probability masses. The fair-walk counting argument is also presented in Grinstead and Snell, Introduction to Probability, section 12.1.
Exact binomial endpoint probabilities for fair walks of 20 and 80 steps and a biased walk of 80 steps; only even endpoints are possible.
Details. The endpoint identity and the binomial distribution give the expected value, variance, and standard deviationA short direct check gives and , hence . Then apply linearity of expectation and the variance of a sum of independent random variables.
The absolute width and the width relative to the number of steps answer different questions. In the fair case the standard deviation grows from to , while shrinks from to . At , the standard deviation is , or times the fair width, and . Centering and dividing by each walk's own standard deviation gives, for ,This rescaling equalizes the variances, not the entire probability distributions. The spacing between reachable endpoints is two, so its rescaled spacing is : approximately for the fair -step walk, for the fair -step walk, and for the biased -step walk.
The positions themselves are dependent. For , , where the second term is independent of . Their covariance is thereforeFor example, in the fair case allows or , whereas allows or . Nevertheless the position process is a Markov chain: given its current position, the next fresh increment has no dependence on its past. Its transition probabilities areThese transition probabilities are the same at every time and every integer position: shifting both and by the same integer leaves unchanged. Thus the Markov property and independent increments coexist with dependent positions.
Simple type Created 2026-10-13 Updated 2026-10-24
In the examples here, a simple type is a finite expression built from the base types
int and bool using function types:For example, describes a function accepting an integer and producing a Boolean value. During type inference, the grammar is extended with type variables such as for types not yet determined. A type scheme additionally binds such type variables; it is distinct from the individual simple type used at one call.



