One thing you have to admire about gerrymandering: It’s got some wicked slang.

Gerrymandering is, of course, the dark art of drawing a legislative map that favors your political party. That involves “packing”—taking all the neighborhoods with voters who hate you and cramming them into one district. (You’ll lose that district by a landslide but have a leg up in all the others.) The reverse trick is “cracking,” breaking up a neighborhood that loathes you into chunks that you attach to other regions where you’re loved. Your opponents’ votes get spread around and diluted.

Obviously these shenanigans warp and imperil democracy. Various groups have sued over gerrymandered districts three dozen times in the past few decades, but they’ve always lost, because it’s hard to prove how much a map is gerrymandered. Usually plaintiffs have resorted to hypotheticals. (“If both parties had won the same number of votes, this map would have given the Republicans four more seats than they deserved.”) But courts don’t like hypotheticals. They want hard numbers.

Last year, they got them. Eric McGhee, a research fellow at the Public Policy Institute of California, has figured out a new way to think about gerrymandering: in terms of efficiency. With packing and cracking, the goal is to ensure your opponents’ votes are wasted, so they do not contribute to victory. A packed district has—artificially—too many votes for one side. A cracked district, too few. McGhee figured out how to calculate the “efficiency gap” of an election. Go district by district, counting how many votes the winner got above 50 percent—anything higher was a waste. Then count the loser’s votes, because all those went down the tubes. Add up all the waste by party statewide, then take the difference between the two numbers as a percentage of votes cast—that’s the efficiency gap. Yes, other factors could be at work—population change, let’s say. But in general, the bigger the gap, the more gerrymandered the state.

Best of all? “It’s fifth-grade math,” McGhee says. A judge could verify the calculations with a pencil and paper.

Indeed, the efficiency gap has already scored one major victory. In November a federal court relied in part on that formula to determine that Republicans had gerrymandered Wisconsin. Math: It works!

The data age is likely to spell trouble for gerrymandering. This skulduggery relies on geometry, geography, and demographic tables, precisely the domains where math nerds can give us clarity. Recently, Moon Duchin, a mathematician at Tufts University, realized her research in geometry—figuring out the average distances between points in various shapes—had a bearing on “compactness,” the legislative definition of what makes a fair district. Inspired, Duchin formed the Metric Geometry and Gerrymandering Group. Their program, which aims to train mathematicians in mapping and civil rights law so they can be expert witnesses in gerrymandering cases, was so flooded with applications—she expected dozens and got over 1,100—that Duchin is expanding the size. “My God, we’ve been just amazed at the response,” she says.

Actually, tech could fight gerrymandering in a lot of ways. The Public Mapping Project and programmer Dave Bradlee have created apps that let anyone redistrict a state, to see just how easy (or hard) it is to map fairly. I’d love it if a tech firm with a huge footprint—Google, Facebook, I’m looking at you—would take that idea mainstream and bring gerrymandering into the public consciousness. Make it a smartphone game! Possibly one with an outcome you could email to your representatives.

After all, the nation’s political maps will be redrawn in 2020, with new census numbers. The data of democracy is up for grabs. Thank goodness the mathematicians are watching.

This article appears in the May issue. Subscribe now.