The Mathematics of Elections

← Back to specs
High school 14 Rooms

Teaching objectives

Without faking a single vote, the voting rule decides who wins. This upper-secondary lab has 14 rooms and 41 challenges about systems with states and electors, seat apportionment and decision rules. There are also eight ungraded class polls. There are no scammer or detective roles: an electoral system is a debatable rule, not a scam. All the mathematics is computed in the browser.

What students learn

  • States and electors. When each state takes all its electors, an election can be won with very few popular votes (6 of 21, 28.6 %), and the candidate with more votes can lose.
  • How many electors each state gets. The quota, the largest remainders and the d’Hondt method do not give the same split; d’Hondt also shares seats among parties.
  • One more seat and I end up with none. With largest remainders, when the chamber grows a state can lose a seat (the Alabama paradox); with d’Hondt it does not happen.
  • The rule and the map. The country worth designing to win with few votes depends on the rule, and whoever draws the borders also decides (gerrymandering).
  • Which rule is fairer? The weight of a vote in each state and the balance between protecting small territories and making every person count the same.
  • Majorities within majorities. With groups of 3 over k levels, a fraction (2/3)^k of the votes is enough.
  • Vote splitting. A candidate who does not win can change who wins; plurality only looks at the first preference.
  • Condorcet cycles. With coherent preferences, “the one preferred by more wins” can form a cycle, and whoever sets the order of the knockout decides.
  • The alternative vote. The last candidate is eliminated and ballots are transferred; having more first preferences can make you lose.
  • Power in a parliament. The Banzhaf index measures how many times a party is needed to win; seats are not power.
  • Participation quorum. Requiring a minimum participation creates incentives to abstain.
  • The jury theorem. With independent judges who are right more than half the time, the majority is right more often than each one; if they copy each other, there is no advantage.
  • Zero-sum games. When two players choose at the same time, being predictable gets exploited (also by an AI that learns your habits): a mixed strategy (choosing at random with certain probabilities) secures a value of the game, and the indifference principle computes it.
  • Campaigns of several weeks. With one week the symmetric game is trivial (saddle point); with several it is solved backwards and positions appear where you have to defend and others where you have to surprise. The room ends with a class tournament.

