Bit Complexity and Arithmetic Cost

Track the size of intermediate integers and compare arithmetic operation counts with the cost of actually representing their results.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. An intermediate value needs storage
  2. Bound growth before choosing the cost model

An intermediate value needs storage

An arithmetic-operation count may charge one unit for each multiplication. On binary integers, multiplying two \(b\)-bit inputs by the schoolbook method takes \(O(b^2)\) bit operations. Repeated squaring illustrates the difference sharply. Starting from \(2\), after \(k\) squarings the result is \(2^{2^k}\), whose binary encoding has \(2^k+1\) digits. Merely writing the exact answer already requires exponential space in \(k\).

Bound growth before choosing the cost model

With modular arithmetic modulo a positive \(m\), reducing after multiplication keeps residue sizes bounded by the bit length of \(m\). Modular exponentiation trades a large exact output for a compact residue. In a word-RAM analysis, operations on one machine word can be constant time under a fixed instruction set, while a multiword product needs more work. This same distinction makes an algorithm polynomial in a numeric capacity but pseudopolynomial in its encoded input.[1][2]

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩
  2. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