Whenever the time came to elect a new doge of Venice, an official went to pray in St. Mark’s Basilica, grabbed the first boy he could find in the piazza, and took him back to the ducal palace. The boy’s job was to draw lots to choose an electoral college from the members of Venice’s grand families, which was the first step in a performance that has been called tortuous, ridiculous, and profound. Here is how it went, more or less unchanged, for five hundred years, from 1268 until the end of the Venetian Republic.

Can theorists engineer a better way to elect candidates? Illustration by Joost Swarte

Thirty electors were chosen by lot, and then a second lottery reduced them to nine, who nominated forty candidates in all, each of whom had to be approved by at least seven electors in order to pass to the next stage. The forty were pruned by lot to twelve, who nominated a total of twenty-five, who needed at least nine nominations each. The twenty-five were culled to nine, who picked an electoral college of forty-five, each with at least seven nominations. The forty-five became eleven, who chose a final college of forty-one. Each member proposed one candidate, all of whom were discussed and, if necessary, examined in person, whereupon each elector cast a vote for every candidate of whom he approved. The candidate with the most approvals was the winner, provided he had been endorsed by at least twenty-five of the forty-one.

Don’t worry if you blinked: bewildering complexity was part of the point. The election aimed to reassure Venetians that their new ruler could not have been eased into place by backroom deals. Venetians had been coming up with inventive ways to make political decisions for a couple of hundred years before they concocted this rigmarole. Earlier elections in Venice, and in other Italian communes, required a winner to be endorsed by two-thirds, or sometimes three-quarters, of the voters. The hallmark of the Venetian approach has come to be known as “approval voting,” in which electors do not need to pick a favorite but may vote for several candidates they like.

In 1179, two years after a stay in Venice, Pope Alexander III reformed papal elections, perhaps because he liked some of what he saw there. Among other things, he abolished a tradition of requiring unanimity among the cardinals, and settled for a two-thirds majority instead. You would expect a two-thirds consensus to be easier to reach than unanimity, but papal conclaves in the thirteenth century seemed to go on forever. On six occasions, it took several months to choose a Pope. In 1241, by some accounts, the head of the civil administration in Rome threatened to exhume the corpse of the defunct Pope and parade it through the city in full regalia if the cardinals didn’t settle on a new one. Eventually, the cardinals got the hang of it. After some tinkering over the years, the two-thirds rule was reconfirmed by the present Pope, in 2007.

“What is done by two-thirds of the Sacred College, that is surely of the Holy Ghost,” Pius II said of his own election, in 1458. He did not explain why divine approval kicks in only at the two-thirds mark. Since then, mathematicians, economists, and political theorists have made their own attempts to elucidate the math of voting, and figure out better electoral systems. The story of these efforts is told in “Numbers Rule: The Vexing Mathematics of Democracy, from Plato to the Present” (Princeton; $26.95), by George Szpiro, a journalist and mathematician.

The book happens to be timely. The voting method that is used in Britain—and that has been kept on in some of its former colonies, including the United States—may finally be replaced. When neither of Britain’s two main parties won a majority in parliamentary elections this May, the Conservative Party formed a coalition government with Britain’s third party, the Liberal Democrats, who have long campaigned for electoral reform. One price of the coalition deal is a national referendum on changing the country’s main voting system, which will be held in 2011. If Britain does switch, as most other developed countries already have, the cause of voting reform in holdouts like the United States, India, and Canada could get a boost.

In the standard British style of voting, each elector casts one vote, and the candidate with more votes than any other is elected. This is known as “first past the post”; the winner just needs to get more votes than anyone else, not achieve any threshold (such as a two-thirds majority). It is also called “winner takes all,” to distinguish it from some other methods, which elect the top two or more candidates.

In a contest between two people for one job, first past the post seems to be merely common sense. But, as soon as there are three or more candidates on the slate, it can quickly go awry. The least popular candidate could easily win, if the opposition to him or her splits its votes between two or more other candidates. Say sixty per cent of voters are right of center and forty per cent are to the left. In a three-way contest with two equally popular right-wing candidates and one left-winger, a first-past-the-post vote will elect the left-winger, whom only a minority want. A dramatic variety of vote-splitting happens when a “spoiler” with no chance of winning manages to affect the outcome of an election by sucking away votes that could have reversed the positions of two front-runners in a close race. If several hundred Ralph Nader supporters in Florida had voted for Al Gore, the outcome of America’s 2000 Presidential election would have been different.