Key mathematical ideas

  • Minimum votes: with states of 3, 7 and 11 inhabitants and 3, 4 and 5 electors, X wins with 6 of the 21 votes and the loser can have 15.
  • Sharing electors: with 10 electors and states of 40, 130, 220, 290 and 320 thousand inhabitants, largest remainders give 1-1-2-3-3 and d’Hondt 0-1-2-3-4: the smallest state gets no elector at all. In a province with 5 seats and 40,000, 28,000, 17,000, 9,000 and 6,000 votes, d’Hondt gives 2-2-1-0-0 and 15 % of the votes win no seat.
  • The Alabama paradox: with states of 5,000, 3,000 and 1,000 inhabitants, largest remainders give 2-1-1 with 4 seats and 3-2-0 with 5; d’Hondt gives 3-1-0 and 3-2-0. Between 1 and 12 seats it only happens when going from 4 to 5.
  • Design your country: with 25 inhabitants in 5 states, the fewest votes X can win with are 3 (one per state), 7 (proportional) or 4 (US-style): 12 %, 28 % and 16 %. On a grid of 25 voters (11 for X and 14 for Y), X wins 3 of 5 states in 138 of the 4006 ways of drawing the borders (3.4 %), while by rows or by columns Y wins.
  • The weight of a vote: a state’s electors divided by its inhabitants; under the US-style rule and states of 1 to 13 inhabitants, a vote in the smallest state weighs 6.5 times one in the largest.
  • Nested majorities: 2/3, 4/9, 8/27 and 16/81 (19.8 %) with 1, 2, 3 and 4 levels.
  • Vote splitting: with 42, 38 and 20 votes A wins; if C withdraws, B wins 58–42. With four candidates (A 31, B 25, C 30 and D 14 votes), whoever runs B’s campaign only wins if C and D both withdraw: if only C withdraws D wins (44) and if only D withdraws A wins (45); with both out, B wins 55–45.
  • Condorcet cycle: with 9 voters in three blocks, A beats B, B beats C and C beats A, all 6–3; depending on the first duel of the knockout anyone can win. With 100 voters on a line, the Condorcet winner finishes last in first preferences.
  • The alternative vote: with 21 ballots, C is eliminated and A wins 11–10; if 3 B›A›C voters switch to A›B›C, A rises to 10 first preferences, B is eliminated and C wins 11–10. With 2,100 voters it is enough that 201 of 300 switch.
  • Banzhaf index: with 9, 8 and 2 seats (majority 10) each party has 1/3; with 5, 3 and 1 the big one decides; with 4, 4 and 1 the small one equals the big ones; with 3, 3, 3 and 1 (majority 6) the 1-seat party has no power.
  • Quorum: with 20 people and a minimum of 10, with 7 yes and 2 no it is not valid (9) and with 7 yes and 3 no yes wins; with 7 certain yes votes and 6 opponents, the proposal fails if at least 4 opponents stay at home.
  • The jury: with 25 judges who are each right 60 % of the time, the majority is right 84.6 % of the time (with p = 40 %, 15.4 %); 41 judges (odd) are needed to pass 90 %; with 101 judges it is enough for each to be right 57 % of the time (with 56 % the majority is right 88.75 % of the time).
  • Challenger against president: with states of 3, 4 and 6 electors and independent elections (each one is a new one, nothing carries over), what is measured is the average number of electors the challenger takes per election. Against a president who defends at random with 10 %, 20 % and 70 %, the best state is the 4 (3.2 on average per election). Students find the mixes themselves: as the president, the defence that equalises the bars e(1 − q) is (1/9, 3/9, 5/9); as the challenger, the attack that equalises p·e is (4/9, 3/9, 2/9) (the small state most often); and the value of the game is (n − 1)/Σ(1/e) = 8/3 ≈ 2.67 per election. They play against an AI that learns from their habits: it exploits any unbalanced mix and cannot beat the optimal one.
  • Several weeks of campaign: with one week, both go to the 6 and draw (saddle point, value 0). With 4 weeks the value is still 0, but in a position with two weeks to go in which you lead 6 to 4, the only move that guarantees the win is to go to the 3; and in a last week with him leading 7 to 6 you have to mix 50-50 between the 3 and the 4. In the class tournament the equilibrium (4/9, 3/9, 2/9 and 1/9, 3/9, 5/9) never loses to anyone, but the best response to the class average scores more if the class is predictable.

Using it in class

  • Rooms 1, 7, 8, 12, 13 and 14 have a class poll (rooms 5 and 11 have it at the end): none of them is graded and they open a discussion.
  • Project “Winning with the fewest votes”, the borders challenge of “Design your country”, the duels going round in a circle of “Head-to-head duels” and the book of room 2, which explains the d’Hondt method with an animation.
  • Rooms 9 and 12 are the hardest: it is better to keep them for those who have already done the rest.
  • Rooms 13 and 14 are the only ones with a game against the computer and a poll each; in room 14 the teacher can launch the class tournament from their panel (tournament button, as in Axelrod): the strategies the students have sent are collected and example strategies can be added.
  • Level: upper secondary. It needs proportions and division; no calculation needs more than a calculator.

Room-by-room contents

Room 1 · Winning with the fewest votes

Three states with 3, 7 and 11 inhabitants, each with its electors (3, 4 and 5). The student switches each inhabitant’s vote between X and Y and sees how votes and electors add up. Before starting, the class estimates the smallest percentage that can win. As the scammer, they split the votes so that X wins with as few as possible.

Student tasks

  • Estimate the smallest percentage of votes that wins (ungraded).
  • Split the votes so that X wins with the minimum (6 out of 21).

Room 2 · How many electors does each state get?

A country of five states with 40, 130, 220, 290 and 320 thousand inhabitants shares out 10 electors. The split is worked out with the largest remainders method and with the d’Hondt method (using a table of quotients in which the largest ones are marked), and they do not give the same result: under d’Hondt the smallest state gets no elector at all. Then the 5 seats of a province are shared among five parties and the student works out what share of the votes is left without a representative. The book explains the quota, largest remainders, d’Hondt and how both are used in Spain.

