Method line M16 · When and why do we use it?

Counting in Two Ways

In the Chinese book: 算两次

Count one quantity in two ways and equate: rows of a table, then columns.

📖 Chapter 16 of 《解题方法与策略》

One idea, one pictureFirst look at the table with “Count by rows”, then with “Count by columns”. Why are the two totals always equal? Drag n around.

Loading figure…

In one sentence

The total number of marks in a table (an incidence table) can be added up by rows or by columns:

This sounds too simple to be worth saying, yet it is extremely powerful: choose the “rows” and “columns” well, and one side is easy to compute while the other side is exactly the quantity you want. That is counting in two ways (the Fubini principle).

Predict first

is the number of positive divisors of . What is ?

Choose an answer first; then you can see the result.

Example: Σ d(j) = Σ ⌊n/i⌋

Step 1 / 4
Loading figure…
  1. Draw the incidence table

    The rows are and the columns are ; put a dot where . The sum we want is the number of dots in the table.

Stop 1 · Families of subsets (Vol. 1)

Rows = elements, columns = subsets, and a dot where “the element belongs to the subset”. Counting by columns gives ; counting by rows gives “how many subsets each element belongs to”.

Example: the total size of all the subsets of {1, 2, 3, 4}

Step 1 / 3
Loading figure…
  1. Count by columns

    Each column is a subset , and its column sum is . Adding up numbers directly is a bit tiring.

Stop 2 · People and groups (Vol. 1)

Rows = people, columns = groups, and a dot where “this person is in this group”. If you know every row sum and every column sum, you can work one out from the other.

Loading figure…
Tap cells to put 6 people (P) into 4 groups (G). Try to put everyone in exactly 2 groups: how many people does a group have on average? Can the two counts ever give different totals?

Example: each person is in exactly 3 clubs, each club has exactly 6 people, and there are 40 people. How many clubs are there?

Step 1 / 4
  1. Name the unknown

    Say there are clubs. The incidence table has rows and columns.

Stop 3 · Sums and combinatorial identities (Vol. 5)

The most beautiful way to prove an identity is to find a set whose two ways of counting give the two sides.

One problem, several solutions

Prove that .

Count in two ways

Count the -element subsets of . On one hand there are of them. On the other hand, sort them by their largest element (): the other two elements are chosen from , in ways. The two sides are equal.

CostYou have to think of “sorting by the largest element”, but then it takes one line.

Mathematical induction

For both sides are . If it holds for , adding to the left side gives (Pascal's rule), so it holds for .

CostMechanical and reliable, but it does not show “why” the identity holds.

Stop 4 · Combinatorial estimates (Vol. 6)

To bound how large a family of sets can be, count some kind of “pair”: one side gives an upper bound from the condition, the other is expressed through the size of the family.

Example: 𝓕 is a family of 3-element subsets of {1, …, 7}, and any two of its sets share at most one element. How large can |𝓕| be?

Step 1 / 4
  1. What to count

    Count “(pair of elements , set )” with .

Practice

Exercise 1Basic

Find , where is the number of positive divisors of .

Exercise 2Basic

A grade has students. Each student is in exactly clubs, and each club has exactly students. How many clubs are there?

Exercise 3Advanced

Find .

Exercise 4Challenge

A family of -element subsets of has the property that any two of its sets share at most one element. At most how many sets can such a family have?

Mistake Museum · Exhibits from this stop

Before you leave, look at the traps other people fell into here.See every exhibit in the museum →

Exhibit

Each object is counted twice, but you forget to divide

The wrong step: people each shook hands with exactly others, so there were handshakes in all.
What went wrong? Think first, then open

Diagnosis Counting person by person, each handshake is counted once by each of its two people. Here the “incidence table” is people × handshakes, and each column (one handshake) has two marks.

The right step: , so there were handshakes. And by the way: if people each shook hands times, would be odd, which is impossible. That is the handshake lemma.

“First ask how many marks each column has”

Exhibit

Taking the bound from double counting as the answer

The wrong step: A family of -element subsets of , any two sharing at most one element. Count “(pair of elements, set)”: , so is at most .
What went wrong? Think first, then open

Diagnosis is only an upper bound. For , count once more by elements: the sets containing a given element meet pairwise only in that element, so there are at most of them. Then , so , which is sharper.

The right step: Once you have an upper bound, either give a construction that reaches it, or count in another way to improve the bound.

“A bound becomes an answer only with a construction”

Stops on this line

The same idea, used once in each of several places.

  1. Families of SubsetsVol. 1 Sets, ch. 5
  2. Inclusion–ExclusionVol. 1 Sets, ch. 9
  3. General Terms and SumsVol. 5 Sequences and Mathematical Induction, ch. 4
  4. Cauchy in Combinatorial EstimatesVol. 6 The Mean Inequalities and the Cauchy Inequality, §4.4