Introduction
Inversion is a common tool to solve some math problem.
This passage will introduce some trick for solving these problem.
Prerequisites
Multiplicative Functions
A function is multiplicative if, for all with , it satisfies . In particular, if this holds for all , then the function is called completely multiplicative.
Common multiplicative functions:
- Identity function: , complete
- Constant function: , complete
- Equality function: , , complete
- Euler function:
- Mobius function:
- Number of divisors function:
- Sum of divisors function:
Dirichlet Convolution
Below is the formula of Dirichlet convolution:
Dirichlet convolution satisfy below law:
- Commutative law : ;
- Associative law : ;
- Distributive law : ;
- Identity element : .
And below is some important dirichlet convolution:
The proof of these equation isn’t difficult but very important, must try to prove them before reading below part.
Mobius Inversion
The following is the basic form of mobius inversion:
If
then
These relative explain “Inversion” perfectly: using Mobius function to get calculation method from to by the calculation method from to .
And we can using below formula to prove these parttern easily.
Observe the form of the relation from we can using Dirichlet Convolution to express it:
I will explain each step of this proof.
- Dirichelet Convolution’s law: identity element
- Commutative law
- The relative from to :
- Commutative law
Mobius Inversion also have another form, this form is base on multiple.
If
then
This form cannot prove elegantly like before.
We can expand in the formula after inversion
Then swap summation:
Then we define then this equation change to:
As we know, because of the natrue of mobius function:
So that equation just can get result when , so the equation change to , we finish the proof of multiple form of mobius inversion.
Classic Problem
Before solve some question, we need know a core trick.
This trick even no need to prove. I already say mobius function have a natrue that the sum of the Mobius functions of the divisors of a number equal to 1 only when that number equal to 1.
Problem 1
Solution:
Problem 2
Function is number of divisors function.
Core Lemma:
Solution:
Problem 3
Solution:
Problem 4
Function is Fibonacci sequence.
Core Lemma:
Below is proof.
Lemma 1.
Prove it by mathematical induction:
- Base case:
- For ,
- For ,
- Inductive hypothesis: Assume it holds for .
- Inductive step: When , , so . (Becasue of )
Lemma 2. When , holds.
Before prove this lemma, we should know a law Still use mathematical induction to prove it:
- Base case: For ,
- Inductive hypothesis: Assume it holds when .
- Inductive step: When ,
When try to prove Lemma 2.
Let , then , So:
Because of , so we can simplify above expression to below one:
Then becasue of Lemma 1, we can know that (because there are no common divisior between and ), then repeat this process, we can found taht
Now we going to prove that core lemma.
Let . By the Euclidean algorithm,
Combining Lemma 2, we can apply the same reduction process to :
By definition, , and (the greatest common divisor of a non-zero number and is the number itself). Therefore,
Solution:
The last step is because , we dismantle the sum.
Summarize
The core idea of mobius inversion is optmize the time complexity of a expression by the natrue of mobius function.