← LibraryAsymptotic Notation and Machine ModelsEngineering · MathematicsLesson 21/32← PrevNext →
ArticlePublished 6 Aug 2026Updated 5 Aug 20268 min readBy Kevin Jogin
KEVOS® Knowledge Library · Engineering → Mathematics

Engineering/Mathematics/Algorithm analysis

Asymptotic Notation and Machine Models

A number-theoretic algorithm's cost is measured in bit operations against an input whose size is its bit length, not its value. Getting that convention right is what separates a polynomial-time algorithm from an exponential one that looks linear.

  • Analysis foundation
  • Complexity
  • Cost model discipline
  • ≈14 min read
  • Applies to every algorithm page
ℓ = ⌈log₂ n⌉Input sizeThe size of an integer input is its bit length. Trial division runs in O(√n) = O(2ℓ/2) — exponential in the input size.
O(ℓ³)Modular exponentiationThe workhorse cost with classical arithmetic: O(ℓ) squarings at O(ℓ2) each.
Ln[⅓, c]SubexponentialBetween polynomial and exponential; the shape of the number field sieve's running time.
ÕSoft-OSuppresses logarithmic factors — standard shorthand when fast multiplication is assumed.

01

Executive summary

Complexity claims in this field are only meaningful relative to two conventions: what counts as one operation, and how input size is measured. For number-theoretic algorithms the answers are bit operations and bit length, and both differ from the defaults assumed in general algorithm courses.

The consequence appears immediately. Trial division to √n looks like a fast algorithm when n is treated as the input size; measured against the length of n, it is exponential. Every security argument in cryptography depends on stating the model correctly.

Two cost models, and when each is appropriate
ModelUnit of costAppropriate whenRisk
Bit complexityone bit operationOperands grow with the input — RSA, factoring, big-integer workVerbose; hides constant-factor engineering
Arithmetic complexityone field or ring operationThe base ring is fixed — finite field algorithms, linear algebraMisleading if the ring elements grow
Word RAMone machine-word operationOperands fit in a word; practical implementation analysisAssumes unit-cost multiplication of O(log n)-bit words

Always state which model a bound refers to. 'O(n³) for modular exponentiation' is meaningless without saying whether n is the modulus or its bit length.

Contents

02

Asymptotic notation

Definition D1

O, Ω, Θ, o, ω

  • f = O(g): there are c, x0 with |f(x)| ≤ c·g(x) for x ≥ x0 — an upper bound.
  • f = Ω(g): g = O(f) — a lower bound.
  • f = Θ(g): both hold — a tight bound.
  • f = o(g): f/g → 0 — strictly smaller order.
  • f = ω(g): f/g → ∞.
  • The equals sign is an abuse of notation. f = O(g) means membership in a set. It is not symmetric, and chains such as O(n) = O(n2) read left to right only.
  • Soft-O. Õ(f) means O(f·(log f)k) for some constant k — a convenient way to state results that assume fast multiplication without tracking log factors.
  • Uniformity matters. When a bound involves two parameters, say the modulus size and the exponent size, state which one the constant is uniform in; hidden dependence on a second parameter is a common source of incorrect claims.
  • Constants are not always negligible. Schönhage–Strassen multiplication is asymptotically superior to Karatsuba but only becomes faster above a few thousand bits. Crossover points are engineering facts that asymptotics deliberately discard.
Contents

03

Input size and the polynomial-time boundary

The single most common error in this field

The input size of an integer n is ℓ = ⌊log2 n⌋ + 1 bits, not n. An algorithm running in time O(n) or O(√n) is exponential in the input size, because n = 2. This is why trial division, the sieve of Eratosthenes and Pollard rho are not polynomial-time factoring algorithms, however fast they are on small inputs.

Operations required at ℓ = 2048 bits (order of magnitude, schematic)
Addition, O(ℓ)≈ 2 × 10³
Multiplication, O(ℓ²)≈ 4 × 10⁶
Modular exponentiation, O(ℓ³)≈ 9 × 10⁹
AKS primality, Õ(ℓ⁶)≈ 10¹⁹
NFS factoring, L[⅓,1.92]≈ 10³⁴
Trial division, O(2^{ℓ/2})≈ 10³⁰⁸
Complexity classes as they appear here
ClassFormExample
LinearO(ℓ)Integer addition and comparison
QuadraticO(ℓ2)Schoolbook multiplication; Euclid's algorithm
CubicO(ℓ3)Modular exponentiation with classical arithmetic
PolynomialO(1)AKS primality proving
SubexponentialLn[α, c], 0 < α < 1Quadratic sieve (α = ½), number field sieve (α = ⅓)
Exponential2Ω(ℓ)Trial division; generic discrete log at O(√q)
Definition D2

L-notation

Ln[α, c] = exp((c + o(1))·(ln n)α·(ln ln n)1−α)α = 0 gives polynomial time in log n; α = 1 gives exponential time; intermediate α interpolates

The parameter α is the one that matters for extrapolating key sizes. Moving from the quadratic sieve to the number field sieve reduced α from ½ to , which is why RSA modulus sizes had to grow substantially in the 1990s.

Contents

04

Machine models

A model must be fixed before any bound is meaningful. Three are in common use, and results transfer between them with known overheads.

01

Turing machine

Sequential tape access. The reference model for complexity theory, but tape movement inflates costs by polynomial factors that are irrelevant in practice.

02

RAM with unit-cost operations

