Given \(f(n) = \sum_{d | n} g(d)\), recover \(g(n) = \sum_{d | n} \mu(n/d) f(d)\).
Details
The check that matters is the defining property of \(\mu\): \(\sum_{d | n} \mu(d)\) is 1 at \(n = 1\) and 0 everywhere else. That is an identity, and the residual is returned rather than assumed.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_mobius_inversion(V)
#> $g
#> [1] 1 1 2 2 4 2 6 4
#>
#> $mobius
#> [1] 1 -1 -1 0 -1 1 -1 0
#>
#> $divisor_sums
#> [1] 1 0 0 0 0 0 0 0
#>
#> $reconstruction_residual
#> [1] 0
#>
#> $mobius_identity_residual
#> [1] 0
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Mobius inversion (Stanley 3.7)"
#>
