Блог пользователя fractal

Автор fractal, история, 4 года назад, По-английски

Can someone make tutorial on Morbius inversion?

  • Проголосовать: нравится
  • +248
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
 
Проголосовать: нравится +158 Проголосовать: не нравится

Its morbin time

»
4 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +67 Проголосовать: не нравится
»
4 года назад, скрыть # |
 
Проголосовать: нравится -64 Проголосовать: не нравится

Stop learning useless algorithms, go and solve some problems, learn how to use binary search.

»
4 года назад, скрыть # |
 
Проголосовать: нравится +149 Проголосовать: не нравится

Morbius inversion is undoubtedly one of the algorithms of all time

»
4 года назад, скрыть # |
 
Проголосовать: нравится +82 Проголосовать: не нравится

You simply morb by yelling "ambatumorb", no need for a tutorial

»
4 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится +16 Проголосовать: не нравится

I can give a small glimpse of what's the usage/overview:

A lot moebius inversion relies on the equality $$$\sum_{d\mid n} \mu(d) = [n = 1] = \begin{cases} 1 &\text{if}\ n = 1 \\ 0 &\text{otherwise} \end{cases}$$$, where $$$\mu(d)$$$ is the moebius function, which can be precomputed for $$$d \in [1, n]$$$ in $$$O(n)$$$ time using linear sieve. Often using this identity, you can expand a boolean expression/counting problem into expressions involving divisors, and exchanging summation signs will reduce time complexity. For example (classical example), let's count the number of coprime pairs $$$|{(a, b) \in [1, n]^2 : \gcd(a, b) = 1}|$$$:

$$$\begin{align*} \sum_{i=1}^n \sum_{j=1}^n [\gcd(i, j) = 1] &= \sum_{i=1}^n \sum_{j=1}^n \sum_{d\mid\gcd(i, j)} \mu(d) \\ &= \sum_{i=1}^n \sum_{j=1}^n \sum_{d\mid i, d\mid j} \mu(d) \\ &= \sum_{d=1}^n \mu(d) \sum_{i=1,d\mid i}^n \sum_{j=1,d\mid j}^n 1 \\ &= \sum_{d=1}^n \mu(d) \lfloor\frac{n}{d}\rfloor^2 \end{align*}$$$

Hope that each line makes sense and follow, or ask me if you don't :)

»
4 года назад, скрыть # |
 
Проголосовать: нравится +71 Проголосовать: не нравится

I would also appreciate some info on morbius sweep line algorithm

»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I can reccomend this instructional tutorial video essay documentary: https://www.imdb.com/title/tt5108870/

»
4 года назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

You can't. Morbius is a godly invention that can't be replicated by us mortals.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

It's a useless Algo, Go Learn DFS or Binary Search

»
4 года назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

There are some online tutorials about mobius inversion technique, and you can find many of them using your favorite search engine. But I would suggest going one step further, and reading some other text in number theory or combinatorics as well, because mobius is just a clean way of applying inclusion/exclusion principle.

To do this, I really recommend the book "Introduction to the Theory of Numbers" by "Harold N. Shapiro"

It's a good book overall, and the exercises can surely help you improve your skills, but to really get the intuition behind this trick, I suggest you also read the amazing "GeneratingFunctionology" by "Herbert S. Wilf", especially the second chapter and its exercises. I should also mention that to get the most of this book, you should know a bit a calculus (at least taking derivatives)