Mobius Mobius inversion proof function &

Preface?

~ ~ Finally holiday feeling decadent moment I do not take the opportunity to blog on the waste ......

Quickly write something brush sense of presence ( cheat Points )

Mobius function

 Define a function $ \ mu (d) $, satisfying:

1. If $ d = 1 $, the $ \ mu (d) = 1 $.

2. If $ d = p_1p_2p_3 \ cdots p_k $ and $ $ P_i is mutually different prime numbers, $ \ mu (d) = (- 1) ^ k $.

3. Other cases $ \ mu (d) = 0 $.

Then we will function $ \ mu (d) $ known as Mobius function.

It looks NB?

Plainly, it is for one is $ \ mu (1) = 1 $, several other words if the number d comprise the same quality factor is $ \ mu (d) = 0 $, if the quality factor is different, then if x has odd prime factors $ \ mu (d) = - 1 $, or $ \ mu (d) = 1 $.

 Mobius function has many magical properties ( to know two ):

Properties of a: $ \ SUM \ limits_ {D |} n-\ MU (D) = [n-==. 1] $

prove:

[N == 1] means that if and only returns 1 1 n =, and 0 otherwise.

$ N = 1 $ is clearly established.

\ Neq 1 $ $ n-time, for the first $ \ mu (d) = 0 $ where we can ignore, considering only $ \ mu (d) \ neq 0 $, i.e. $ d = p_1 ^ {c_1} p_2 ^ {c_2} \ cdots p_k ^ {c_k} $, and in the case of $ \ forall i \ in [1, k] \ c_i = 1 $ is.

 Provided $ n = p_1 ^ {c_1} p_2 ^ {c_2} \ cdots p_i ^ {c_i} $, d is the number of prime factors where j is a total of $ C_i ^ j $ species.

According to the definition Möbius then we can get the function \ begin {array} {lcl} \ sum \ limits_ {d | n} \ mu (d) & = & C_i ^ 0-C_i ^ 1 + C_i ^ 2- \ cdots + (- 1) ^ kC_i ^ i \\ & = & \ sum \ limits_ {j = 0} ^ i (-1) ^ jC_i ^ j \ end {array}

It means that we only need to prove $ \ sum \ limits_ {j = 0} ^ i (-1) ^ jC_i ^ j = 0 $ on it.

This thing is a bare binomial theorem binomial theorem does not, then I can refer to one another blog ( started reading the cheat ).

So we are happy to prove out a property.

Two properties: $ \ SUM \ limits_ {D | n-} \ {FRAC \ MU (D)} {D} = \ FRAC {\ Phi (n-) {}} $ n-

Where $ \ phi (n) $ is the Euler function (Möbius inversion should look at would not know it ......).

When this proved that nature speaks Dirichlet convolution below.

Seeking:

Seeking a single number Mobius prime factor decomposition can function directly.

If the function value Mobius find items 1 ~ n, we can calculate by Eratosthenes sieve method.

#include<cstdio>
using namespace std;
int const N=1e5+5;
int miu[N];
bool v[N];
inline void get_miu(int n){
    for(register int i=1;i<=n;++i)
        miu[i]=1;
    for(register int i=2;i<=n;++i){
        if(v[i])continue;
        miu[i]=-1;
        for(register int j=i<<1;j<=n;j+=i){
            v[j]=1;
            if((j/i)%i)miu[j]=-miu[j];
            else miu[j]=0;
        }
    }
    return ;
}
int main(){
    int n;
    scanf("%d",&n);
    get_miu(n);
    return 0;
}
View Code

Screen can also be linear, as long as the basic linear prime number sieve to make minor modifications.

#include<cstdio>
using namespace std;
int const N=1e5+5;
int miu[N],prime[N],tot;
bool v[N];
inline void get_miu(int n){
    miu[1]=1;
    for(register int i=2;i<=n;++i){
        if(!v[i])prime[++tot]=i,miu[i]=-1;
        int zz=-miu[i];
        for(register int j=1;j<=tot;++j){
            int now=prime[j]*i;
            if(now>n)break;
            v[now]=1;
            if(i%prime[j])miu[now]=zz;
            else break;
        }
    }
    return ;
}
int main(){
    int n;
    scanf("%d",&n);
    get_miu(n);
    return 0;
}
View Code

 Dirichlet convolution

Before learning Dirichlet convolution us first understand a thing called arithmetical functions .

We do not have to be familiar with the whole system function of number theory, we only need to know a few common functions to number theory.

If a number theoretic function f for any two positive integers coprime a, b satisfies $ f (a * b) = f (a) * f (b) $, we called the function f multiplicative function.

Note that the function of the product and the product remains multiplicative function multiplicative function.

We see most of arithmetical functions are multiplicative function, the following are some examples:

1. $ \ Phi (n) / \ varphi (n) $ denotes the Euler function of the counted number 1 ~ n with n coprime. $ \ Phi (n) = \ sum \ limits_ {i = 1} ^ n [gcd (n, i) == 1] $

2. $ \ Mu (n) $ Mobius function above should have made it very clear, and not repeat them.

3. $ d (n) $ n represents the number of submultiple number of positive factors $ d (n) = \ sum \ limits_ {d | n} 1 $

