The speedy theme song of "The Big Bang Theory," nicknamed "The History of Everything," gives new meaning to the term "nerd rock." The Barenaked Ladies ditty, which introduces TV's most popular comedy each week, is a serious earworm that was derived from equal parts good luck and hard work.

[Related: Why the Stars of 'Big Bang Theory' Deserve Big Bucks]

After reading Simon Singh's book "Big Bang: The Most Important Scientific Discovery of All Time and Why You Need to Know About It," lead singer Ed Robertson improvised a song about cosmological theory onstage during a show in Los Angeles. And who happened to be in the audience? "The Big Bang Theory" creators Chuck Lorre and Bill Prady, who were developing the awesomely geeky show at that moment. "They apparently looked at each other and said, 'These guys gotta write the theme song,'" Robertson dished in this behind-the-scenes peek at the making of the tune.

[Photos: 'The Big Bang Theory' Art Exhibition]

And the rest is history. OK, not quite. Lorre and Prady — who had already been discussing the action-packed "lyrical engineering," as Lorre put it, of the BNL hit "One Week" — contacted the band to create a song that encompassed everything that's happened since the beginning of time up to the present in 15 seconds. Not an easy feat, to say the least.

The original cut was 32 seconds, but it was trimmed before becoming the song "BBT" fans know and love. Also interesting, the first demo was an acoustic version with just Robertson, and Lorre loved it as it was. "That's it; we're done," he told Robertson on the phone, but the singer refused to go forward without his band mates. When Lorre heard the new version with the whole band, he loved it even more. "It was an unbelievably infectious piece of music," Lorre raved.

[Photos: Flip Through Pics From 'Big Bang Theory' Season 7]

Barenaked fact: When BNL visited the set of "The Big Bang Theory" to perform the tune and film a video for it, they piled out of the van completely naked and even ran onstage in the buff! "We already knew this was going to be an interesting day," Lorre said of that moment.

Also cool: Simon Helberg, who plays Howard Wolowitz, and Lorre lent their musical talents to the video. Helberg tickled the ivories, while Lorre showed off his killer guitar-playing skills. Speaking of theme songs and fun facts, Lorre wrote the iconic theme for "Teenage Mutant Ninja Turtles." Now, that's a handy bit of TV trivia.

Watch Helberg and Lorre rock out with the Barenaked Ladies on set:

By the way, if you ever wanted to memorize the "Big Bang Theory" theme, here are the lyrics:

Our whole universe was in a hot dense state,

Then nearly 14 billion years ago expansion started. Wait...

The Earth began to cool.

The autotrophs began to drool.

Neanderthals developed tools.

We built a wall (we built the pyramids).

Math, science, history, unraveling the mystery

That all started with the Big Bang!















"The Big Bang Theory" airs Thursdays at 8 p.m. on CBS.