You press a button and wait for your elevator. How long before you get impatient and agitated? Theresa Christy says 20 seconds.

As a mathematician steeped in the theories of vertical transportation at Otis Elevator Co., Ms. Christy, 55, has spent a quarter-century developing systems that make elevators run as perfectly as possible—which means getting most riders into a car in less than 20 seconds. “Traditionally, the wait time is the most important factor,” she says. “The thing people hate the most is waiting.”

Developed in the 19th century, elevators transformed urban living, real estate markets and skylines around the world. As an Otis research fellow, Ms. Christy gets to work on the toughest problems and on signature projects like the 1,483-foot-high Petronas Towers in Malaysia, for a time the world’s tallest building.

During the recent $550 million upgrade of the Empire State Building, Ms. Christy was asked whether she could help get more people up to the observation deck. She said she couldn’t get more people into a car but could move them up more quickly. So she increased the elevators’ speed by 20%, to 20 feet per second. Now the cars can rise 80 floors in about 48 seconds, 10 seconds faster than before.

Rather than having riders wait for the first available car, Otis Elevator’s Compass system has riders input the floor they want by keypad or touch screen. They are then told which car to take. The result: a more orderly lobby and a faster ride.

Ms. Christy strikes down one common myth—that “door close” buttons don’t work. Sometimes they do, sometimes they don’t, she says. It depends on the building’s owner.

The challenges she deals with depend on the place. At a hotel in the holy city of Mecca in Saudi Arabia, she has to make sure that the elevators can clear a building quickly enough to get most people out five times a day for prayer.

In Japan, riders immediately want to know which car will serve them—indicated by a light and the sound of a gong—even if the elevator won’t arrive for 30 seconds. That way, people can line up in front of the correct elevator.

Japan also boasts, in Ms. Christy’s opinion, the smoothest, best-riding elevators. “When you get into an elevator there, you sometimes think you are ‘stuck’ in the elevator because the motion is so smooth and quiet,” she says. But that service comes with extra costs and slower speeds.

Another problem: How many people fit in an elevator? In Asia, more people will board a car than in Europe or New York, Ms. Christy says; Westerners prefer more personal space. When she programs an elevator system she uses different weights for the average person by region. The average American is 22 pounds heavier than the average Chinese.

At their core, elevators are a mode of transportation. Serving passengers well is constrained by the number of elevators, their speed, how fast their doors open and close, and how many people can fit in a car. In the U.S., these factors come together 18 billion times a year, each time a passenger rides an elevator.

That experience is at the heart of what Ms. Christy does. From her sparse second-floor office in a leafy office park in Farmington, Conn., she writes strings of code that allow elevators to do essentially the greatest good for the most people—including the building’s owner, who has to allocate considerable space for the concrete shafts that house the cars. Her work often involves watching computer simulation programs that replay elevator decision-making.

“I feel like I get paid to play videogames. I watch the simulation, and I see what happens, and I try to improve the score I am getting,” she says.

Here is a typical problem: A passenger on the sixth floor wants to descend. The closest car is on the seventh floor, but it already has three riders and has made two stops. Is it the right choice to make that car stop again? That would be the best result for the sixth-floor passenger, but it would make the other people’s rides longer.

For Ms. Christy, these are mathematical problems with no one optimum solution. In the real world, there are so many parameters and combinations that everything changes as soon as the next rider presses a button. In a building with six elevators and 10 people trying to move between floors, there are over 60 million possible combinations—too many, she says, for the elevator’s computer to process in split seconds.

“We are constantly seeking the magic balance,” says the Wellesley math major. “Sometimes what is good for the individual person isn’t good for the rest.”

A named inventor on 14 patents, Ms. Christy has a few more pending. She refers to the latest of them as the “surfboard feature.” The idea came from a joke with colleagues when they were leaving one night after a dinner out. They sheepishly worried whether someday elevators might display a rider’s weight. (Elevators already calculate the total weight in the car.)

The joke got Ms. Christy thinking of a feature that would allow people with a bulky or heavy item to have a car to themselves. So she and her colleagues created a system that can be programmed to allocate an empty car to a user. The feature would give users like hotel bellhops a numeric code that is punched in before entering the elevator. (A hotel in Hawaii considered using it to prevent surfers from disturbing other guests with their surfboards—hence its name.) The feature is generally used now by staff in hotels and office buildings.

One part of Ms. Christy’s career didn’t go as planned. With aspirations of getting into management, Ms. Christy got her M.B.A. from Babson College, but the role didn’t suit her. “I thought I wanted to be a manager,” she said. “But I really like solving the puzzles myself. I didn’t like assigning them to other people. I was a little jealous.”