Student tasks

  • Share 10 electors among five states with largest remainders (1-1-2-3-3).
  • Share the same electors with d’Hondt by marking the 10 largest quotients (0-1-2-3-4).
  • Share 5 seats of a province among five parties with d’Hondt (2-2-1-0-0).
  • Work out the percentage of votes left without a seat (15 %).

Room 3 · One more seat and I end up with none

Three states with 5,000, 3,000 and 1,000 inhabitants. The student shares 4 seats with largest remainders (2-1-1) and then 5 (3-2-0): when the chamber grows, the smallest state loses its seat. This is the Alabama paradox. In the last challenge they share 4 and 5 seats with d’Hondt (3-1-0 and 3-2-0), where nobody loses. The book recaps largest remainders, tells the 1880 Alabama case and explains divisor methods.

Student tasks

  • Share 4 seats with largest remainders (2-1-1).
  • Share 5 seats with largest remainders (3-2-0) and see state C lose its seat.
  • Share 4 and 5 seats with d’Hondt (3-1-0 and 3-2-0): nobody loses.

Room 4 · Design your country

The student places 25 inhabitants among five states (at least 1 in each) with the − and + buttons, and a panel says with how many votes X could win under the chosen rule. The elector rule changes in each challenge: one per state, proportional and US-style; the same 25 inhabitants give a minimum of 3, 7 or 4 votes depending on the rule. In the last challenge the borders are drawn on a grid of 25 voters whose votes are fixed (11 for X and 14 for Y): five states of five squares, each in one piece, must be painted so that X, who has fewer votes, wins. This is gerrymandering.

Student tasks

  • Design the country in which X wins with the fewest votes with one elector per state (3 out of 25).
  • The same under the proportional rule (7 out of 25).
  • The same under the US-style rule (4 out of 25).
  • Draw the borders of five states of five squares so that X, with 11 votes out of 25, wins 3 states.

Room 5 · Which rule is fairer?

A fixed country of five states with 1, 3, 5, 9 and 13 inhabitants and three elector rules (one per state, US-style and proportional). In two vote splits the student decides who wins under each rule; in each one two different rules agree and the third gives another winner, and the candidate with more popular votes loses under one of them. Then they work out how many times more the vote of an inhabitant of the smallest state weighs than that of the largest. At the end the class votes on which rule seems fairest (ungraded) and it is discussed with the examples of the United States Senate and the Spanish Senate.

Student tasks

  • Decide who wins under each of the three rules in split 1.
  • The same in split 2.
  • Work out how many times more the vote of the smallest state weighs under the US-style rule (5.4).
  • Vote on which rule seems fairest (ungraded).

Room 6 · Majorities within majorities

Voters in groups of 3 choose a winner; the winners are grouped again in threes, and so on up. The student builds the split with the fewest votes that wins with 2 and 3 levels and extrapolates to 4.

Student tasks

  • Win with the minimum with 2 levels (4 out of 9).
  • Win with the minimum with 3 levels (8 out of 27).
  • Work out the minimum fraction with 4 levels (16/81).

Room 7 · The candidate who changes the winner without winning

Three candidates and a hundred voters with ranked ballots, of which only the first preference counts. Before starting, the class gives its opinion on who should win with 42, 38 and 20 votes (ungraded). The student works out who wins with the three candidates (A) and who would win if C withdrew and its voters moved to their second choice (B), with animated bars. Then, with a slider, they look for the smallest number k of B’s voters who move to a third candidate for A to win, having started at 45 against 55 (11). The book explains plurality and vote splitting, with the debated Florida 2000 case.

Student tasks

  • Give an opinion on who should win with 42, 38 and 20 votes (ungraded).
  • Say who wins with three candidates (A) and who wins if C withdraws (B).
  • Find the smallest number of B’s voters who move to C for A to win (11).

Room 8 · Head-to-head duels

Nine voters in three blocks of three and three candidates compared in pairs. Before starting, the class gives its opinion on whether it can happen that A beats B, B beats C and C beats A (ungraded). The student decides the three duels (all 6–3) and watches the animation in which they form a cycle; then chooses the first duel of a knockout so that C wins (A versus B), and finally analyses another election of 100 voters in which the Condorcet winner (B) loses by plurality (A wins). The book presents the Condorcet cycle and mentions Arrow’s theorem.

