Intuition, Vocabulary and Foundations
Arithmetic functions attach information to each positive integer. If $n=12=2^2\cdot3$, then $\varphi(12)=4$ counts residues coprime to $12$, $\mu(12)=0$ records that a square divides $12$, $\tau(12)=6$ counts its divisors, and $\sigma(12)=28$ sums them. Think of the divisors as a dependency network: a value stored at $d$ can contribute to every multiple of $d$.
For $n=\prod_i p_i^{e_i}$, unique factorization gives
$$ \varphi(n)=n\prod_{p\mid n}\left(1-\frac1p\right),\qquad \tau(n)=\prod_i(e_i+1),\qquad \sigma(n)=\prod_i\frac{p_i^{e_i+1}-1}{p_i-1}. $$
The Möbius function is $\mu(1)=1$; it is $0$ when some $p^2$ divides $n$; otherwise it is $(-1)^k$ when $n$ is a product of $k$ distinct primes. An arithmetic function $f$ is multiplicative when $f(ab)=f(a)f(b)$ for $\gcd(a,b)=1$—not necessarily for arbitrary $a,b$. Dirichlet convolution combines functions by
$$ (f*g)(n)=\sum_{d\mid n}f(d)g(n/d). $$
Its identity is $\varepsilon(1)=1$ and $\varepsilon(n)=0$ for $n>1$. With $\mathbf 1(n)=1$, the defining inverse relation is $\mu*\mathbf 1=\varepsilon$. Therefore, if $F(n)=\sum_{d\mid n}f(d)$, then Möbius inversion recovers $f(n)=\sum_{d\mid n}\mu(d)F(n/d)$.
Treat divisor sums as a reversible transform on the divisor lattice: convolution with $\mathbf 1$ accumulates information upward to multiples, and convolution with $\mu$ removes exactly that accumulated contribution. Multiplicative prime-power formulas apply only after checking coprimality or using a valid factorization.
| Concept | Definition or notation | Example | Non-example or boundary | Question answered |
|---|---|---|---|---|
| Euler totient | $\varphi(n)$ counts $1\le k\le n$ with $\gcd(k,n)=1$ | $\varphi(12)=4$ | $\varphi(1)=1$, not $0$ | How many invertible residue classes exist? |
| Möbius function | $\mu(n)$ detects square-free prime parity | $\mu(30)=-1$ | $\mu(12)=0$ because $4\mid12$ | Can a divisor sum be inverted? |
| Divisor count | $\tau(n)=\sum_{d\mid n}1$ | $\tau(12)=6$ | $\tau(1)=1$ | How many positive divisors exist? |
| Divisor sum | $\sigma(n)=\sum_{d\mid n}d$ | $\sigma(12)=28$ | Proper-divisor sum is $\sigma(n)-n$ | What is the total divisor weight? |
| Multiplicativity | $f(ab)=f(a)f(b)$ when $\gcd(a,b)=1$ | $\tau(12)=\tau(4)\tau(3)$ | $\tau(8)\ne\tau(4)\tau(2)$ | Can prime-power results be combined? |
| Dirichlet convolution | $(f*g)(n)=\sum_{d\mid n}f(d)g(n/d)$ | $\mathbf1*\mathbf1=\tau$ | It is not pointwise multiplication | How do divisor-indexed contributions compose? |
| Summatory function | $S_f(x)=\sum_{n\le x}f(n)$ | $\sum_{n\le5}\varphi(n)=10$ | It is not the point value $f(x)$ | What is the aggregate through a bound? |
Step-by-Step Derivations and Algorithms
A linear sieve evaluates several multiplicative functions while assigning every composite through its smallest prime factor. When processing $i$ and a prime $p$, form $x=ip$. If $p\mid i$, then $p$ extends an existing prime power: $\mu(x)=0$, $\varphi(x)=p\varphi(i)$, and the divisor formulas update the exponent of $p$. The loop then stops, ensuring that $x$ is generated once. If $p\nmid i$, a new coprime prime factor is introduced: $\mu(x)=-\mu(i)$ and $\varphi(x)=(p-1)\varphi(i)$.
For an array $a$, the divisor zeta transform computes $A(n)=\sum_{d\mid n}a(d)$ by adding $a(d)$ to $A(d),A(2d),A(3d),\ldots$. The number of additions is
$$ \sum_{d=1}^{N}\left\lfloor\frac Nd\right\rfloor=O(N\log N). $$
Möbius inversion reverses the transform with the same traversal pattern. For quotient-dependent sums, values of $\lfloor N/i\rfloor$ are constant on blocks. Starting at $l$, set $q=\lfloor N/l\rfloor$ and $r=\lfloor N/q\rfloor$; every $i\in[l,r]$ has quotient $q$. Replacing $N$ iterations by these blocks yields only $O(\sqrt N)$ distinct ranges.
flowchart TD
A["Prime factorization model"] --> B["Prime-power formulas"]
A --> C["Linear sieve states"]
B --> D["Multiplicative tables"]
C --> D
D --> E["Divisor zeta transform"]
E --> F["Möbius inversion"]
D --> G["Prefix sums"]
G --> H["Harmonic quotient blocks"]
The linear-sieve invariant is that each composite is emitted exactly once, paired with its smallest prime factor; this proves $O(N)$ arithmetic updates and $O(N)$ storage. Dense divisor transforms take $\Theta(N\log N)$ operations, while a loop whose summand depends only on $\lfloor N/i\rfloor$ can be grouped into $\Theta(\sqrt N)$ quotient blocks.
Implementation, Complexity and Engineering
The reference implementation keeps pointwise tables separate from prefix or transformed arrays. It uses integer recurrences rather than floating-point product formulas, explicitly initializes the exceptional value at $1$, and exposes transformations as new arrays so callers cannot silently confuse the input with its divisor sum.
| Method | Time | Space | Numeric concern | Common failure | Mitigation |
|---|---|---|---|---|---|
| Per-value factorization | $O(\sqrt n)$ per query | $O(1)$ | Large intermediate powers | Repeating work over a batch | Use a sieve when the maximum bound is moderate |
| Linear function sieve | $O(N)$ | $O(N)$ | $\sigma(n)$ may exceed fixed-width types | Updating a composite more than once | Stop after extending its smallest prime factor |
| Divisor zeta transform | $O(N\log N)$ | $O(N)$ | Accumulated sums can overflow | Confusing divisor and multiple loops | Test against explicit divisor enumeration |
| Möbius inversion | $O(N\log N)$ for all values | $O(N)$ | Signed cancellation | Using pointwise multiplication | Verify by applying the forward transform again |
| Harmonic grouping | $O(\sqrt N)$ blocks | $O(1)$ excluding output | Products of block width and value | Advancing only one index | Jump to $r=\lfloor N/q\rfloor$ |
| Prefix summation | $O(N)$ build, $O(1)$ range query | $O(N)$ | Prefix totals may be much larger than terms | Treating $S_f(n)$ as $f(n)$ | Use distinct names and types for pointwise and cumulative data |
Applications, Case Studies and Exercises
Möbius inversion turns a condition about a greatest common divisor into divisor counts. Since $[\gcd(x,y)=1]=\sum_{d\mid\gcd(x,y)}\mu(d)$, the number of ordered coprime pairs in $[1,N]^2$ is
$$ \sum_{d=1}^{N}\mu(d)\left\lfloor\frac Nd\right\rfloor^2. $$
The same pattern counts coprime $k$-tuples by replacing the square with the $k$th power. In a batch analytics system, a divisor transform can aggregate device measurements by every calibration period that divides a timestamp; Möbius inversion then recovers the exact-period contribution rather than the cumulative contribution.
Apply Arithmetic Functions, Convolution & Möbius Inversion
Case study 1 — coprime grid points. Set $N=5$. Build $\mu(1),\ldots,\mu(5)$, then evaluate $\sum_{d=1}^{5}\mu(d)\lfloor5/d\rfloor^2$. Checkpoint: the contributions are $25,-4,-1,0,-1$, giving $19$. Verify by listing the $25$ ordered pairs and rejecting the six pairs whose gcd exceeds $1$.
Case study 2 — recovering exact subscription periods. Suppose $F(n)$ is the number of services whose period divides day $n$, with $F(1..6)=(2,5,3,7,4,8)$. Compute $f(n)=\sum_{d\mid n}\mu(d)F(n/d)$. Checkpoint: reconstruct each $F(n)$ from $\sum_{d\mid n}f(d)$; success means all six values match exactly.
Hands-on challenge. Implement a reusable table through $N=10^6$ and answer: $\varphi(n)$, $\mu(n)$, $\tau(n)$, $\sigma(n)$, and the number of ordered coprime pairs up to a requested bound. Test $N=1$, primes, prime powers, square-free composites, and values containing a squared prime. Measure build time and peak memory; success requires agreement with a naive factorization oracle for every $n\le1000$.
Tiered exercises. (1) Recall: compute $\mu(18)$, $\tau(72)$, and $\sigma(25)$. (2) Derivation: prove that the convolution of multiplicative functions is multiplicative. (3) Implementation: add prefix sums of $\mu$ and $\varphi$. (4) Debugging: find why failing to stop the inner linear-sieve loop double-processes composites. (5) Extension: use quotient blocks to evaluate a weighted floor sum without visiting every index.
Choose factorization for a few isolated inputs, a linear sieve for dense pointwise tables, divisor transforms for all-divisor aggregation, and harmonic grouping when only floor quotients matter. Never confuse multiplicative with completely multiplicative, or $f(n)$ with its summatory value; these tools lead naturally to faster summatory functions and coprimality-counting techniques.
Next in the Series
In Modular Combinatorics, we'll explore Evaluate combinatorial quantities under prime and composite moduli..