Mat. DiscretaCounting

The Sum and Product Rules

Add the counts of cases that cannot happen together; multiply the counts of choices made one after another.

Sin empezar Ir a la práctica

Esta lección aún no está traducida. Por ahora se muestra en inglés; la versión en español está en camino.

In probability you counted permutations by multiplying choices. That multiplication is one of two basic rules of counting. Both rules are facts about sets you have seen: the size of a union of separate sets, and the size of a Cartesian product.

Idea clave

Sum rule: if a choice can be made in one of several ways that cannot happen together, with $a$, $b$, … options in each, the total is $a + b + \cdots$. Product rule: if a choice is made in steps, with $a$ options for the first step and $b$ for the second (whatever the first was), and so on, the total is $a \cdot b \cdots$.

Por qué funciona

The sum rule is $|A \cup B| = |A| + |B|$ for disjoint sets: nothing is counted twice because nothing is in both. The product rule is $|A \times B| = |A| \cdot |B|$: a two-step choice is an ordered pair, and each first step pairs with every second step. The words to listen for: "either … or" (alternatives, add) versus "first … then" (a sequence, multiply). Big problems often need both: split into cases with the sum rule, count each case with the product rule.

Worked examples

Ejemplo resuelto: A license plate

A plate has $3$ letters (A–Z) followed by $3$ digits (0–9), repeats allowed. How many plates are there?
  1. Six steps in a row: $26$ choices for each letter and $10$ for each digit.
  2. Product rule: $26^{3} \cdot 10^{3} = 17{,}576 \cdot 1{,}000 = 17{,}576{,}000$.

Respuesta: $17{,}576{,}000$

Ejemplo resuelto: Two possible lengths

A code uses digits 0–9 and has length $3$ or $4$. How many codes are there?
  1. A code has one length or the other, never both, so split into cases and add.
  2. Length $3$: $10^{3} = 1{,}000$. Length $4$: $10^{4} = 10{,}000$.
  3. Sum rule: $1{,}000 + 10{,}000 = 11{,}000$.

Respuesta: $11{,}000$

Ejemplo resuelto: Cases, then products

How many three-digit numbers are even and have three different digits?
  1. The last digit must be even, and $0$ behaves differently because the first digit cannot be $0$. So split by the last digit.
  2. Last digit $0$: first digit $1$–$9$ ($9$ ways), middle digit anything else ($8$ ways): $9 \cdot 8 = 72$.
  3. Last digit $2$, $4$, $6$ or $8$ ($4$ ways): first digit not $0$ and not the last digit ($8$ ways), middle digit not either of those ($8$ ways): $4 \cdot 8 \cdot 8 = 256$.
  4. Sum rule: $72 + 256 = 328$.

Respuesta: $328$

Error común

Multiplying alternatives or adding a sequence. "Choose a dessert: one of $4$ pies or one of $3$ cakes" is $4 + 3 = 7$, not $12$; there is no second step. "Choose a pie and a cake" is $4 \cdot 3 = 12$, not $7$. Check: ask whether one outcome involves both choices (multiply) or just one of them (add).

Práctica

Apruebas con 3 respuestas correctas, las 2 últimas seguidas. Cada respuesta correcta da 1 XP.

Cargando la práctica…

Se apoya en

Lleva a

Fuentes y lecturas

  • Oscar Levin, Discrete Mathematics: An Open Introduction (3rd ed.), section "Additive and Multiplicative Principles"
  • MIT OpenCourseWare 6.042J Mathematics for Computer Science (Lehman, Leighton and Meyer), chapter "Cardinality Rules" (sum and product rules)