With his work at Yale, Stanley Milgram (Peter Sarsgaard) sets out to answer questions about compliance, as explored in “Experimenter.” (Courtesy of Magnolia Pictures)

The real-life experimenter at the heart of the docudrama that goes by that name is Stanley Milgram (1933-1984), a social psychologist who, in an infamous 1961 experiment at Yale, enlisted volunteers to test another subject’s memory with word games, then administer an electric shock for every incorrect response.

The twist was that the whole exercise was built on a sham. The person supposedly receiving the volts was an actor, hidden away in the next room, where he could be heard moaning and pleading after each wrong answer. Urged on by a calm man in a lab coat, the volunteers delivering fake shocks continued to follow orders, administering what they thought were increasingly painful punishments with each faulty reply, even after the man had grown entirely silent.

Now that’s some heavy stuff. But the film, written and directed by Michael Almereyda, turns it all into a heady, provocative entertainment. As Milgram, Peter Sarsgaard is perfectly cast as the analytical, emotionally reserved Bronx native who became interested in the theme of compliance during the trial of Holocaust mastermind Adolf Eichmann. Milgram wanted to know how genocide had been implemented so systematically. Why had so many people followed such barbaric orders?

Going into the experiment, Milgram’s colleagues didn’t believe the subjects would continue to increase the shocks, and yet, 65 percent of them did, regardless of sex, race and age. “Why is defiance the anomaly instead of the norm?” Milgram asks in the movie. And why does the word of a man in a lab coat — played by John Palladino — outweigh the desperate pleas of the “victim” (Jim Gaffigan)?

In this scene from the 2015 film "Experimenter," Stanley Milgram (played by Peter Sarsgaard) explains his electric-shock experiment to a class at Harvard. (Magnolia Pictures)

In real life, as in the film, Milgram’s findings led to both fame and controversy. His book, “Obedience to Authority: An Experimental View,” was turned into a 1976 television movie (“The Tenth Level”) starring William Shatner and Ossie Davis, played here by Kellen Lutz and Dennis Haysbert. But many of Milgram’s peers considered his methods troubling. Milgram’s findings may have been important, but to come to them he had to deceive people. What’s more, it was argued, by holding up a mirror to his volunteers’ shameful — if normal — behavior, he may have psychologically damaged people in the quest for truth.

Formally, “Experimenter” uses Brechtian techniques normally reserved for the stage. At times, Sarsgaard directly addresses the camera, breaking the fourth wall. Occasionally, he speaks to us while walking down a corridor with an elephant ambling along behind him. During other scenes, as when Milgram and his wife (Winona Ryder) are driving to a dinner party, the background becomes a two-dimensional black-and-white set.

The distancing effect invites us to view the subjects — played by a number of capable actors, including John Leguizamo, Taryn Manning and Anthony Edwards — in the same dispassionate way Milgram does: as specimens. Science isn’t an emotional undertaking. We’re supposed to consider what happens on a purely intellectual level. Of course, despair can only be held at bay so long.

“Experimenter’s” most striking quality is the way it encourages us to think deeply, from the first frame to the last, even if it’s just to consider what on Earth an elephant is doing on screen. That’s a welcome change, after a long summer of shoot-’em-ups and superheroes. The drama is also sprinkled with clever Easter eggs. Milgram’s office, for instance, is decorated with a print of Brueghel’s “Landscape With the Fall of Icarus,” a painting in which all of the characters ignore the fatal accident happening nearby.

Milgram conducted other experiments, too, which are dutifully chronicled here, but none made the impact of his obedience study. Scientists are still replicating it years later — and still coming to the same troubling conclusions. Meanwhile, systematic violence continues around the globe. As Milgram put it, “Human nature can be studied, not escaped.”

PG-13. At Landmark’s E Street Cinema. Contains brief strong language and troubling behavior that may make viewers lose faith in humanity. 90 minutes.