Álvaro Nistal/Flickr (CC-BY-NC-ND 2.0) During your next summer cool down with ice cream, ponder the surprising history and science behind the frozen treat.

Or maybe not, because it's kind of gross.

Journalists Cynthia Graber and Nicola Twilley have pieced together a fascinating, science-infused origin story of ice cream in their latest episode of Gastropod, a podcast about food science and history.

As Gastropod explains, in 1558 Italian scholar Giambattista della Porta published the critical trick behind making smooth, rich ice cream: lowering the freezing point of water. He achieved this by mixing saltpeter into snow, using the slush to rapidly freeze a bucket of water. (Today we use table salt and ice.)

But Della Porta didn't invent ice cream. That happened when word of his method found its way into the kitchen of English noblewoman Lady Anne Fanshawe.

According to Gastropod, Fanshawe scribbled down what's arguably the earliest-known recipe for ice cream. Social historian and blogger Ivan Day personally discovered the recipe after sifting through some old books he won in an auction.

Here's Fanshawe's complete recipe for "icy cream," circa the 1660s (which is noticeably missing the salt part):

Take three pints of the best cream, boyle it with Mace, or else flavor it with orange flower water or ambergreece, sweeten the cream, with sugar[.] let it stand until it is quite cold, then put it into Boxes, either silken or firm then take, Ice chopped into small peeces and putt it into a tub and set the Boxes in the Ice covering them all over, and let them stand in the ice two hours, and the cream will come to be ice in the Boxes, then turne them out into a charger with some of the same Seasoned cream, so serve it up to the Table.

I bolded the part with "ambergreece" — spelled "ambergris" today — because it's very strange and repulsive stuff.

A hunk of ambergris. Smithsonian National Museum of American History Ambergris might sound familiar if you've ever read Herman Melville's "Moby Dick." Here's how the character Ishmael describes it in the novel:

[A]mbergris is soft, waxy, and so highly fragrant and spicy, that it is largely used in perfumery, in pastiles, precious candles, hair-powders, and pomatum. The Turks use it in cooking, and also carry it to Mecca, for the same purpose that frankincense is carried to St. Peter's in Rome. Some wine merchants drop a few grains into claret, to flavor it.

Ambergris is in Moby Dick, of course, because sperm whales make it.

Adult sperm whales hunt and eat hundreds of pounds of squid in the darkest depths of the ocean every day. Squid have tough beaks and other indigestible parts, though, so whales vomit up the extra gunk every couple of days.

But in about 1% of sperm whales, author Christopher Kemp details in his book "Floating Gold," a digestive defect allows the hard squid parts make their way into the whale's bowels — where they get stuck and block the intestinal tract.

Here's how Kemp describes what happens next to the blockage:

Feces build up behind it. The whale's gastrointestinal system responds by increasing water absorption from the lower intestines, and gradually the feces saturating the compacted mass of squid beaks become like cement, binding the slurry together permanently. ... Temporarily, feces make their way past it again, passing between the boulder and the wall of the intestines. And, slowly, the process repeats, adding additional strata to the boulder, which grows larger with each new layer in the same way that a tree grows, adding a new growth ring with each passing year.

No one really knows if lumps of ambergris eventually kill sperm whales, or if the animals manage to eventually... pass the stuff.

Whatever the case, when the ambergris breaks free of its whale prison, it floats to the top of the ocean, cures in the salt and the sun, and gets discovered by adventurous humans. Today ambergris finds its way into museums and onto auction blocks: Pieces that weigh about 1 lb can fetch tens of thousands of dollars for their use in expensive perfumes (mostly the French variety, since ambergris has "sweet, woody odor").

So how does ambergris ice cream taste?

Graber and Twilley tracked down historical gastronomist Sarah Lohman, who made some of Fanshawe's signature custard for the show.

"It was really, really, really good," Twilley said. "To me, it felt kind of like vanilla, in that it was sort of a background thing. But then it was so much more complex tasting than vanilla. It was like vanilla on drugs."

Listen to their full reaction in Gastropod's complete episode, below — along with some surprising and scientific twists and turns in the history of ice cream.