Rule of Sum and the Inclusion-Exclusion Principle

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

If there are ways of getting a result and ways to get a result , then the number of ways of getting or is , as long as the results and do not overlap.


To get the right number when there is overlap, think of the possible results and as sets. Then the number of ways to get an element from or is . This is called the principle of inclusion-exclusion.


Contributed by: George Beck (July 2018)
Open content licensed under CC BY-NC-SA



The sum rule generalizes when there are more than two kinds of results, giving


as long as all the pairwise intersections

, , ,

are empty.

If there are overlaps, the right-hand side of the formula is an alternating sum. For example, here is the formula for three sets:



[1] Wikipedia. "Rule of Sum." (Jun 4, 2018)

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.