Add political parties to the picture, and the winner-take-all system looks even worse. A party’s share of seats in a parliament or a congress can diverge wildly from its over-all share of votes. In Britain’s 1983 election, the Liberal-S.D.P. Alliance won more than twenty-five per cent of the votes but fewer than four per cent of the seats in Parliament. In this year’s election, the Liberal Democrat Party won more than a fifth of the votes and less than a tenth of the seats. That’s because Lib-Dem supporters today, like those of the Alliance in 1983, are thinly scattered across the land.

In a country with just two political parties, winner takes all can deliver a proportionate parliament or congress. But that’s only because the supporters of political parties tend to live in clusters. Say that fifty-three per cent of American voters are Democrats and forty-six per cent are Republicans (mirroring the vote in last year’s Presidential election). Then imagine that the supporters of the two parties were spread evenly throughout the country’s districts—like Britain’s Liberal Democrats, only much more so. In that case, the Democrats would win every seat and there would be no Republicans in Congress. Something like this happened in Wales in 1906, when Conservatives got thirty-four per cent of the vote and no seats.

Szpiro, who is more interested in math than in politics, says relatively little about how voting systems have played out in the real world. (Readers who want to enrage themselves and frighten their families should turn to William Poundstone’s 2008 book, “Gaming the Vote,” a masterly account of the way electoral mathematics is manipulated in America.) But it’s clear that no country would pick first-past-the-post voting today. Of democracies with no significant British past, only Nepal now elects its national assembly this way.

The history of voting math comes mainly in two chunks: the period of the French Revolution, when some members of France’s Academy of Sciences tried to deduce a rational way of conducting elections, and the nineteen-fifties onward, when economists and game theorists set out to show that this was impossible. Perched in the middle is the Reverend Charles Dodgson, better known as Lewis Carroll, the author of “Alice’s Adventures in Wonderland” and “Through the Looking-Glass.”

The first mathematical account of vote-splitting was given by Jean-Charles de Borda, a French mathematician and a naval hero of the American Revolutionary War. Borda concocted examples in which one knows the order in which each voter would rank the candidates in an election, and then showed how easily the will of the majority could be frustrated in an ordinary vote. Borda’s main suggestion was to require voters to rank candidates, rather than just choose one favorite, so that a winner could be calculated by counting points awarded according to the rankings. The key idea was to find a way of taking lower preferences, as well as first preferences, into account.

Unfortunately, this method may fail to elect the majority’s favorite—it could, in theory, elect someone who was nobody’s favorite. It is also easy to manipulate by strategic voting. If the candidate who is your second preference is a strong challenger to your first preference, you may be able to help your favorite by putting the challenger last. Borda’s response was to say that his system was intended only for honest men. The French Academy adopted Borda’s method of electing members, until a new member, Napoleon Bonaparte, pressed the Academy to abandon it. It’s not clear what Napoleon didn’t like about it, but, given that his conquest of Venice deposed its last doge, Napoleon has the distinction of having quashed two unusual voting schemes. (Versions of Borda’s method are still used in some sporting competitions, in the Eurovision Song Contest, and to elect the Parliament of Nauru, a Pacific atoll.)

The Marquis de Condorcet, a prominent reformer who became a secretary of the revolutionary National Assembly, made a deeper investigation of voting. In effect, Condorcet suggested dividing elections into a series of one-on-one contests, so that every candidate is directly compared with every other. If there is a candidate who wins every such match, it is clear who should be the over-all winner of the tournament. But even with as few as three candidates there may not be such a person.

While scrutinizing such contests, Condorcet noticed that a loop may arise resembling the children’s playground game rock-paper-scissors. Scissors cut paper, paper wraps rock, but rock blunts scissors—so none of them is the strongest. The same could happen in a run of head-to-head votes. If more people prefer Alphonse to Benoît than prefer Benoît to Alphonse, and more prefer Benoît to Claude than Claude to Benoît, it could also be the case that more prefer Claude to Alphonse than Alphonse to Claude. In this sort of loop, which was later called a “cycle” by Charles Dodgson, the notion of an over-all winner breaks down. Condorcet’s own fortunes broke down when he fell out with the Jacobins over the execution of Louis XVI, was branded a traitor, and died mysteriously in prison.