False. On every odd positive integer , . Given any proposed Big O notation constant and threshold , choose an odd . Then , contradicting the required bound. The behavior on even integers cannot repair this failure on an unbounded subsequence.
Use tensor-product quadrature with composite Simpson's rule in each coordinate. If there are subintervals in each direction, then and the quadrature rule error is : apply the one-dimensional error bound for composite Simpson's rule successively, using bounded fourth partial derivatives. Hence the error is in big O notation. The rectangular domain makes the product grid convenient.
Use composite Simpson's rule on this smooth, bounded one-dimensional interval. Its fourth derivative is bounded on the interval, so the error bound for composite Simpson's rule gives in big O notation as the number of function evaluations increases.
Use Simpson's rule: the cubic exactness of Simpson's rule includes every quadratic integrand, so three function evaluations already give the exact answer. Thus the error is zero. For a general smooth integrand the corresponding composite Simpson's rule has error in big O notation, but that bound is unnecessarily weak here.
A convenient choice for this irregular region is Monte Carlo integration. The region is contained in . For independent uniform points in that square, letThe indicator random variable incorporates the curved boundary directly. This estimator is unbiased; the integrand is bounded on the square, so its variance is finite. The variance of a sum of independent terms gives root mean square error in big O notation. This is a stochastic error rate. Applying a rectangular Simpson's rule to the indicator-weighted integrand would lose the smoothness required for its fourth-order error bound.
For a generic integrand in 20 dimensions, Monte Carlo integration gives root mean square error , whereas tensor-product quadrature with composite Simpson's rule gives only . One can sample uniformly in the Euclidean unit ball, for example by an independent uniform direction and radius with uniform on .
For this particular integrand, the most efficient elementary choice uses radial integration over a ball first. The area of the unit 19-sphere is , as follows from the volume of an n-ball. HenceThe reduced integrand is smooth. Apply composite Simpson's rule to obtain deterministic error in big O notation, with one original radial integrand evaluation per node. If the selection is restricted to direct multidimensional methods, Monte Carlo integration with root mean square error is the appropriate choice.
In big O notation, means that there exist and such that for every integer . For the required polynomial versus exponential growth comparison, . If and , thenBy mathematical induction, for all . Thus , with and .
The statement in Big O notation means that some and integer satisfy for all . The statement in big omega notation means that some and satisfy for all .
Finally, in big theta notation means that some and satisfyEquivalently it is both an eventual upper bound and an eventual lower bound. These definitions ignore a finite initial segment; they do not assert pointwise inequalities with constant one.
Suppose first that . Choose and so that for . There are only finitely many natural numbers below . Because at each of them, all ratios in this finite prefix are finite. LetThen both in the prefix and in the tail, hence on the entire domain of a function. This proves the finite-prefix extension of a big O bound.
Conversely, a bound valid for every natural number is certainly valid eventually. The purported real constant cannot be negative because never vanishes; if it is zero, enlarge it to a positive constant. The definition of Big O notation then applies. The nonvanishing assumption is what permits the finite exceptions to be absorbed into one constant.
True. Rationalization gives, for ,This lies between zero and , so it is in Big O notation. In fact it converges to , rather than to zero. The rationalized form also avoids the catastrophic cancellation of subtracting two nearby large quantities.
True. For every integer , and . ThereforeThe constants and satisfy the definition of Big O notation. Whether the chosen convention for natural numbers includes zero is immaterial to this eventual assertion.
False. On the unbounded subsequence of odd positive integers, . For any proposed constants , choose an odd . Then , contradicting the eventual upper bound required by Big O notation. The small ratio on even integers cannot compensate for this failure on infinitely many odd integers.
Use the reciprocal-factorial sum for increasing accuracy. Let be the requested number of decimal places and use absolute error tolerance proportional to . Expanding gives and , so these are genuine first nonzero error orders. The first approximation needs of order . Even its fast implementation therefore uses multiplications, while the linear version uses exponentially many in . The third approximation needs of order , but its fast powering still uses multiplications, with two parallel accumulators and a cancellation-prone subtraction.
For the Taylor series sum, Stirling's formula gives , so a sufficient term count grows as . Its divisions therefore grow more slowly than the multiplication counts of either fast-power alternative. More concretely, its positive tail satisfiesThe first omitted term also gives a lower bound . This is the reciprocal-factorial series remainder bound, supplying an explicit stopping certificate rather than relying only on Big O notation. It follows by bounding every successive tail denominator factor below by .
The sum also avoids subtraction of nearly equal large values and has small positive terms, making it numerically preferable. For a particular small accuracy request, constants and actual term counts may be compared directly; an asymptotic error bound alone does not prove a universal finite-input operation ranking. With ordinary
Double, sufficiently many tiny positive terms stop changing the rounded sum, so beyond machine precision a higher-precision version is necessary regardless of the formula.This is lower-bound search: return the first position whose value is at least the target, allowing the result to equal the array length. The notation for an empty suffix is vacuously true, so this also covers a target larger than every entry and the empty array. Assume a stable sorted array, ordered nondecreasingly.
def ternarySearch(a: Array[Int], x: Int): Int = {
var lo = 0
var hi = a.length
while (lo < hi) {
val third = (hi - lo) / 3
val m1 = lo + third
val m2 = hi - 1 - third
if (a(m1) >= x) hi = m1
else if (a(m2) < x) lo = m2 + 1
else {
lo = m1 + 1
hi = m2
}
}
lo
}The loop invariant isInitially the excluded prefix and suffix are empty, so both quantified assertions hold. During an iteration, . If , sortedness makes every later value at least , so replacing
hi by m1 preserves the right assertion. If the first test failed and , every earlier value is below , so replacing lo by m2 + 1 preserves the left assertion. Otherwise ; both new exclusions are valid, and lo = m1 + 1; hi = m2 retains exactly the unresolved middle. In that branch , since a single value cannot satisfy both strict and nonstrict inequalities in opposite directions.The nonnegative loop variant
hi - lo strictly decreases. In fact, with old length and , the three possible new lengths are , with the middle branch feasible only when nonnegative; each is at most . At exit lo == hi, and the loop invariant is exactly the desired partition. The result is the unique lower-bound index, including the first equal entry when duplicates occur. This ternary lower-bound search uses comparisons and auxiliary space, in the Big O notation word-operation model. The index formulas also avoid computing an overflowing 2 * length.Put and suppose , so there are interior grid points , . Write . The fixed ends impose homogeneous Dirichlet boundary conditions,For a sufficiently smooth displacement field, the two Taylor series at fixed time givewhere all displayed derivatives on the right are evaluated at . Adding cancels the odd terms, leaving the second-order central differenceSubstitute this finite difference into the wave equation and retain continuous time. The resulting method of lines gives coupled second-order ordinary differential equations,In particular, the first and last equations are and for . With the interior displacement vector only,Equivalently, , , and all other entries vanish. This entrywise definition also covers small , including when . The matrix is a symmetric matrix and a tridiagonal matrix. The spatial approximation has error in Big O notation; time has not yet been discretized.
Polynomial versus exponential growth 2026-10-25
Every fixed power is eventually smaller than an exponential function with base : for a fixed nonnegative integer , . To prove this, the ratio of successive terms is , so after finitely many terms the ratio is bounded by a fixed . A geometric series bound then proves the limit. In particular in big O notation.
Power iteration direction error 2026-10-14
For a unit vector spanning the target eigenspace and a normalized iterate , defineThis is the norm of the component in the orthogonal complement of , equivalently the sine of the acute angle to its line. It ignores the arbitrary sign or complex unit factor of an eigenvector. Under power iteration convergence for a diagonalizable matrix, in Big O notation. The orthogonal projection defines how we measure direction; it does not assume that the eigenbasis of is orthogonal. In computation, the projection form avoids subtracting nearly equal numbers inside the square root.
Radix sort Created 2026-10-13 Updated 2026-10-18
Radix sort sorts encoded sort keys a digit at a time. Its least-significant-digit version uses stable sorting on each successive digit, often by counting sort. For digits with possible values each, it takes time complexity in Big O notation, assuming constant-cost digit extraction and indexing. Stable sorting retains the ordering established by earlier digits when a later digit ties. Both digit access and the direct indexing in counting sort lie outside the comparison sort model, so these bounds do not contradict the comparison sorting lower bound.[ref]
Representation independence 2026-10-13
Representation independence means that clients restricted to the promised API cannot distinguish implementations by the specified results and state transitions. State what observations count: equal returned labels and failure statuses do not imply equal running times, allocations or physical layouts. If the API also promises a resource bound, a replacement must meet that bound too.
Replace the compact array in the bounded queue with encapsulation by a circular buffer with storage , front index and count . Its representation invariant is , , and . Its abstraction function reads the occupied slots using modular arithmetic:On successful
enqueue(x), write and increment . On successful dequeue(), return , replace by and decrement . Full and empty failures do not alter storage. peek and size have the same abstract meanings as before. Keeping a count distinguishes a full circular buffer from an empty one even when both would have the same next insertion index.For , start empty, enqueue , dequeue twice, enqueue , try to enqueue , then
peek and size. Both implementations return from the removals, report full for , and finish with front , size three and abstract sequence . The compact array stores from index zero; the circular buffer stores with . Their abstraction functions explain why different stored entries describe the same ordered content.Under constant-cost slot access and index arithmetic, with no resizing and labels that fit in one slot, the compact array does slot moves on a successful removal: worst-case time complexity as capacity varies. The circular buffer does no slot moves and uses worst-case time complexity for all four operations. Both allocate slots initially; that construction cost is separate. These are operation-count claims in Big O notation, not measured timings. The short correctness outline checks that each implementation's abstraction function produces the specified new sequence and return value after every successful or rejected call. Repeating that check gives equal traces for clients using only this API.
Richardson extrapolation 2026-10-14
Richardson extrapolation improves an approximation by combining two resolutions so that their leading truncation errors cancel. The useful surprise is that the size of that leading error need not be known: its scaling under refinement is enough. This lets an existing finite difference method or quadrature rule produce a more accurate answer from two runs, without first deriving a new method from scratch.
Suppose approximates a fixed limit as the positive resolution parameter tends to zero, with an asymptotic expansionHere is known, is independent of , and denotes Big O notation. The same asymptotic expansion, with the same , must describe both and . Nested grids make it natural to reuse samples, although nesting itself does not establish this error model. Define the linear combinationThe weights sum to one, preserving , while . Thus Richardson extrapolation gives : the next available term in the asymptotic expansion determines the improved order. Justin Solomon's numerical analysis text develops this cancellation for finite differences and applies it to numerical integration.[ref]
https://people.csail.mit.edu/jsolomon/share/book/numerical_book.pdf. Justin Solomon, Numerical Algorithms, §14.3.3 and Exercise 14.9
Geometrically, regard the approximation as a function of . Its first two terms are a straight line . The two computed points lie at positive ; extending the line through them to gives . This is why the operation is extrapolation: it estimates a value outside the sampled parameter interval. The remaining curvature corresponds to the uncancelled terms of the asymptotic expansion.
Worked example: a centered derivative of sine. For the smooth function , the exact derivative at is . The centered difference quotient, a central finite difference, isThe Taylor series of sine gives the signed truncation errorThus , and . Halving divides the leading truncation error by four. Combining the two centered difference quotients with Richardson extrapolation givesIndeed, the coefficient becomes ; the coefficient vanishes. This is the even-power case of Richardson extrapolation discussed in Persson's authored lecture notes.[ref]
https://persson.berkeley.edu/math128a/lecture_notes/math128a_lecture_notes_chapter_4.html. Per-Olof Persson, Math 128A, Chapter 4, §§4.1–4.2
For and , the actual computations areThe absolute error drops from about for to for , an improvement by roughly a factor of 498. Refining again gives , whose absolute error is about . The refined truncation errors decrease by nearly four for and nearly sixteen for , reflecting their second and fourth orders.
Centered sine derivative errors: second order before Richardson extrapolation and fourth order after cancellation
. Source. Details. The logarithmic scale on each axis turns power laws into straight lines. The dashed reference curves are and , the magnitudes of the leading truncation errors. The plotted errors are computed with 70-digit decimal arithmetic, rather than clipped to a display floor; this isolates the asymptotic expansion from roundoff error.
Worked example: integrating an exponential. Approximate the definite integral of the exponential function on :For numerical integration, the composite trapezoidal rule adds the areas of trapezoids between successive samples; this is the quadrature use of the endpoint average that also occurs in the ODE trapezoidal rule. On equal intervals, with , defineSumming the geometric series gives . Expanding the exponential function near zero yieldsThe leading truncation error again has , . On the uniform nested grids with and intervals, Richardson extrapolation therefore givesThis linear combination is exactly composite Simpson's rule on the finer grid, whose spacing is . On each coarse panel, an old endpoint receives weight and the new midpoint weight ; shared old endpoints receive weight . These are the usual Simpson's rule weights multiplied by . The equivalence is explained directly in LeMesurier's university notes.[ref]
https://lemesurierb.people.charleston.edu/elementary-numerical-analysis-python/notebooks/definite-integrals-3-simpson-richardson.html. Brenton LeMesurier, MATH 375, §19.1: The Basic Simpson's Rule by Richardson Extrapolation
For two coarse panels and four fine panels,The absolute errors are about , and , respectively. Reusing the fine-grid samples makes Richardson extrapolation especially attractive here: the resulting Simpson's rule needs no samples beyond those already used by .
Exponential quadrature on nested grids: trapezoidal areas, reused sample nodes, and the fourth-order Simpson combination
. Source. Details. When the improvement is justified. Richardson extrapolation requires the stated asymptotic expansion and the correct positive . If the actual leading exponent is , its coefficient after combination is , so the leading truncation error generally remains. Merely knowing does not supply a common coefficient or a higher-order remainder. A discontinuity of a function, a singular endpoint, or unrelated changes between grids can invalidate the assumed asymptotic expansion; refinement alone does not guarantee improvement for every numerical problem.
Roundoff error and errors in the sampled values survive the cancellation of truncation error. If the coarse and fine values have absolute perturbations bounded by , the perturbation in is bounded by ; for this is . In floating-point arithmetic, a centered difference quotient can also amplify sample errors through division by , so an indefinitely smaller need not be more accurate. Persson's notes describe this balance between truncation error and roundoff error.[ref]
https://persson.berkeley.edu/math128a/lecture_notes/math128a_lecture_notes_chapter_4.html. Per-Olof Persson, Math 128A, Chapter 4, §4.1: Roundoff Error Instability
The same cancellation idea appears in step-doubling error estimation. For an order- one-step method for an ordinary differential equation, two half steps each contribute local truncation error of order , so their accumulated leading local error has ratio to one full step. This explains the denominator there; the appropriate exponent follows from that local error model, rather than automatically from a generic use of Richardson extrapolation.



