Nearing a million views on YouTube is a four-minute clip of a lecture by Kurt Vonnegut. He draws two axes on a chalkboard: beginning to end, ill fortune to good fortune. When the hero rejoices, the graph goes up, and when he despairs, it nosedives. (It’s a little like those dials CNN gives focus groups.) Vonnegut sketches two basic stories: a rise-and-fall story he depicts as “man on hill” and its inverse, a U-shaped curve of redemption called “man in hole.” He wonders what technology might do with his thesis: “There’s no reason why the simple shapes of stories can’t be fed into computers.”

Matthew Jockers, a professor of “comparative text analysis,” was already working on sentiment mapping when he saw the Vonnegut clip and decided to take up the challenge. So last year he built a program that grouped more than 40,000 books into six essential plots. He added one more in a forthcoming book, co-written with Jodie Archer, called The Bestseller Code — a big-data take on why some books sell so much better than others. (The results conform roughly to Christopher Booker’s famous Seven Basic Plots — see below.)

The new book also has specific things to say about our most popular plots, including a section on the Girl books (gone, on the train, dragon-tattooed): All three put their girls into a hole and pretty much leave them there, subverting our expectations of a happy ending. But many blockbusters share a particular plot secret. The Da Vinci Code, for instance, reveals a pattern of ups and downs both dramatic and predictable — “a beating kind of regular rhythm,” as Jockers puts it (see below). Which may be familiar from your latest serial-TV binge session.

1. Comedy: A happy ending, with a speed bump (The Secret Life of Bees).

2. Tragedy: Comedy’s inverse (Bonfire of the Vanities).

3. Rags to Riches: Your basic coming-of-age story (Cinderella; Jane Eyre).

4. Rebirth: A more downbeat transformation (Wolf Hall; The Stand).

5. Voyage and Return: A roller-coaster adventure (Alice in Wonderland; The Road).

6. Quest: Two rises and a fall (The Corrections).

7. Overcoming the Monster: Classic man-in-hole (The Silver Linings Playbook).

50 Shades, Two Ways

From a bird’s-eye view, E. L. James’s BDSM best seller traces a classic “rebirth” arc; zoom in a bit more and you can see the chapter-by-chapter heartbeatlike pulse that Jockers says lies underneath the most compulsively readable stories.

*This article appears in the August 8, 2016 issue of New York Magazine.