Sorting algorithm 2026-10-13
A sorting algorithm rearranges a finite sequence into nondecreasing order under a chosen total order on its keys. Its output must contain every input entry exactly once, including repetitions: producing ordered values is insufficient if entries are lost. Merge sort is one such algorithm; stable sorting adds a requirement about equal keys.
Sorting creates reusable structure: equal sort keys become adjacent, and a sorted array supports binary search. However, an algorithm correctness check must establish both sortedness and sorting permutation preservation. Replacing every entry by the smallest key can produce ordered keys while destroying the original data. Stable sorting imposes a third condition when equal sort keys occur: retain their arrival order.
For example, take complete sorting records , with the first component as the sort key and the letter as associated data. A correct output is . The sort keys are ordered, every complete sorting record remains, and the equal-key pairs keep before and before . The output satisfies sortedness and sorting permutation preservation, but fails stable sorting. The output has the right multiset of sort keys but loses and duplicates ; it fails sorting permutation preservation of complete sorting records.
To express stable sorting precisely, label every input occurrence by its original position, even when two complete sorting records have identical contents. Let be the output position of the occurrence originally at position . Besides sortedness and sorting permutation preservation, require
Here is the sort key function. Sorting by the pair under lexicographic order gives the same order as stable sorting by : the original position breaks ties without discarding associated data. For a two-field ordering, first apply stable sorting by the secondary sort key, then apply stable sorting by the primary sort key. The second pass retains the secondary order within each group of equal primary sort keys. For instance, first becomes by letter, then by number.
Sort key Created 2026-10-13 Updated 2026-10-20
A sort key is the value extracted from a complete entry to determine its ordering. Model extraction as a function into a total order; compare and , while moving the complete entries. Ordering sorting records by an age field does not also compare their names. Repeated sort keys are allowed, so this induces equal-key groups even when the complete sorting records differ. Keep the sort key function and the comparison rule fixed throughout a sort; inconsistent comparisons need not admit any sorted result.
Space complexity Created 2026-09-24 Updated 2026-11-05
The space complexity of an algorithm measures the maximum working storage used during its computation as a function of encoded input length. A machine-level definition must state which storage counts. In a common Turing machine convention, a read-only input tape and a write-only output tape are excluded, while visited work-tape cells are counted.
For example, count the ones in a binary string of length by scanning once and retaining a binary counter. Its value ranges from zero to , requiring bits for the counter. Keeping a separate copy of the full input would instead require bits. The computation can therefore use much less working storage than the amount of data it examines.
The maximum concerns simultaneously retained storage, not the total amount allocated and later reused over time. Bit complexity and a unit-cost model also need care here: treating an arbitrarily large integer as one storage cell can hide its growing representation size.
Sparse map with a default value Created 2026-10-24 Updated 2026-10-31
Represent a total function by storing only selected entries of a finite partial function and returning a fixed default for missing keys. A missing payment-count record can denote two zero counts. Storing an explicit default-valued record can have the same observable meaning, so the abstraction function need not be injective. Update operations must preserve all unrelated keys and establish the intended change whether or not the key was previously stored.
Take , the nonnegative integers, and , the positive integers. Choose the injections
Here is an inclusion map, while reaches only the positive even integers. In particular, is not a bijection: it misses every positive odd integer. Simply using the inverse function of on its image misses input zero.
The remedy is to follow the alternating injections starting at the missing input zero:
The subscripts distinguish an input in from an output in , even when their numerical values agree. The resulting subset of is . Its sequence of members satisfies and , giving by mathematical induction. Define the function
Figure 1.
A bijection moves only the sequence
. The upper row alternates the original injections and . Solid blue arrows are the chosen bijection on ; dashed gray arrows only continue the chain. Below, examples outside use and keep their numerical values. Every displayed number belongs to the explicitly constructed example. Details.
The image covers all the positive members of exactly once. The other inputs cover exactly once by staying fixed. These output sets are disjoint and their union is , proving that is a bijection. In particular, , , , while and .
For completeness, its inverse function is
The familiar bijection also works, but this example shows something more specific: the two chosen injections can repair the missing zero by moving only a sparse sequence of inputs. The repair never has to shift the entire set.
Special function 2026-11-05
A special function is a named family of functions with a developed theory of identities, transformations, asymptotic behavior and numerical evaluation, often arising repeatedly as solutions of differential equations or integral representations. The boundary with elementary functions is conventional rather than a strict mathematical classification.
For example, the regular solution of normalized by is the order-zero Bessel function . Such a function packages a recurring radial-wave calculation into a reusable object. The Gamma function similarly extends factorial values through for nonnegative integers, allowing identities involving integer parameters to be studied continuously.
Spectral kernel expansion of a reversible chain Created 2026-10-06 Updated 2026-11-05
For a finite irreducible Markov chain satisfying detailed balance with , its transition matrix is a self-adjoint operator for . For a real orthonormal eigenbasis with eigenvalues ,
Indeed, apply the spectral decomposition of to the function , whose coefficient against is . For , every eigenvalue multiplier is interpreted as one.
Spectral mapping theorem Created 2026-09-24 Updated 2026-11-05
A spectral mapping theorem relates the spectrum of an operator to the spectrum after applying a function to it. For a bounded linear operator on a complex Banach space and a polynomial ,
Factor over the complex numbers. If no root lies in , every factor is invertible, so their product is invertible. Conversely a product of commuting factors can be invertible only if each factor is invertible, giving the reverse inclusion.
For a matrix with eigenvalues one and three, has eigenvalues two and ten. More general functions require a specified functional calculus; an unrestricted substitution rule for unbounded operators is not automatic.
Spectral method Created 2026-09-29 Updated 2026-11-05
A spectral method approximates an unknown function by a finite expansion in global basis functions, such as Fourier modes or orthogonal polynomials. A Galerkin method makes the residual orthogonal to the retained trial space; a collocation method instead makes it vanish at selected nodes. The expansion coefficients are the numerical unknowns.
For the -periodic heat equation, a Fourier series truncation
gives under Fourier–Galerkin method projection. Each retained mode decays independently, and differentiation becomes multiplication of its coefficient by . This turns a partial differential equation into finitely many ordinary differential equations.
Rapid convergence comes from rapid coefficient decay. If with , the omitted tail has an exponentially small uniform norm bound by a geometric series. Limited smoothness or discontinuities can prevent that rate. A large number of retained modes cannot justify exponential convergence without the needed solution regularity.
Spectral profile Created 2026-09-24 Updated 2026-11-05
The Spectral profile records the energy needed to concentrate a function on sets of a given stationary mass. For a finite irreducible Reversible Markov chain with Stationary distribution , define
Here is its Dirichlet form of a Markov chain, and ensures that admissible nonempty sets exist. This is the variance-normalized convention.[ref]
The profile is nonincreasing in , because enlarging permits more supports. The ordinary spectral gap is a lower bound on every , but small supports can force a larger Rayleigh quotient. For the symmetric two-state chain with off-diagonal Transition probability , a function supported on one state has energy and variance , so .
The denominator matters. Replacing variance by gives a restricted Dirichlet eigenvalue instead. On a support of mass at most , the Cauchy-Schwarz inequality gives , relating the two conventions within a factor .
Spectral theory 2026-11-05
Spectral theory studies a linear operator through the scalars at which it fails to be invertible in the required sense. For a bounded operator on a complex Banach space, its spectrum consists of for which has no bounded inverse defined on the whole space.
In finite dimensions this is the set of eigenvalues. In infinite dimensions there can be more: multiplication by on has spectrum but no eigenvectors. An eigenfunction at would have to be supported on the single point , a null set. Functions concentrated near that point nevertheless have arbitrarily small , ruling out a bounded inverse.
Spectrum analyzer Created 2026-10-14 Updated 2026-11-05
A spectrum analyzer measures signal level as a function of frequency. A swept heterodyne instrument selects frequencies through mixing and filtering; an FFT-based instrument estimates spectral content from sampled time records. Resolution bandwidth, observation time and windowing affect whether close tones are distinguished and how noise appears. A tall spectral peak is not automatically the signal's total power: calibration and integration conventions matter. Compared with an oscilloscope's time trace, the spectrum exposes frequency components, harmonics and out-of-band emissions.
Spherical average Created 2026-09-24 Updated 2026-11-05
The spherical average of a function about at radius is its normalized integral over the sphere:
Here is surface measure on the unit sphere. Normalization ensures . This is an average over the surface, distinct from the average over the solid ball.
For , symmetry makes the linear term in vanish, so . By contrast, a harmonic function satisfies whenever the closed ball lies in its domain. This mean value property explains the connection with the Laplace operator and radial wave equation formulas.
Spherical mean Created 2026-09-28 Updated 2026-11-05
The spherical mean of a function on averages it over a sphere of radius about :
Here is surface measure on the unit sphere and is its total area. Using the unit sphere absorbs the physical surface-area factor into the change of variables. The expression requires an integrable restriction to that sphere; continuity near it is one sufficient condition.
For , expanding and using the zero average of gives . By contrast, the mean value property for harmonic functions gives when is harmonic on a neighborhood of the closed ball. Averaging over a boundary sphere and averaging over the whole ball are different operations, even though both have a mean-value property for harmonic functions.
Spline approximation Created 2026-09-24 Updated 2026-11-05
Spline approximation represents a function by low-degree polynomial pieces joined at specified knots. Smoothness conditions control the agreement of neighboring pieces. This permits local changes without fitting one high-degree polynomial across the entire domain.
The simplest example is piecewise-linear interpolation on a uniform grid. If on each cell of width , the interpolation remainder gives . More regular cubic splines impose derivative continuity as well. Spline quasi-interpolation uses local functionals instead of solving for a global interpolating fit, making locality useful in both analysis and computation.
Square wave Created 2026-10-14 Updated 2026-10-18
A square wave alternates between two constant levels for equal halves of a period. Choose a -periodic function equal to on and on , with value zero at the jumps. Its odd function symmetry makes the mean and every cosine Fourier coefficient vanish. Directly integrating the two constant pieces gives
Thus only odd sine Fourier harmonics occur, with amplitudes decreasing like the reciprocal of their frequency multiplier. Every finite Fourier partial sum is smooth, yet their pointwise limit has jumps. At those jumps the Fourier series converges to zero, the midpoint of the two levels, regardless of which value we assign to the original function there.
This example explains how smooth components can encode sharp transitions. Increasing the number of Fourier harmonics narrows the transition region, but also produces the persistent overshoot described by the Gibbs phenomenon. The illustrated square wave and coefficient calculation are mathematical constructions, not measurements of a physical device.
Suppose are bounded functions on the same nonempty set, and the supremum norm of their difference is at most . Then their optimal values differ by at most the same amount:
Indeed, for every , so ; exchange and for the other direction. Adding a constant shifts a supremum by that constant, a basic compatibility between upper bounds and addition.[ref]
For a chosen example on , take and . Their supremum error is , since . Completing the square gives
Thus has maximum zero at , while has maximum at . The change in optimal value, , is smaller than the certified bound . For the vertical translation , the bound is exact: its supremum error and optimal-value change are both .
Figure 1.
Uniform error controls the optimal value; maximizing inputs require additional control
. Original polynomial examples on . Left: and lie within a vertical error band of , while their maxima differ by . Right: the small tilts and have maximizing inputs and for every ; solid lines use and dashed lines use . These chosen examples are not measured errors or claims about an arbitrary optimizer. Details.
A stable optimal value does not guarantee a stable maximizing input. On , the two linear functions and satisfy
For every positive , their unique maximizing inputs remain two units apart, at and . Both functions approach the flat zero function, which has many maximizing inputs. Consequently an accurate objective function value is not by itself a certificate that the optimizing decision is accurate.
The estimate also gives a convenient consequence of uniform convergence. If converges uniformly to a bounded function on a nonempty , then for the bounded tail of the sequence. Uniform control handles the changing input that defines the best value. Pointwise convergence alone supplies no such control; the existing examples under uniform convergence illustrate that distinction.
Stateful channel iteration and Fibonacci numbers Created 2026-10-25 Updated 2026-10-31
Consider a component that remembers its previous input and maps input to , then sets . Feeding each output back into the same component gives state transition . Starting at , the successive outputs are , the Fibonacci numbers after calls. The state transition, rather than a memoryless function on one integer, explains the recurrence. Replacing the component between calls or repeatedly feeding a fixed external input gives different behavior.
State monad 2026-10-31
A computation represented by a function from an initial program state to a result and a final program state. Its sequencing passes each output program state to the next computation.