In HBO’s Silicon Valley, which was recently renewed for a second season on the air, a team of would-be tech zillionaires look to create a foundational technology. They want to make and sell a product that will come to underlie other technologies, and thus become an essential component of the working system as a whole. In the show, fictionally, the characters decide their best chance of creating such a “deep tech” solution is to make a new and powerful compression algorithm. In the real world, the show’s creators and consultants decided to do much the same thing.

In a move that roughly equals the nerdery that led Lord of the Rings artisans spend weeks on details that would never be on screen, technology consultants brought in to help with Silicon Valley decided to actually design the compression algorithm required for in the show. Stanford researchers Tsachy Weissman and Vinith Misra knew their algorithm had to be new and distinct from any real-world compression programs, and that it also had to be roughly credible to the show’s quite knowledgable audience.

“We had to come up with an approach that isn’t possible today, but it isn’t immediately obvious that it isn’t possible,” says Misra. “That is, something that an expert would have to think about for a while before realizing that there is something wrong with it.”

The incentives governing the design of the actual algorithm, called Pied Piper in the show, are interesting. The creators have to keep talk intelligible to the audience while also producing technical-looking flow charts to be splayed over the company’s various whiteboards. These issues and others led the creators to “lossy” compression, which sacrifices some detail in the name of file size, and then tried to extrapolate out to the most credible possible lossless solution that didn’t run afoul of any of the show’s other, more cinematic priorities. The final design does not attack hierarchical trees of data via either the “stem to leaf” or “leaf to stem” approaches, but with the a “middle out” approach.

Misra actually also created a wonderful (and explicit!) little “academic” paper about one of the show’s more lurid jokes. It’s definitely a labor of love, staffed by people who have as much genuine affection for their subject matter as any fantasy effects house. This is what happens when you give geeks some money and free rein to experiment: something awesome.