Andrew Paul Feinberg in his office at Johns Hopkins University School of Medicine. (Marvin Joseph/The Washington Post)

On a Monday, Jim Miller argued a case against the U.S. Department of Agriculture in federal appeals court. The next day, he took his biostatistics exam at Johns Hopkins University.

He won the appeal. He did not win the midterm exam — nor was his professor at all sympathetic that he been cramming to prepare for oral arguments in court, Miller said. But Miller was exhilarated by this dramatic career pivot, one that saw him walk away from decades of specialized legal work and enroll in school for the first time since the 1970s to earn a master’s degree in public health.

Like many people at various points in their careers — even the most successful — he had asked the question: Can I reinvent myself?

People in their 20s can switch majors, transfer, apply seamlessly to graduate schools as their interests evolve. They’re less likely to be tied to a job, a mortgage, a family — all the things that make dramatic change seem daunting, if not impossible.

“The younger you are, the easier it is, always,” said Patricia Rose, director of career services at the University of Pennsylvania.

But advances in technology have changed the calculation for older workers, leading some back to school to launch themselves on a new path in life.

“The speed of change is so rapid now that the kind of work that people do will be continuously reinvented,” said Steven Laymon, interim dean of continuing and professional studies at the University of Virginia. “Digital technology, the ubiquity of data and the globalization of work will be these evolutionary drivers that change people’s jobs on an ongoing basis.”

Sometimes those can be ­changes of lane or acceleration. And sometimes it will be a complete, gut-wrenching U-turn. The turn could be spurred by the market, a diagnosis, a lifelong dream, a conversation at a cocktail party, a revelation — one that could have profound impact far beyond a single person.

What drove Miller was a growing fascination with the science of the legal cases he was arguing, many involving pharmaceutical companies and the Food and Drug Administration. He felt he needed to know more. It had been so long since his undergraduate years that he had forgotten an entire year of biology. At 58, he took an entry-level biostatistics course. “It was a revelation,” he said.

He told his partners, who were dumbfounded, that he had been accepted at Hopkins and was leaving the firm. While his wife continued working, he found himself studying alongside people from all over the world, a young and idealistic group whom he found inspiring and refreshing after so many years in Washington. “I just cannot emphasize enough how fascinating I found epidemiology.

“I would say, ‘Do it,’ ” he said, to anyone who asked. “If you’re really interested in something, you ought to pursue that interest. That’s certainly what happened to me.”

It happened to Andrew Feinberg, too. Feinberg, a professor of medicine at Hopkins since 1994, was standing on Charles Darwin’s grave in Westminster Abbey a few years ago, surrounded by a crowd of other tourists looking at memorials of famous scientists, when an idea “just came flying into my head.”

Feinberg had just looked at a plaque honoring the physicist Paul Dirac, one of the founders of quantum theory, when he had the insight: that there might be, in biology, a built-in variability that’s a little like quantum theory. He immediately sensed that could explain something that he had long been trying to understand. It could, perhaps, help predict who would get cancer or other diseases.

It was an electrifying idea. But he needed to know more to explore it.

“I knew that what I was really interested in was how randomness and noise, this variability, how that could cause changes in a system, and make it suddenly behave in a different way,” he said. “But I didn’t know how to do it.”

Feinberg had studied math in college but left early to go to medical school. “And that’s the dark ages. I knew six programming languages, but they’re all dead now — there’s no way to code them.”

So he went back to school for a year. He took graduate classes in systems biology, and engineering and biostatistics and computing, doing the homework and taking the tests, with the other students in the class staring at him wondering, he said, “What’s with this — this — geriatric person?”

He never gave up his job. He kept running his lab. But he took a very big risk. His reputation as a pioneer in cancer epigenetics was somewhat on the line. And he gave up some funding, including a cancer research grant he had had his entire career.

“When you want to start over, embark on a new area of research in academia, it’s very difficult,” said Denis Wirtz, vice provost for research at Hopkins. “The research you’re doing is typically funded by the federal government or a private agency,” which often are more likely to support proven areas than radical new ideas.

Feinberg applied for a pioneer award from the National Institutes of Health designed to encourage high-risk, high-reward research, and that made it possible for him to go back to the classroom. Then he was given an endowed chair at Hopkins that allows him to have appointments in the medical school, the engineering school and the school of public health. Such positions are designed to give the capital that professors need “to break that Catch-22,” Wirtz said.

Sometimes people don’t realize their experience can be an asset, rather than a barrier to admission, said Janet Gilmore, a spokeswoman for the University of California at Berkeley. They may not need a new degree but instead could change gears with an additional course or certificate.

“If you want to do something different, let’s help you do something different,” said Sara Neher, assistant dean of MBA admissions at U-Va.’s Darden School of Business. The school has found many doctors, lawyers, engineers and teachers want a business degree.

The key is to make a compelling case for a pivot.

For Martin Johnson, a plastic surgeon in Arizona looking for a new direction at age 60 after chemotherapy left lingering numbness in his hands, the key was a desire to help a nonprofit group providing medical care in Central America. He wanted to better understand the complexities of the problems they are trying to solve. So he went back to school to study public health.

For Pauline Lubens, the desire to pivot came from an unexpected grief. She had been following an army sergeant after his return from Iraq, taking photographs documenting months of intense, emotional recovery from a traumatic brain injury. Then, the man died after a routine surgery.

Lubens felt lost, no longer sure that the work she did as a photographer mattered. She wanted to help families affected by war in a way that was more direct.

So she took a GRE test-prep course and, at 53, applied to Hopkins to get a master’s in public health. She quit her job, accessed some of her retirement money and took out student loans.

“Anyone in finance would tell me I made a horrible decision,” she said — and then the real estate market tanked while she was in school, upending her plan to pay off the loans with a line of credit on her house. Now she’s pursuing a doctorate, and teaching a class on war and public health, delving into issues such as the lack of drinking water in Syria. She lives in graduate-student housing in California and watches the interest mount on her loans, well aware that it’s difficult to find good faculty jobs.

But, she said: “I love it. It’s so exciting. I really fell in love with teaching. I fell in love with finding new ways of defining these important issues.” And there was something about starting over that made any bumps along the way easier to ride out.

“If you live long enough, you fail at a lot of things,” she said. “Or else you’re not really trying.”

Correction: An earlier version of this article stated that Jim Miller had been an undergraduate at Yale University. Although he holds a law degree from Yale, Miller received his undergraduate degree from New College of Florida.