3 Variable inclusion-exclusion identity (generalizable to any number) - factoring trick
There is a very useful factoring trick which you might have seen somewhere already.
a + b + c + ab + bc + ac + abc = (1 + a)(1 + b)(1 + c) - 1
What is the intuitive way to understand it?
Essentially:
(1 + a) represents 2 choices: whether 'a' is present or not.
Similarly for (1 + b) and (1 + c).
So when you multiply all 3, you will get all possible terms where 'a','b','c' can be present or not.
And there are 2 * 2 * 2 = 8 such terms.
This sounds similar to generating all divisors of abc if a,b,c are primes.
This can be generalized to any number of variables.
For e.g. for 4 variables:
a + b + c + d + ab + ac + ad + bc + bd + cd + abc + abd + acd + bcd + abcd = (1 + a)(1 + b)(1 + c)(1+d) - 1
Comments
Post a Comment