Student tasks

  • Give an opinion on whether three candidates can form a cycle (ungraded).
  • Decide the winner of the three duels (A, B and C: a 6–3 cycle).
  • Choose the first duel of the knockout with which C wins (A versus B).
  • Say who wins by plurality (A) and who is the Condorcet winner (B) in an election of 100 voters.

Room 9 · Winning less by having more votes

Twenty-one ranked ballots and the alternative vote: the last candidate is eliminated and its ballots move to the next preference, and you see them move on screen. The student does the count (C is eliminated and A wins, 11–10), sees three voters change their ballot to put A first and checks that C then wins (11–10). With 100 times more voters, they work out how many of the 300 B›A›C voters have to switch at a minimum for C to win without ties (201). It is the hardest room of the lab. The book explains the alternative vote and monotonicity.

Student tasks

  • Do the count: who is eliminated and who wins (C is eliminated, A wins).
  • After three ballots change, say who wins (C).
  • With 2,100 voters, find how many B›A›C voters have to switch for C to win without a tie (201).

Room 10 · The small party that decides

A hemicycle in which coalitions are formed by tapping parties: the seats light up and the decisive parties get a crown. With 9, 8 and 2 seats out of 19 (majority 10), the student works out the Banzhaf index of C (1/3) and sees all the coalitions being run through. Then they look for how many of 9 seats A needs to decide alone (5) and, finally, what power a 1-seat party has in a parliament of 3, 3, 3 and 1 seats with majority 6 (0). The book explains winning coalitions, decisive parties and the Banzhaf index.

Student tasks

  • Work out the Banzhaf index of C with 9, 8 and 2 seats (1/3).
  • Find the smallest number of seats with which A decides alone in a parliament of 9 (5).
  • Work out the power of the 1-seat party with 3, 3, 3 and 1 seats and majority 6 (0).

Room 11 · The vote against that makes yes win

A referendum of 20 people that is valid if at least 10 take part and is decided by a majority of the votes cast. The student sees that with 7 yes and 2 no it is not valid (9 participants) and with 7 yes and 3 no yes wins; decides whether someone against is better off voting “no” or staying at home (at home); and works out how many of 6 opponents have to stay at home for the proposal to fail (4). At the end the class gives its opinion on whether requiring a minimum participation seems right (ungraded). The book explains the quorum and the incentive to abstain, with the case of Italy.

Student tasks

  • Decide whether it passes with 7 yes and 2 no and with 7 yes and 3 no (no · yes).
  • Choose between voting “no” and staying at home in another town (stay at home).
  • Find how many opponents have to stay at home for the proposal not to pass (4).
  • Give an opinion on whether requiring a minimum participation is a good idea (ungraded).

Room 12 · Is a majority wrong less often?

A jury of n judges who are right with probability p and decide on their own. Before starting, the class gives its opinion on how often a majority of 25 judges who are each right 60 % of the time is right (ungraded). The student changes n and p, simulates one vote or repeats it 1000 times (with the distribution of judges who are right) and compares with the exact binomial calculation. Challenges: the probability with n = 25 and p = 60 % (84.6 %), the smallest odd number of judges to pass 90 % (41) and, with 101 judges, the smallest whole percentage of accuracy per judge for which the majority passes 90 % (57 %), first by eye (an ungraded poll) and then moving the p slider. It is a harder room. The book explains the binomial, Condorcet’s jury theorem and why independence matters.

Student tasks

  • Give an opinion on how often a majority of 25 judges who are each right 60 % of the time is right (ungraded).
  • Estimate with the simulator the probability that the majority is right with n = 25 and p = 60 % (84.6 %, with tolerance).
  • Find the smallest odd number of judges with which the majority is right more than 90 % of the time (41).
  • Say by eye how often each judge has to be right for 101 judges to pass 90 % (ungraded) and find the smallest whole percentage with the slider (57 %).

Room 13 · Challenger against president

