Skip to content

MoebiusMu ​

The Möbius function: 0 if n has a squared prime factor, else (-1)^(number of prime factors).

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaMöbius functionMathWorldMoebiusFunctionWikidataQ205243Encyclopedia of MathematicsMöbius_functionDLMF27.2.E12FungrimMoebiusMuOEISA008683Wolfram LanguageMoebiusMu!
MoebiusMu(n)the Möbius function μ(n)\mu(n).
SageMathmoebius(n)✓SymPymobius(n)Oscarmoebius_mu(n)Juliamoebius_mu(n)
Typed signatures
TypePackageApplies
(integer) -> integercompute-enginealways
(number | quadratic_integer, any*) -> integernumber-theoryreplaces compute-enginealways

Domain: Number theory

Details
  • μ(n)=0\mu(n)=0 if nn has a squared prime factor; otherwise μ(n)=(−1)ω(n)\mu(n)=(-1)^{\omega(n)} for ω(n)\omega(n) distinct prime factors.
  • μ(1)=1\mu(1)=1 by convention, the empty product.
  • Underlies Möbius inversion: ∑d∣nμ(d)=0\sum_{d\mid n}\mu(d)=0 for every n>1n>1.
  • nn is squarefree exactly when μ(n)≠0\mu(n)\neq0. See IsSquareFree.
  • μ\mu is only defined on positive integers; compute-engine leaves n≤0n\le0 unevaluated.

Examples

1 more kept as data, checked against the oracles
Basic #
live ↗
InMoebiusMu(1)\mathrm{MoebiusMu}(1)Out11
live ↗
InMoebiusMu(11)\mathrm{MoebiusMu}(11)Out−1-1

12 = 2² · 3 is not squarefree

live ↗
InMoebiusMu(12)\mathrm{MoebiusMu}(12)Out00

10 = 2·5, a product of an even number of distinct primes

live ↗
InMoebiusMu(10)\mathrm{MoebiusMu}(10)Out11
Scope #

Threads element-wise over a list, as Wolfram's Listable heads do

live ↗
InMoebiusMu([1,2,3,4])\mathrm{MoebiusMu}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack)Out[1,−1,−1,0]\bigl\lbrack1, -1, -1, 0\bigr\rbrack

Gaussian integers: 5+6i5+6i is a Gaussian prime (norm 61)

live ↗
InMoebiusMu(5+6i)\mathrm{MoebiusMu}(5+6i)Out−1-1

Listable: threads over a list

live ↗
InMoebiusMu([4,10,17,20])\mathrm{MoebiusMu}(\bigl\lbrack4, 10, 17, 20\bigr\rbrack)Out[0,1,−1,0]\bigl\lbrack0, 1, -1, 0\bigr\rbrack

Listable over a Range

live ↗
InMoebiusMu(1..20)\mathrm{MoebiusMu}(1..20)Out[1,−1,−1,0,−1,1,−1,0,0,1,−1,0,−1,1,1,0,−1,0,−1,0]\bigl\lbrack1, -1, -1, 0, -1, 1, -1, 0, 0, 1, -1, 0, -1, 1, 1, 0, -1, 0, -1, 0\bigr\rbrack
Applications #

15=3⋅515=3\cdot5 is squarefree, so μ≠0\mu\ne0

live ↗
InMoebiusMu(15)≠0\mathrm{MoebiusMu}(15)≠0OutTrue\mathrm{True}

∑d∣nμ(d)=1\sum_{d\mid n}\mu(d)=1 only when n=1n=1

live ↗
InDivisorSum(1,_1⁡↦MoebiusMu(_1⁡))\mathrm{DivisorSum}(1, \operatorname{\_1}↦\mathrm{MoebiusMu}(\operatorname{\_1}))Out11
Properties #

∑d∣nμ(d)=0\sum_{d\mid n}\mu(d)=0 for n>1n>1, the identity behind Möbius inversion

live ↗
InMoebiusMu(1)+MoebiusMu(2)+MoebiusMu(3)+MoebiusMu(4)+MoebiusMu(6)+MoebiusMu(12)\mathrm{MoebiusMu}(1)+\mathrm{MoebiusMu}(2)+\mathrm{MoebiusMu}(3)+\mathrm{MoebiusMu}(4)+\mathrm{MoebiusMu}(6)+\mathrm{MoebiusMu}(12)Out00

Multiplicative over coprime factors, 253=11⋅23253=11\cdot23

