Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Section 6.5 Inclusion/Exclusion 1 Finding the number of elements in the union of 2 sets • From set theory, we know that the number of elements in the union of 2 sets is the sum of the number of elements in each set minus the number of elements in the intersection of the 2 sets: |A B| = |A| + |B| - |A B| 2 Example 1 • A discrete math class consists of 4 students taking Software Design, 3 students taking CS2, 2 students taking neither, and 1 student taking both. How many students are in the class? – Let |A| = # in SD, |B| = # in CS2, |C| = # in neither – So |AB| = # taking both and |ABC| = # in discrete – |A B C| = |A| + |B| + |C| - |A B| = 4+3+2-1=8 3 Example 2 • How many positive integers not exceeding 100 are divisible by 2 or 5? – |A| = # divisible by 2 = 100/2 = 50 – |B| = # divisible by 5 = 100/5 = 20 – |A B| = # divisible by both; since they are mutually prime, this is the numbers divisible by 2*5 = 100/10 = 10 – So |A B| = 50 + 20 - 10 = 60 4 Example 3 • We can use similar means to find the number of elements outside the union of 2 sets: • A recent survey found that 96% of U.S. households have at least one television, 98% have phone service, and 95% have both; what percentage of households have neither? 5 Solution for example 3 • Let |A| = % of households with TV (96) and |B| = % of households with phone service (98) • We know that 95% have both; this is |AB| • The total number of households that have either TV or phone service, |AB| is: |A| + |B| - |AB| = 96+98-95 = 99 • The total number of households is 100%, so the number that have neither TV nor phone is 100-99, or 1% 6 Finding the number of elements in the union of 3 sets • The sum |A| + |B| + |C| counts the number of elements in one set once, the number in 2 sets twice, and the number in all 3 sets 3 times • Subtracting the number of elements in any pair of the sets eliminates the double counting: |A|+|B|+|C| - |AB| - |AC| - |BC| • But this also eliminates all elements appearing in all 3; so we add those elements back in: |A|+|B|+|C| - |AB| - |AC| - |BC| + |ABC| 7 Example 4 • Suppose there are 2504 computer science majors at a school; of these: – 1876 have taken C++, 999 have taken Java, 345 have taken C and – 876 have taken both Java and C++, 231 have taken C++ and C, and 290 have taken Java and C • How many CS majors have not taken any of these languages? 8 Example 4 • Let |J| be the number who have taken Java (999), |P| be the number who have taken C++ (1876) and |C| the number who have taken C (345) • Then: |JPC| = |J|+|P|+|C| - |JP| - |JC| - |PC| + |JPC| 999+1876+345 - 876 - 231 - 290 + 189 = 2012 • So 2504 - 2012 or 492 have taken none of these languages 9 Principle of Inclusion/Exclusion Let A1, A2, … , An be finite sets; then |A1 A2 … An| = |Ai| - |Ai Aj| + 1in 1i<jn |Ai Aj Ak| - … + 1i<j<kn (-1)n+1|A1 A2 … An| 10 Proof We want to show that each element in the union of the sets is counted exactly once; suppose a is a member of exactly r of the sets A1 … An where 1 r n. This element is counted: C(r,1) times by |Ai| and C(r,2) times by |Ai Aj| and, in general, C(r,m) times by summation involving m of the sets So element a is counted C(r,1)-C(r,2)+C(r,3)- … +C(r,r) times 11 Proof continued Recall the binomial theorem: (x+y)n = C(n,j)xn-jyj (as j goes from 0 to n) We can show from this theorem that (-1)kC(n,k) = 0 (as k goes from 0 to n); thus C(r,1) - C(r,2) + C(r,3)- … +(-1)rC(r,r) = 0 Changing the exponent of -1 in the last term to r+1 gives us: C(r,1) - C(r,2) + C(r,3)- … +(-1)r+1C(r,r) = 1 So each element in the union is counted exactly once. 12