. 4 $ \ sigma (n) $ divisors function represents all positive factors and the sum of n $ \ sigma (n) = \ sum \ limits_ {d | n} d $

5. $ \ Epsilon (n) / e (n) $ membership function for Dirichlet convolution multiplication unit $ \ epsilon (n) = [n == 1] $

6. $ 1 (n) $ the identity function constant at 1 $ 1 (n) = 1 $

7. $ Id (n) $ Unit itself is a function of the size of $ Id (n) = n $

If for any function f is a positive integer pair (a, b) are satisfied $ f (a * b) = f (a) * f (b) $, then we have the function f is called a full multiplicative function.

Examples of functions of the area is completely 5,6,7 multiplicative function.

All Dirichlet character (a kind of arithmetical functions, would like to know the degree of your mother asked to go) is completely multiplicative function.

Below, we started to explain the Dirichlet convolution.

 $ * $ Define a calculation, a function f, g satisfies $ (f * g) (n) = \ sum \ limits_ {d | n} f (d) g (\ frac {n} {d}) $, we call this operation $ * $ is called Dirichlet convolution.

Dirichlet convolution commutative, associative law and distributive law.

The above explanation membership function $ \ epsilon (n) when it comes to $ membership function for the Dirichlet convolution multiplication unit, the membership functions may serve as the Dirichlet convolution unit cell, i.e. $ f * \ epsilon = f $ .

For a function f, if $ f (1) \ neq 0 $, there is the function g satisfies $ f * g = 1 $, we called the inverse of f g.

Stealing from a giant god's blog inverse equation:

$g(n)=\frac{1}{f(1)}\left([n==1]-\sum\limits_{d|n,d\neq 1}f(d)g(\frac{n}{d})\right)$

$\sum\limits_{d|n}f(d)g(\frac{n}{1})=f(1)g(n)+\sum\limits_{d|n,d\neq 1}f(d)g(\frac{n}{d})=[n==1]$

Here are several convolution relations:

1.$d=1*1$

2. $ \ Sigma * = d 1 $

3. $ Ids = \ phi * 1 $

4. $ \ Epsilon = \ m * 1 $

5. $ \ Phi = \ mu * $ Id

6. $ 1 = \ mu * d $

prove:

1,2 apparent (directly substituted into the function expression on the line).

3:

\begin{array}{lcl}Id(n) & = & \sum\limits_{i=1}^n\sum\limits_{j=1}^n[gcd(i,n)==j] \\& = & \sum\limits_{j|n}\sum\limits_{i=1}^{\lfloor\frac{n}{j}\rfloor}[gcd(i,\frac{n}{j})==1] \\& = & \sum\limits_{j|n}\phi(\frac{n}{j}) \end{array}

That $ Id = \ phi * 1 $

It is actually a function of the nature of the Euler: $ \ sum \ limits_ {d | n} \ phi (d) = n $

4 is the nature of a Möbius function above has been proven, not repeat them.

5:

I seem to say that the nature of Mobius function Second, we must prove that at the time of speaking Dirichlet convolution?

This is actually a $ 5 \ properties mu (n) $ II.

\begin{array}{cc}Id & = & \phi*1 \\Id*\mu & = & \phi*1*\mu \\Id*\mu & = & \phi*\epsilon \\Id*\mu & = & \phi \\ \sum\limits_{d|n}\mu(d)\frac{n}{d}  & = & \phi(n) \\ \sum\limits_{d|n}\frac{\mu(d)}{d} & = & \frac{\phi(n)}{n} \end{array}

QED.

6.

\begin{array}{cc}d & = & 1*1\\d*\epsilon & = & 1*1\\ d*\mu*1 & = & 1*1\\ d*\mu & = & 1 \end{array}

QED.

Mobius inversion

$f(n)=\sum\limits_{d|n}g(d) \Leftrightarrow g(n)=\sum\limits_{d|n}\mu(d)f(\frac{n}{d})$

Another form: $ f (n) = \ sum \ limits_ {n | d} g (d) \ Leftrightarrow g (n) = \ sum \ limits_ {n | d} \ mu (\ frac {d} {n }) f (d) $

Let's prove the first form.

Known $ f (n) = \ sum \ limits_ {d | n} g (d) $

则\begin{array}{lcl}\sum\limits_{d|n}\mu(d)f(\frac{n}{d}) & = & \sum\limits_{d|n}\mu(d)\sum\limits_{i|\frac{n}{d}}g(i) \\& = & \sum\limits_{d|n}\sum\limits_{i|\frac{n}{d}}\mu(d)g(i) \\& = & \sum\limits_{i|n}\sum\limits_{d|\frac{n}{i}}\mu(d)g(i) \\& = & \sum\limits_{i|n}g(i)\sum\limits_{d|\frac{n}{i}}\mu(d) \\& = & g(n)\end{array}

Proved.

But in fact it may be proved by Dirichlet convolution.

 $ F (n) = \ sum \ limits_ | g (d) $ {d n} may be represented as $ f = g * 1 $

则\begin{array}{lcl}f*\mu & = & g*1*\mu \\& = & g*(1*\mu) \\& = & g*\epsilon \\& = & g \end{array}

We can get into the two forms Mobius inversion of the ......

Guess you like

Origin www.cnblogs.com/remarkable/p/11364178.html