The 2020 election was many things. It was close. It was long and drawn out. It was exciting. It was also a teachable moment.

Think back to your high school algebra class. OK, don’t think about that, think about the election. Did the media take too long to declare a winner? Or did they actually call it too soon–before all the votes were counted? What does it take to predict whether a state is ultimately going to turn red or blue ? How many votes must separate the front runner from the runner-up? What percentage of the total ballots must have been counted? And what does any of this have to do with algebra, of all things?

Imagine an election with two candidates, let’s call them Paul and Cynthia. Paul has 9,000 votes, Cynthia has 10,000. Who has won? If all the votes have been counted, then obviously Cynthia has. But what if the counting is still in progress? Can we still tell who has won? Clearly, it depends on how many votes remain to be counted. If that number is smaller than 1,000 there’s no way that Paul can catch up, and it’s a sure bet that Cynthia is the winner.

So far, so obvious. But what if there are more than 1,000–say 2,000–uncounted votes? In that case, it would be mathematically possible for Paul to win, but he might have to win a pretty high percentage of those votes. Given his performance so far, how likely is it that Paul will actually win the election? Or to put it another way, what fraction of the outstanding votes would he have to get in order to catch up to Cynthia?

With the simple numbers I’ve used here you can probably guess the answer after a few tries. Let’s see… If Paul gets all 2,000 votes that clearly puts him over the top; if he only gets 1,000 Cynthia will get the other 1000 and he’ll be right back where he started. He needs more. How about 1,500? That way Cynthia would get 500, Paul would get a net gain of 1,000 and it’d be a tie. So Paul has to get more than 1,500 votes, or ¾ of the votes up for grabs in order to win. That sounds do-able, especially if those votes come from precincts that favor Paul, so maybe we shouldn’t call the election for Cynthia just yet.

When newspapers and television commentators describe partial election returns they generally report how many votes each candidate has received so far along with an estimate of how many votes have yet to be counted. That’s less than illuminating: what we really want to know is how well the losing candidate will need to perform on those remaining ballots in order to win. It turns out that’s pretty easy to calculate. All it takes is a little–you guessed it!–algebra.

Let P, C, and R stand, respectively, for Paul’s votes, Cynthia’s votes, and the remaining, as yet uncounted, votes. For instance, in the example above P would be 9,000, C 10,000, and R 2,000. Now imagine that after the R votes have been tabulated Paul wins some number, X, of them and Cynthia gets all the others, namely R – X. (We’re assuming that there are only two candidates in the race – it’s not hard to include additional ones.) So the condition that Paul and Cynthia are tied after the R votes have been counted can be written as

P + X = C + R – X

or, in English: if Paul can get X votes out of the remaining R votes he can eke out a tie with Cynthia. Any more than that and Paul wins outright.

This formula is obviously correct, but in its present form it’s also pretty useless. After all, we know P, C, and R–it’s X we’re looking for. So to make the formula useful we have to rearrange it so that X is on one side and the other three variables are on the other. Do you remember how to do this? According to the rules of algebra you’re allowed to move a variable from one side of the “equals” sign to the other if you change its sign. (There’s a reason why that works, of course. If you remember it, you don’t need to continue reading.) So, for instance, we can move the P from the left side to the right side and put a minus sign in front of it, like this:

X = -P + C + R – X

and we can perform the same operation with the X on the right side of the “equals” sign, to get:

X + X = -P + C + R

Add the two Xs together and change the order on the right side to make it more readable and you have:

2X = C – P + R

Now divide both sides by 2 to get:

X = ½ (C – P + R)

Plugging in the numbers from the example above, X = ½ (10,000 – 9,000 + 2,000) = 1,500.

That example was so simple that we could guess the answer, but during the election the numbers were bigger and it wasn’t so easy to keep track of what was going on. It would have been helpful if the reporters had done the math for us, but few of them did.

A final note. All we’ve done so far is calculate how many votes out of those remaining the currently losing candidate needs in order to come out on top. In order to estimate how likely such an event is we would need to know much more about those remaining votes than just how many of them there are. Information about where they were coming from and, in this election particularly, whether they were in-person or mail-in votes turned out to be critically important in deciding whether or not to call the election for one candidate or the other.