{
  "id": "mobius-function",
  "title": "Möbius Function",
  "lang": "en",
  "source_lang": "en",
  "summary": "The Möbius function is an arithmetic function encoding squarefreeness and the parity of prime factors, central to divisor-sum inversion and the study of prime numbers.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "Moebius function",
    "Möbius mu function"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/mobius-function/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/mobius-function/",
      "json": "https://aiwiki.page/zh/mobius-function.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The Möbius function, denoted by \\(\\mu(n)\\), is a function on the positive integers taking values in \\(\\{-1,0,1\\}\\). It is zero when \\(n\\) is divisible by the square of a prime; otherwise, it records whether \\(n\\) has an even or odd number of distinct prime factors. Introduced by August Ferdinand Möbius in 1832, it is a fundamental tool in number theory, especially for reversing sums over divisors, expressing counting formulas, and studying cancellation in arithmetic sequences."
    },
    {
      "heading": "Definition and basic values",
      "text": "For a positive integer \\(n\\), the Möbius function is defined by\n\n\\[\\mu(n)= \\begin{cases} 1,&n=1,\\\\ (-1)^r,&n\\text{ is a product of }r\\text{ distinct primes},\\\\ 0,&p^2\\mid n\\text{ for some prime }p. \\end{cases}\\]\n\nAn integer not divisible by the square of any prime is called a squarefree integer. Thus, \\(\\mu(n)\\) vanishes exactly on the non-squarefree positive integers.\n\nThe first twelve values are:\n\n\\[\\begin{array}{c|rrrrrrrrrrrr} n&1&2&3&4&5&6&7&8&9&10&11&12\\\\ \\hline \\mu(n)&1&-1&-1&0&-1&1&-1&0&0&1&-1&0 \\end{array}\\]\n\nFor example,\n\n\\[\\mu(30)=(-1)^3=-1,\\qquad \\mu(210)=(-1)^4=1,\\]\n\nwhereas \\(\\mu(18)=0\\), because \\(3^2\\mid18\\).\n\nThe definition is unambiguous by the fundamental theorem of arithmetic, which guarantees unique prime factorization. The value \\(\\mu(1)=1\\) agrees with viewing \\(1\\) as a product of no primes."
    },
    {
      "heading": "Multiplicativity and the divisor identity",
      "text": "The Möbius function is a multiplicative function: if \\(a\\) and \\(b\\) have greatest common divisor \\(1\\), then\n\n\\[\\mu(ab)=\\mu(a)\\mu(b).\\]\n\nIt is not completely multiplicative, because this equality need not hold without the coprimality condition. For a prime \\(p\\),\n\n\\[\\mu(p^2)=0\\ne\\mu(p)^2=1.\\]\n\nIts central divisor identity is\n\n\\[\\sum_{d\\mid n}\\mu(d)= \\begin{cases} 1,&n=1,\\\\ 0,&n>1. \\end{cases}\\]\n\nTo see why, suppose \\(n>1\\) has \\(r\\) distinct prime divisors. Only its squarefree divisors contribute to the sum. Each such divisor corresponds to a selection of those primes, so the binomial theorem gives\n\n\\[\\sum_{d\\mid n}\\mu(d) =\\sum_{j=0}^{r}\\binom{r}{j}(-1)^j =(1-1)^r=0.\\]\n\nThis alternating cancellation is an arithmetic form of the inclusion–exclusion principle."
    },
    {
      "heading": "Möbius inversion",
      "text": "The principal application of the function is Möbius inversion. If functions \\(f\\) and \\(g\\) on the positive integers satisfy\n\n\\[g(n)=\\sum_{d\\mid n}f(d),\\]\n\nthen\n\n\\[f(n)=\\sum_{d\\mid n}\\mu(d)\\,g(n/d) =\\sum_{d\\mid n}\\mu(n/d)\\,g(d).\\]\n\nThus, knowing the sum of \\(f\\) over the divisors of every integer determines \\(f\\) itself.\n\nFor complex-valued functions, the formula follows by substituting the expression for \\(g\\):\n\n\\[\\begin{aligned} \\sum_{d\\mid n}\\mu(d)g(n/d) &=\\sum_{d\\mid n}\\mu(d)\\sum_{e\\mid n/d}f(e)\\\\ &=\\sum_{e\\mid n}f(e)\\sum_{d\\mid n/e}\\mu(d). \\end{aligned}\\]\n\nThe inner sum is zero unless \\(e=n\\), when it equals \\(1\\), leaving \\(f(n)\\).\n\nDirichlet convolution\n\nThis relationship has an algebraic formulation using Dirichlet convolution, defined by\n\n\\[(f*g)(n)=\\sum_{d\\mid n}f(d)g(n/d).\\]\n\nLet \\(\\mathbf{1}(n)=1\\) for every positive integer, and let\n\n\\[\\varepsilon(n)= \\begin{cases} 1,&n=1,\\\\ 0,&n>1. \\end{cases}\\]\n\nThe function \\(\\varepsilon\\) is the identity for Dirichlet convolution, and the divisor identity says\n\n\\[\\mu*\\mathbf{1}=\\varepsilon.\\]\n\nConsequently, \\(\\mu\\) is the convolution inverse of the constant-one function. Möbius inversion is then the implication\n\n\\[g=\\mathbf{1}*f \\quad\\Longrightarrow\\quad f=\\mu*g.\\]"
    },
    {
      "heading": "Counting applications",
      "text": "Euler’s totient function\n\nEuler’s totient function \\(\\varphi(n)\\) counts the integers from \\(1\\) to \\(n\\) that are coprime to \\(n\\). It satisfies\n\n\\[\\sum_{d\\mid n}\\varphi(d)=n.\\]\n\nMöbius inversion therefore yields\n\n\\[\\varphi(n) =\\sum_{d\\mid n}\\mu(d)\\frac{n}{d} =n\\prod_{p\\mid n}\\left(1-\\frac1p\\right),\\]\n\nwhere the product runs over the distinct prime divisors of \\(n\\).\n\nMore generally, the coprimality indicator can be written as\n\n\\[\\mathbf{1}_{\\gcd(a,b)=1} =\\sum_{\\substack{d\\mid a\\\\d\\mid b}}\\mu(d).\\]\n\nSumming this identity over \\(1\\le a,b\\le N\\) gives the exact count\n\n\\[\\#\\{(a,b):1\\le a,b\\le N,\\ \\gcd(a,b)=1\\} =\\sum_{d\\le N}\\mu(d) \\left\\lfloor\\frac Nd\\right\\rfloor^2.\\]\n\nSquarefree integers\n\nBecause \\(\\mu(n)^2\\) is \\(1\\) precisely when \\(n\\) is squarefree,\n\n\\[\\mu(n)^2=\\sum_{d^2\\mid n}\\mu(d).\\]\n\nHence the number of squarefree positive integers at most \\(x\\) is\n\n\\[Q(x)=\\sum_{n\\le x}\\mu(n)^2 =\\sum_{d\\le\\sqrt{x}}\\mu(d) \\left\\lfloor\\frac{x}{d^2}\\right\\rfloor.\\]\n\nThis gives\n\n\\[Q(x)=\\frac{6}{\\pi^2}x+O(\\sqrt{x}),\\]\n\nwith the error expressed in big-O notation. In particular, the natural density of squarefree integers is \\(6/\\pi^2\\).\n\nPrimitive words and periodic objects\n\nIn combinatorics, Möbius inversion separates objects with an exact period from objects whose period merely divides a given integer.\n\nFor an alphabet with \\(q\\) symbols, let \\(P_q(n)\\) count length-\\(n\\) words that are not repetitions of a shorter word. Every word has a unique shortest repeating block, so\n\n\\[q^n=\\sum_{d\\mid n}P_q(d).\\]\n\nTherefore,\n\n\\[P_q(n)=\\sum_{d\\mid n}\\mu(d)q^{n/d}.\\]\n\nSince each primitive word has \\(n\\) distinct cyclic rotations, \\(P_q(n)/n\\) counts primitive necklaces of length \\(n\\)."
    },
    {
      "heading": "Dirichlet series and the Riemann zeta function",
      "text": "The Möbius function is closely connected with the Riemann zeta function. For a complex number \\(s\\) with \\(\\operatorname{Re}(s)>1\\),\n\n\\[\\sum_{n=1}^{\\infty}\\frac{\\mu(n)}{n^s} =\\prod_p\\left(1-\\frac1{p^s}\\right) =\\frac1{\\zeta(s)}.\\]\n\nThe series and product converge absolutely in this region. In expanding the product, each prime can be chosen at most once, producing exactly the squarefree terms with their alternating signs.\n\nSimilarly,\n\n\\[\\sum_{n=1}^{\\infty}\\frac{\\mu(n)^2}{n^s} =\\prod_p\\left(1+\\frac1{p^s}\\right) =\\frac{\\zeta(s)}{\\zeta(2s)}, \\qquad \\operatorname{Re}(s)>1.\\]\n\nThese identities connect prime factorization with complex analysis. The first identity cannot simply be interpreted as an ordinarily convergent series throughout every region where \\(1/\\zeta(s)\\) has an analytic continuation; convergence requires separate justification."
    },
    {
      "heading": "The Mertens function and cancellation",
      "text": "The summatory Möbius function is called the Mertens function:\n\n\\[M(x)=\\sum_{n\\le x}\\mu(n).\\]\n\nIt measures the imbalance between squarefree integers with an even number of prime factors and those with an odd number. Its size is a central problem in analytic number theory.\n\nThe prime number theorem is equivalent to\n\n\\[M(x)=o(x),\\]\n\nmeaning that \\(M(x)/x\\to0\\). Thus, although the individual values of \\(\\mu(n)\\) are irregular, their average tends to zero.\n\nA stronger statement is equivalent to the Riemann hypothesis:\n\n\\[\\text{for every }\\epsilon>0,\\qquad M(x)=O_\\epsilon\\!\\left(x^{1/2+\\epsilon}\\right).\\]\n\nThe former Mertens conjecture asserted\n\n\\[|M(x)|<\\sqrt{x}\\qquad(x>1).\\]\n\nIt was disproved by Andrew Odlyzko and Herman te Riele in 1985. Its failure does not disprove the Riemann hypothesis: the conjectured bound was stronger than the estimate above.\n\nRandom-sign models can suggest possible cancellation behavior, but the values of \\(\\mu(n)\\) are deterministic and constrained by multiplicativity. Such models do not establish the required estimates."
    },
    {
      "heading": "Computation",
      "text": "For a single integer whose prime factorization is known, computing \\(\\mu(n)\\) is immediate: a repeated prime factor gives zero; otherwise, the parity of the number of prime factors determines the sign. For large integers without a known factorization, determining the necessary factor information can be computationally difficult.\n\nTo compute all values up to \\(N\\), sieve methods are more efficient than factoring each integer separately. A simple sieve starts each value at \\(1\\), changes the sign for every distinct prime divisor, and sets the value to zero for multiples of prime squares.\n\nA linear sieve uses the rules\n\n\\[\\mu(np)= \\begin{cases} 0,&p\\mid n,\\\\ -\\mu(n),&p\\nmid n, \\end{cases}\\]\n\nfor prime \\(p\\), together with \\(\\mu(1)=1\\). By arranging for each composite integer to be processed once, it computes the table in \\(O(N)\\) arithmetic operations using \\(O(N)\\) storage."
    },
    {
      "heading": "Generalization to partially ordered sets",
      "text": "The arithmetic Möbius function is a special case of the Möbius function of a locally finite partially ordered set, in which every interval \\([x,y]\\) is finite. This generalized function is defined recursively by\n\n\\[\\mu_P(x,x)=1,\\qquad \\mu_P(x,y)=-\\sum_{x\\le z<y}\\mu_P(x,z) \\quad(x<y).\\]\n\nWhen the positive integers are ordered by divisibility,\n\n\\[\\mu_P(a,b)=\\mu(b/a)\\qquad(a\\mid b).\\]\n\nFor subsets ordered by inclusion,\n\n\\[\\mu_P(A,B)=(-1)^{|B\\setminus A|} \\qquad(A\\subseteq B).\\]\n\nIn this setting, Möbius inversion becomes ordinary inclusion–exclusion. The partially ordered set formulation places divisor inversion and many combinatorial inversion formulas within a common algebraic framework."
    }
  ],
  "links": [
    "integer",
    "number-theory",
    "prime-number",
    "fundamental-theorem-of-arithmetic",
    "greatest-common-divisor",
    "binomial-theorem",
    "inclusion-exclusion-principle",
    "eulers-totient-function",
    "big-o-notation",
    "combinatorics",
    "riemann-zeta-function",
    "complex-number",
    "complex-analysis",
    "analytic-continuation",
    "prime-number-theorem",
    "riemann-hypothesis",
    "partial-order"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}