Random access, arithmetic on unbounded integers at unit cost. Convenient but dishonest for big-integer work, since it hides the cost of multiplying large numbers.

03

Word RAM (logarithmic cost)

Random access with O(log n)-bit words and unit-cost word operations. The model that matches real hardware and the one implicitly used in implementation analysis.

Reconciling the models

Number-theoretic results are usually stated in bit complexity, which is model-independent up to constant factors across reasonable machines. Implementation analyses are stated in word operations. The translation is a division by the word size w for linear-time operations, and by w2 for schoolbook multiplication — so a 64-bit machine gains a factor of roughly 4096 on multiplication relative to a bit-serial count.

  • Parallelism and memory hierarchy are outside all three models. The linear algebra stage of a factoring record is bounded by memory bandwidth and interconnect latency, not by operation counts; asymptotic analysis says nothing about it.
  • Randomised models add a source of random bits and admit Las Vegas algorithms (always correct, random running time) and Monte Carlo algorithms (fixed running time, small error probability). Miller–Rabin is Monte Carlo; ECPP-style primality proving is Las Vegas.
  • Quantum models change the picture entirely for this domain: Shor's algorithm factors and computes discrete logarithms in polynomial time, which is why post-quantum schemes rest on different problems altogether.
Contents

05

Stating and using cost models correctly

A checklist for reporting complexity
QuestionWhy it matters
Is the input size the value or its bit length?Determines whether an algorithm is polynomial or exponential
Bit operations, ring operations or word operations?A factor of or 2 hangs on the answer
Classical or fast arithmetic assumed?O(ℓ2) versus Õ(ℓ) multiplication changes every downstream bound
Worst case, average case or expected over internal randomness?Miller–Rabin's 1/4 is worst case over inputs, not average
Is the bound conditional?Several results assume the extended Riemann hypothesis
Are pre-computation costs included?Index calculus amortises an expensive setup over many later logarithms

Worked model statement

A correct statement reads: Modular exponentiation of an -bit base by an -bit exponent modulo an -bit modulus takes O(ℓ3) bit operations using schoolbook multiplication, or Õ(ℓ2) using fast multiplication. Both figures, and the assumption behind each, belong in the statement.

  • Report crossover points alongside asymptotics when recommending an implementation; Karatsuba typically wins above roughly 300–600 bits, and FFT-based methods only above several thousand.
  • Distinguish amortised from per-operation costs: Montgomery multiplication has a setup cost that pays for itself only across many operations with the same modulus.
  • State whether a bound counts modular multiplications or bit operations when comparing exponentiation strategies — sliding-window methods reduce multiplication counts, not the cost of each one.
Contents

06

Quick reference and FAQ

Standard costs on ℓ-bit inputs (classical arithmetic)
OperationBit operationsWith fast multiplication
Addition, subtraction, comparisonO(ℓ)O(ℓ)
MultiplicationO(ℓ2)Õ(ℓ)
Division with remainderO(ℓ2)Õ(ℓ)
gcd, extended gcdO(ℓ2)Õ(ℓ)
Modular exponentiationO(ℓ3)Õ(ℓ2)
Jacobi symbolO(ℓ2)Õ(ℓ)
Miller–Rabin, k roundsO(kℓ3)Õ(kℓ2)
Conversion to decimalO(ℓ2)Õ(ℓ)
Why is the sieve of Eratosthenes not a polynomial-time algorithm?
Its cost is Θ(n log log n) in the value n, which is Θ(2 log ℓ) in the input length. It is an excellent algorithm for its actual task — listing all primes below a bound — but that task has an output of exponential size, so no polynomial bound is possible.
Does the choice of Turing machine versus RAM ever change a conclusion?
Not for the polynomial-versus-not question, which is robust across reasonable sequential models. It changes exponents, so a claim of O(ℓ6) should always name its model.
Why do papers report Õ bounds so often?
Because the logarithmic factors depend on which fast multiplication algorithm is assumed, and those assumptions change over time — the 2019 Harvey–van der Hoeven result achieving O(ℓ log ℓ) multiplication altered several of them. Soft-O keeps the substantive content stable.
How should security levels be derived from these bounds?
By extrapolating the best known attack cost, including its o(1) term, and adding a margin. Published estimates for RSA and discrete-log parameters are the product of careful extrapolation from record computations, not a direct reading of an asymptotic formula.
Contents

08

References and further reading

  • V. Shoup, A Computational Introduction to Number Theory and Algebra, Cambridge University Press, 2005 — §3.1–3.2.
  • T. H. Cormen, C. E. Leiserson, R. L. Rivest and C. Stein, Introduction to Algorithms, 4th ed., MIT Press, 2022 — Chapter 3.
  • D. E. Knuth, The Art of Computer Programming, Vol. 2, 3rd ed., Addison-Wesley, 1997 — §4.3 on classical arithmetic costs.
  • D. Harvey and J. van der Hoeven, 'Integer multiplication in time O(n log n)', Annals of Mathematics 193 (2021) 563–617.

KEVOS® Knowledge LibraryEngineering → MathematicsTaxonomy ID: ENG-MATHPage ID: asymptotic-notation-and-machine-modelsReview cycle: annual


Continue learning

Linearly Generated Sequences and Sparse Linear SystemsArticle · MathematicsNEXT LESSON →Multiprecision Integer ArithmeticArticle · MathematicsDiscrete Probability for Algorithm AnalysisArticle · MathematicsEuclid's Algorithm and Modular ComputationArticle · Mathematics