live ↗
InMoebiusMu(253)=MoebiusMu(11)MoebiusMu(23)\mathrm{MoebiusMu}(253)=\mathrm{MoebiusMu}(11)\mathrm{MoebiusMu}(23)OutTrue\mathrm{True}

Squarefree with an even number of primes gives 11

live ↗
InMoebiusMu(5 187)\mathrm{MoebiusMu}(5\,187)Out11

Squarefree with an odd number of primes gives −1-1

live ↗
InMoebiusMu(32 538)\mathrm{MoebiusMu}(32\,538)Out−1-1

Divisible by a square (1440=25⋅32⋅51440=2^5\cdot3^2\cdot5), so 00

live ↗
InMoebiusMu(1 440)\mathrm{MoebiusMu}(1\,440)Out00

A composite prime power has μ=0\mu=0

live ↗
In[IsPrimePower(121)∧IsComposite(121),MoebiusMu(121)]\bigl\lbrack\mathrm{IsPrimePower}(121)∧\mathrm{IsComposite}(121), \mathrm{MoebiusMu}(121)\bigr\rbrackOut[True,0]\bigl\lbrack\mathrm{True}, 0\bigr\rbrack

Every prime has μ=−1\mu=-1

live ↗
In[IsPrime(11),MoebiusMu(11)]\bigl\lbrack\mathrm{IsPrime}(11), \mathrm{MoebiusMu}(11)\bigr\rbrackOut[True,−1]\bigl\lbrack\mathrm{True}, -1\bigr\rbrack

A single prime gives −1-1

live ↗
InMoebiusMu(2)\mathrm{MoebiusMu}(2)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

Another prime, again −1-1

live ↗
InMoebiusMu(3)\mathrm{MoebiusMu}(3)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

4=224=2^2 is not squarefree

live ↗
InMoebiusMu(4)\mathrm{MoebiusMu}(4)Out00

Known value · Wolfram MathematicalFunctionData, MoebiusMu

Prime, so −1-1

live ↗
InMoebiusMu(5)\mathrm{MoebiusMu}(5)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

Two distinct primes give +1+1

live ↗
InMoebiusMu(6)\mathrm{MoebiusMu}(6)Out11

Known value · Wolfram MathematicalFunctionData, MoebiusMu

One prime factor, an odd count: μ(7)=−1\mu(7) = -1

live ↗
InMoebiusMu(7)\mathrm{MoebiusMu}(7)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

A cube contains a square factor, so 00

live ↗
InMoebiusMu(8)\mathrm{MoebiusMu}(8)Out00

Known value · Wolfram MathematicalFunctionData, MoebiusMu

9=329=3^2 gives 00

live ↗
InMoebiusMu(9)\mathrm{MoebiusMu}(9)Out00

Known value · Wolfram MathematicalFunctionData, MoebiusMu

μ(p)=−1\mu(p) = -1 for every prime pp

live ↗
InMoebiusMu(13)\mathrm{MoebiusMu}(13)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

14=2⋅714=2\cdot7, an even number of primes

live ↗
InMoebiusMu(14)\mathrm{MoebiusMu}(14)Out11

Known value · Wolfram MathematicalFunctionData, MoebiusMu

15=3⋅515=3\cdot5 gives +1+1

live ↗
InMoebiusMu(15)\mathrm{MoebiusMu}(15)Out11

Known value · Wolfram MathematicalFunctionData, MoebiusMu

242^4 is not squarefree

live ↗
InMoebiusMu(16)\mathrm{MoebiusMu}(16)Out00

Known value · Wolfram MathematicalFunctionData, MoebiusMu

17 is prime, so its Möbius value is −1-1

live ↗
InMoebiusMu(17)\mathrm{MoebiusMu}(17)Out−1-1

Known value · Wolfram MathematicalFunctionData, MoebiusMu

Possible issues #

μ\mu is only defined for positive integers; compute-engine leaves n=0n=0 unevaluated

live ↗
InMoebiusMu(0)\mathrm{MoebiusMu}(0)OutMoebiusMu(0)\mathrm{MoebiusMu}(0)
About
Examples32
Checked againstWolfram Language 30 agree2 differSageMath 27 agree1 unevaluatedSymPy 26 agree2 errormathlib4 22 agree1 unevaluated5 errorOscar 5 agree1 differ4 errorJulia 26 agree2 error
CrosswalkWikipediaMathWorldWikidataEncyclopedia of MathematicsDLMFFungrimOEISWolfram LanguageSageMathSymPyOscarJulia

Implementation

mappedwolframpackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedoscarpackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedmathlib4packages/oracle/src/mappings.ts

See also: FactorInteger, IsSquareFree