I was doing KenKen, a math puzzle, on a plane recently when a fellow passenger asked why I bothered. I said I did it for the beauty.

O.K., I’ll admit it’s a silly game: You have to make the numbers within the grid obey certain mathematical constraints, and when they do, all the pieces fit nicely together and you get this rush of harmony and order.

Still, it makes me wonder what it is about mathematical thinking that is so elegant and aesthetically appealing. Is it the internal logic? The unique mix of simplicity and explanatory power? Or perhaps just its pure intellectual beauty?

I’ve loved math since I was a kid because it felt like a big game and because it seemed like the laziest thing you could do mentally. After all, how many facts do you need to remember to do math?

Later in college, I got excited by physics, which I guess you could say is just a grand exercise in applying math to understand the universe. My roommate, a brainy math major, used to bait me, saying that I never really understood the math I was using. I would counter that he never understood what on Earth the math he studied was good for.

We were both right, but he’d be happy to know that I’ve come around to his side: Math is beautiful on a purely abstract level, quite apart from its ability to explain the world.

We all know that art, music and nature are beautiful. They command the senses and incite emotion. Their impact is swift and visceral. How can a mathematical idea inspire the same feelings?

Well, for one thing, there is something very appealing about the notion of universal truth — especially at a time when people entertain the absurd idea of alternative facts. The Pythagorean theorem still holds, and pi is a transcendental number that will describe all perfect circles for all time.

But our brains also appear to respond to mathematical beauty as they do to other beautiful experiences.

In a 2014 study, Semir Zeki, a neuroscientist at University College London, and other researchers used fM.R.I. scanners to observe the brains of 15 mathematicians while they were thinking about various equations. The subjects were shown 60 mathematical formulas two weeks before they were scanned and during and after the scan. They were also asked to rate their level of understanding of each equation and their subjective emotional response to it, from ugly to beautiful.

The researchers found a strong correlation between finding an equation beautiful and activation of the medial orbitofrontal cortex, a region of the prefrontal cortex just behind the eyes. This is the same area that has been shown to light up when people find music or art beautiful, so it seems to be a common neural signature of aesthetic experience.

Geeks, take heart: While you can’t see or hear mathematical ideas, they too are capable of arousing a sense of beauty.

No doubt you’d like to know which equation won the beauty contest. It was the so-called Euler’s identity, which is a deceptively spare but profound equation that links five fundamental mathematical constants: a mix of real and imaginary numbers that combine to make zero. And the ugliest? Ramanujan’s infinite series for the reciprocal of pi — a clunky equation, even to this non-mathematician.

While mathematicians were more likely to find formulas beautiful if they understood them well, the correlation was not perfect, so the researchers were able to show that the observed brain activation was a result of the experience of beauty apart from meaning. This makes sense, in that there were equations that subjects understood completely yet found ugly.

Now, the medial orbitofrontal cortex is also active when we find something pleasurable or rewarding, which isn’t surprising either, since you’d expect beautiful experiences to be both.

My love of math originated in the physical world. My father, an insatiably curious guy and electrical engineer, used to build things with me — crystal radios, electric generators, all kinds of exciting contraptions.

One summer evening I found him tinkering with a mysterious metal box in the garage. It was a prototype of a ruby laser. When he flicked the switch, a brilliant thin red light shot out of the laser and up into the night sky.

“How far does it go?” I asked. “To infinity,” he said and added, smiling, “or further.”

I was awe-struck. I still am.

**Richard A. Friedman** is a professor of clinical psychiatry and the director of the psychopharmacology clinic at the Weill Cornell Medical College, and a contributing opinion writer.