North Carolina A&T State University is divided by the boundary line between the Sixth and Thirteenth Congressional Districts in Greensboro, North Carolina.Charles Mostoller / Reuters

When legislators gerrymander districts, they give one group more representation at the expense of others. For a long time, the Supreme Court has limited racial gerrymanders, but it has been on the fence about the constitutionality of partisan gerrymanders, in part because there’s no universally agreed-upon way to measure them. As mathematical diagnostic tools improve, however, the Court might find it difficult to pretend that it has no choice but to do nothing.

On Tuesday, the Court will take up two partisan gerrymandering cases, one out of North Carolina (based on a congressional map drawn by Republicans) and another out of Maryland (based on a congressional map drawn by Democrats). The politicians’ intentions were clear: They expressly admitted that they sought partisan advantage through the creative drawing of district lines.

But to what degree did they skew the results?

Just as either a plumb or a spirit level may be used by a carpenter to diagnose a crooked table, the courts (or other interested parties) can use a variety of tools to diagnose a crooked map—as Wesley Pegden, Jonathan Rodden, and I have argued in an amicus brief. Different circumstances, including whether the state “swings” or generally goes for one party, call for different gerrymandering tricks, and thus different tools.

In a closely divided state, partisans gain advantage by packing their opponents’ voters into as few districts as possible; that way, the opposing party can’t easily convert voter enthusiasm into added electoral victories. In North Carolina, Democratic candidates won seven of 13 districts with 57.1 percent of the vote on average in 2010. After redistricting, in 2012, they won four of 13 districts with 70.2 percent of the vote on average.

To distinguish the effects of gerrymandering from happenstance, courts can try one of several possible objective measurements, all based on district-level returns, including the lopsided-averages test, the efficiency gap, and partisan bias.

For the lopsided-averages test, just calculate the difference between the averages of interest (in this case, 70.2 percent minus 57.1 percent, or 13.1 percentage points), then figure out, using standard deviation, how probable it is that such a difference would occur naturally. It turns out that the jump between 2010 and 2012 would only have occurred by chance fewer than one out of 50 times. The same test can be used to compare Democratic and Republican wins from the same year, a way of determining whether one side is more packed than the other.

The efficiency gap refers to the fact that a party’s votes are used efficiently if they power many small victories across the board, and wasted if they contribute to large wins. In the case of North Carolina in 2012, the winning Democrats wasted 20.2 percent of votes on average (70.2 percent minus 50 percent plus one vote), whereas the winning Republicans wasted just 7.5 percent of votes on average (from an average share of 57.5 percent). Votes for losing candidates are considered wasted, and contribute to the efficiency gap as well. Taken across all districts, the net efficiency gap averaged out to 21.3 percent in favor of Republicans—one of the largest gaps in the nation. Compare that with 2010, when the efficiency gap was 12.3 percent in favor of Democrats. In just two years, redistricting caused a massive swing in the efficiency gap toward the party responsible for drawing the new map.

Partisan bias, used by political scientists since 1987, is calculated by extrapolating how many seats would be won by either side if the vote were perfectly split 50–50. In North Carolina, such a hypothetical would lead to three Democratic seats out of 13, or 23 percent. The partisan bias is 50 percent minus 23 percent, or 27 percentage points.

Opponents of districting reform have argued that the disparities described above are nothing more and nothing less than a result of where Democratic voters have chosen to reside. Republican strength in North Carolina wasn’t manufactured by Republicans, in other words, but by Democrats.

But computer-based techniques can show beyond a statistical doubt that a district-boundary map favoring one party over another did not arise by geographic accident. By taking an existing statewide map and making only small, random changes to it, it is possible to generate a multitude of alternative maps, nearly all of which are less favorable to the party that drew the offending plan. In this way, it can be shown that natural clustering alone does not explain the result—rather, natural clustering serves as the starting material for drawing an unnaturally skewed outcome.

District-packing is not the only way to gain a partisan advantage, of course. In a state where one party usually wins, the dominant party might try to spread out Democrats and Republicans evenly across many districts, thus making districts that are a political replica of the state as a whole—and freezing out the minority. This alternative strategy requires a different test, called a “chi-square.”

In brief, the courts could examine a state’s majority-party districts and calculate the standard deviation—a measure of how far individual wins tend to stray from the average—then compare it with the standard deviation for the party’s national wins. In Maryland in 2012, the Democrats’ standard deviation was fewer than 7 percentage points, considerably smaller than for Democrats nationwide, at 14 percentage points.

As the plaintiffs in the Maryland case argued, the Democratic mapmakers seemed to have systematically shuffled Republican voters out of the Sixth Congressional District, diluting those voters’ power and turning the district blue. This shuffling allowed Maryland Democrats to engineer near-identical wins in all but one district.

Gerrymandering isn’t just about math; it’s also about civil rights. My colleagues at Princeton, Ben Williams and Brian Remlinger, and I have sorted the various types of redistricting injuries into two major categories: inequality of opportunity and inequity of outcome. Inequality of opportunity means that voters don’t have a chance to elect someone to their liking. This can happen if they are packed into a single district, missing opportunities to elect multiple representatives, or if they are “cracked” between districts so they can’t elect anyone at all. Inequity of outcome simply means that the pattern of wins and losses is out of whack with what one would expect in a neutrally drawn scheme. Computer-based map simulations test both opportunity and outcome. These and other mathematical tests permit courts—in a rigorous, objective, and replicable manner—to assess whether an electoral map has violated the rights of a group of voters.

Whether the Supreme Court adopts any of these theories is likely to depend on Chief Justice John Roberts. He is not known for his love of math, and even referred to the efficiency gap as “sociological gobbledygook.” He has also expressed concern about getting inundated with gerrymandering lawsuits. After 2021, such cases could include Republican-controlled Florida and Georgia, as well as states under possible Democratic control, such as Minnesota and Virginia. But it seems likelier that setting a standard would deter offenses from occurring in the first place. If the Court fails to act, the alternative is the status quo: a veritable festival of gerrymandering.

The slowness of the Supreme Court to act has one silver lining. Partisan gerrymandering, which reached an all-time modern high in 2012, has led to a nationwide outpouring of bipartisan action. Reforms have passed in Colorado, Michigan, Missouri, Ohio, and Utah. Lawsuits based on state constitutions have led to the redrawing of maps in Pennsylvania and Florida state courts. Similar lawsuits may be forthcoming—and can make use of the mathematical diagnostic toolkit. By providing time for state-by-state action, the Supreme Court has allowed redistricting reformers across the country to discover both their inner Federalist and their inner mathematician.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.