gives the Möbius function .


  • MoebiusMu is also known as Möbius function.
  • Integer mathematical function, suitable for both symbolic and numerical manipulation.
  • MoebiusMu[n] gives the sum of the primitive roots of unity.
  • For a number n=u p1k1 pmkm with u a unit and pi primes, MoebiusMu[n]returns 0 unless all ki are equal to 1, in which case it gives (-1)m.
  • MoebiusMu[m+In] automatically works over Gaussian integers.


open allclose all

Basic Examples  (2)

Compute the Möbius function at 11:

Plot the MoebiusMu sequence for the first 20 numbers:

Scope  (10)

Numerical Manipulation  (4)

MoebiusMu works over integers:

Gaussian integers:

Compute for large integers:

MoebiusMu threads over lists:

Symbolic Manipulation  (6)

TraditionalForm formatting:

Reduce expressions:

Solve equations:

Use MoebiusMu in a sum:

In a product:

Identify the MoebiusMu sequence:

DirichletTransform of MoebiusMu:


Applications  (11)

Basic Applications  (2)

Highlight numbers n for which in blue, numbers n for which in red and numbers n for which in black:

Histogram of the cumulative values of MoebiusMu:

The underlying distribution from the data:

Number Theory  (9)

Use MoebiusMu to test for a square-free number:

Use MoebiusMu to compute the number of terms in the Farey sequence:

Compare with the following:

Use MoebiusMu to compute MangoldtLambda:




gives 1 when and 0 when :

MoebiusMu is related to DivisorSigma through the Möbius inversion formulas:

MoebiusMu is related to PrimeNu through the following formula:

MoebiusMu satisfies the following identities:

Compute the number of polynomials over that are irreducible of degree n:

Irreducible polynomials modulo 5:

Distribution of irreducible polynomials modulo 5:

Logarithmic plot of the count for :

Plot the Mertens function [more info]:

Plot :

Properties & Relations  (7)

MoebiusMu is a multiplicative function:

is 1 if n is a product of an even number of distinct primes:

is if it is a product of an odd number of primes:

is 0 if it has a multiple prime factor:

MoebiusMu is 0 for composite prime powers and for primes:

MoebiusMu is 0 for non-square-free integers:

Use PrimeNu to compute MoebiusMu for square-free numbers:

MoebiusMu is equal to the sum of the primitive roots of unity:

Compare with the following:

MoebiusMu can be expressed in terms of LiouvilleLambda and KroneckerDelta:

Neat Examples  (4)

Plot MoebiusMu for the sum of two squares:

Plot the arguments of the Fourier transform of MoebiusMu:

Plot the Ulam spiral of MoebiusMu:

Plot the values of that have :

Wolfram Research (1988), MoebiusMu, Wolfram Language function,


Wolfram Research (1988), MoebiusMu, Wolfram Language function,


@misc{reference.wolfram_2020_moebiusmu, author="Wolfram Research", title="{MoebiusMu}", year="1988", howpublished="\url{}", note=[Accessed: 23-January-2021 ]}


@online{reference.wolfram_2020_moebiusmu, organization={Wolfram Research}, title={MoebiusMu}, year={1988}, url={}, note=[Accessed: 23-January-2021 ]}


Wolfram Language. 1988. "MoebiusMu." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (1988). MoebiusMu. Wolfram Language & System Documentation Center. Retrieved from