Formula offers guidance in how many relationships are needed before the ideal partner materializes. Mathematicians can't help themselves. They want to reduce everything to a formula. Even love.

So listen up, lonely hearts: With Valentine's Day approaching, if you are wondering how many relationships must come and go in your search for an ideal mate, there is a formula for that.

The solution uses probability calculus to figure out how to maximize the odds of choosing the best option from a series of prospects, which could include a string of dates, a pool of job applicants or, in one novel example, a field of portable toilets.

First published in 1960 by Scientific American, it has become known as the secretary problem or the marriage problem.

In the classic version, the prospects arrive one at a time and in random order, so each one's rank can only be judged relative to those who have come before. Ties aren't allowed, and rejections are final

"If you dump someone, that's it," said Kyle Siegrist, a professor emeritus of mathematics at the University of Alabama Huntsville.

The conundrum is whether to stick with someone who looks great now at the risk of missing out on someone better, or to keep playing the field and risk losing a good thing.

In mathematics, this is known as an optimal stopping problem.

It's all about timing. The goal is to choose when to take action to maximize reward and minimize cost, a theory that influences decisions about when to introduce products, exercise stock options or make capital investments.

The question here is at what point should the lovelorn stop searching and settle down?

"You could simply marry the first person you date, which, by the way, is almost never a good idea in mathematics or the real world," Dr. Siegrist said. "Or you could let the first person go by."

The best strategy, according to the formula, is to reject the first 37% of the prospects, then select the next person who is better than everyone in the initial group.

"You're using them to learn what qualities matter to you and what the range of quality is like in the population," said Neil Bearden, a professor of decision sciences at Insead, a graduate business school, in Singapore. "They're like a training set."

A simplified example includes three prospects. No. 1 is ideal, No. 2 is OK and No. 3 is the worst. The three can be ordered six different ways. To maximize the odds of choosing the ideal prospect, the best strategy is to dismiss the first option, no matter what, then choose the next one that is better. If none are better, the final option must be selected.

Using that tactic, the best of the three gets picked 50% of the time. No other strategy will produce better odds.

As the number of candidates increases, the probability of choosing the best one decreases—up to a point.

With 20 prospects, after rejecting the requisite number, the probability of choosing the best is around 38%. With 50 prospects, after the rejections, the probability of choosing the best is about 37%.

"The average person will think that if you had 1,000 candidates, the chances of choosing the best would be practically zero, but that's not true," Dr. Siegrist said. "You can essentially get the best person with 37% no matter how large the number of candidates."

There are clearly flaws with the concept. The rules prohibit recalling an earlier prospect, even though old flames sometimes are rekindled. Your first love might be the ideal mate. A carefully selected person could refuse a proposal. Or someone could be perfectly happy with a partner ranked lower than No. 1.

"If you end up marrying the second best person, life is probably not going to be rotten," Dr. Bearden said. "The classical version misses that."

Bothered by the problem's shortcomings, Dr. Bearden began testing variations. By accident, he noticed that a different threshold could maximize the probability of choosing a very good if not perfect prospect.

Instead of rejecting the first 37%, his formula supports rejecting the square root of the number of prospects before choosing the next best person.

"Decide what your acceptable number of dates is," he said. "Skip the square root of that number, and then really start looking seriously."

With 100 prospects, the first 10 would be rejected, rather than the first 37.

"You end up with someone who is quite high if you follow that simple prescription," he said.

In the case of marriage, second-best might not sound appealing. But slowing down the process addresses the inclination to rush into things.

"We did lots of experiments using good behavioral protocols to get people to take their decisions seriously," Dr. Bearden said. "Over and over and over again, they showed a tendency to stop searching too soon."

As the Supremes noted in 1966, you can't hurry love.