A president holds three states by a hair, with 3, 4 and 6 electors. Every election is different (another electoral cycle, nothing carries over from one to the next): the challenger (the student) pours his campaign into one state and the president shields another, at the same time; if they do not coincide, the challenger takes the electors of that state in that election, and if they coincide, 0. What is measured is the average number of electors taken per election. Before playing, the class gives its opinion on where they would attack most often (it does not score). In free play (10 elections, no grade) the president is an AI that learns: it watches the student’s attacks (frequencies with forgetting and an order-1 Markov table) and a panel shows what it believes about them; people who choose “at random” by hand tend to be predictable. Then come three challenges in which the student finds the percentages himself. Against a president who defends the 3 in 10 % of elections, the 4 in 20 % and the 6 in 70 % (a bad defence, far from the optimal one so that nobody copies it in challenge 2), always attacking the 4 takes on average 3.2 electors per election (2.7 · 3.2 · 1.8): neither the big one nor the least defended (challenge 1). As the president, the student must split the defence with sliders so that the three bars e·(1 − q) are equal: q = (1/9, 3/9, 5/9) and value of the game 8/3 ≈ 2.67 per election (challenge 2). As the challenger, the attack must be split so that the bars p·e are equal: p = (4/9, 3/9, 2/9), securing 8/3 whatever the president does (challenge 3). Each split is checked with the three bars within ±0.2 of each other (with steps of 1 % the thirds cannot be hit exactly) and can be tried with “Play 100 elections” against the AI, which exploits any unbalanced mix and, against the optimal one, neither lowers nor raises the average of 8/3. The book explains mixed strategies and indifference with another example (states of 2 and 3 electors) and, at the end, the indifference principle with the room’s numbers: p proportional to 1/e and value (n − 1)/Σ(1/e). The room closes with 10 elections rolling a die with the mix from challenge 3. It is the room on zero-sum game theory (the president never gains electors, at best he loses none: what one wins the other loses). In free play and in the die game, a map of the three states shows in each election where the attack is, where the defence is and the result.

Student tasks

  • Give an opinion on where one would attack most often (does not score).
  • Play 10 elections by hand against an AI president that learns from the attacks (does not score).
  • Find the best state against a known random defence (10 %, 20 %, 70 %) and the electors on average per election (the 4, 3.2).
  • As the president, split the defence (q) with sliders until the bars e·(1 − q) are equal (1/9, 3/9, 5/9; value 8/3 ≈ 2.67).
  • As the challenger, split the attack (p) with sliders until the bars p·e are equal (4/9, 3/9, 2/9; secures 8/3).
  • Close with 10 elections rolling a die with the mix from challenge 3 (does not score).

Room 14 · Several weeks of campaign

Symmetric version of the campaign: two candidates (the student and the computer) start at 50 % in three states with 3, 4 and 6 electors and play 4 weeks. Each week they choose a state at the same time; a visit gives +3 points to the visitor and if they coincide they cancel; at the end each state goes to whoever is above 50 % (at exactly 50 %, to nobody) and whoever has more electors wins. With a single week the game is trivial (saddle point: both go to the big state and draw; challenge 1). With several weeks it is solved backwards, with a 3×3 game in each position: in a position with two weeks to go, ahead in the 6-elector state, the only safe move is to go to the 3 (challenge 2). After a poll (it does not score), the student plays the whole campaign against the computer, which plays the optimal mix of each position and shows the value of the position after each week (it does not score). In a last week with no saddle point you have to mix 50-50 (challenge 3). The room ends with a class tournament (it does not score): each student sends a single-round strategy from the previous room (probabilities of attacking and defending each state); the teacher launches it from their panel as in Axelrod’s tournament and the class ranking and the analysis of the equilibrium and of the best response to the class are shown. With no tournament launched, the ranking is against example strategies.

Student tasks

  • With a single week, find the state to go to and how it ends (the 6; a draw).
  • In a position with two weeks to go, choose the state that guarantees the win (the 3).
  • Say how the campaign ends if both play perfectly (it does not score) and play the 4 weeks (it does not score).
  • In the last week with no saddle point, find the probability of going to the 3 (50 %).
  • Define and send a strategy for the class tournament (it does not score).

Rooms to project

The most striking ones to show and discuss in class.

★
Room 1 · Winning with the fewest votes — Opens the lab with a surprise: one can win with 28.6 % of the votes. The class’s prior estimate tends to be higher.
★
Room 4 · Design your country — The last challenge, with borders drawn on a grid, shows that whoever draws the map can change the result with the same votes.
★
Room 8 · Head-to-head duels — Two simple animations —the duels going round in a circle and the knockout depending on the agenda— show that “the one preferred by more wins” does not always give a winner.