Learn R Programming

pracma (version 1.1.6)

moebiusFun: Moebius Function

Description

The classical Moebius and Mertens functions in number theory.

Usage

moebiusFun(n)
mertensFun(n)

Arguments

n
Positive integer.

Value

  • For moebiusFun, 0, 1 or -1, depending on the prime decomposition of n.

    For mertensFun the values will very slowly grow.

Details

moebiusFun(n) is +1 if n is a square-free positive integer with an even number of prime factors, or +1 if there are an odd of prime factors. It is 0 if n is not square-free.

mertensFun(n) is the aggregating summary function, that sums up all values of moebius from 1 to n.

See Also

factorize, eulersPhi

Examples

Run this code
sapply(1:16, moebiusFun)
sapply(1:16, mertensFun)

x <- 1:50; y <- sapply(x, moebiusFun)
plot(c(1, 50), c(-3, 3), type="n")
grid()
points(1:50, y, pch=18, col="blue")

x <- 1:100; y <- sapply(x, mertensFun)
plot(c(1, 100), c(-5, 3), type="n")
grid()
lines(1:100, y, col="red", type="s")

Run the code above in your browser using DataLab