Committing to a partner is scary for all kinds of reasons. But one is that you never really know how the object of your current affections would compare to all the other people you might meet in the future. Settle down early, and you might forgo the chance of a more perfect match later on. Wait too long to commit, and all the good ones might be gone. You don’t want to marry the first person you meet, but you also don’t want to wait too long.

This can be a serious dilemma, especially for people with perfectionist tendencies. But it turns out that there is a pretty simple mathematical rule that tells you how long you ought to search, and when you should stop searching and settle down.

The math problem is known by a lot of names – “the secretary problem,” “the fussy suitor problem,” “the sultan’s dowry problem” and “the optimal stopping problem.” Its answer is attributed to a handful of mathematicians but was popularized in 1960, when math enthusiast Martin Gardner wrote about it in Scientific American.

In the scenario, you’re choosing from a set number of options. For example, let’s say there is a total of 11 potential mates who you could seriously date and settle down with in your lifetime. If you could only see them all together at the same time, you’d have no problem picking out the best. But this isn’t how a lifetime of dating works, obviously.

One problem is the suitors arrive in a random order, and you don’t know how your current suitor compares to those who will arrive in the future. Is the current guy or girl a dud? Or is this really the best you can do? The other problem is that once you reject a suitor, you often can’t go back to them later.

So how do you find the best one? Basically, you have to gamble. And as with most casino games, there’s a strong element of chance, but you can also understand and improve your probability of “winning” the best partner. It turns out there is a pretty striking solution to increase your odds.

The magic figure turns out to be 37 percent. To have the highest chance of picking the very best suitor, you should date and reject the first 37 percent of your total group of lifetime suitors. (If you’re into math, it’s actually 1/e, which comes out to 0.368, or 36.8 percent.) Then you follow a simple rule: You pick the next person who is better than anyone you’ve ever dated before.

To apply this to real life, you’d have to know how many suitors you could potentially have or want to have — which is impossible to know for sure. You’d also have to decide who qualifies as a potential suitor, and who is just a fling. The answers to these questions aren’t clear, so you just have to estimate. Here, let’s assume you would have 11 serious suitors in the course of your life.

If you just choose randomly, your odds of picking the best of 11 suitors is about 9 percent. But if you use the method above, the probability of picking the best of the bunch increases significantly, to 37 percent — not a sure bet, but much better than random.

This method doesn’t have a 100 percent success rate, as mathematician Hannah Fry discusses in an entertaining 2014 TED talk. There’s the risk, for example, that the first person you date really is your perfect partner, as in the illustration below. If you follow the rule, you’ll reject that person anyway. And as you continue to date other people, no one will ever measure up to your first love, and you’ll end up rejecting everyone, and end up alone with your cats. (Of course, some people may find cats preferable to boyfriends or girlfriends anyway.)

Another, probably more realistic, option is that you start your life with a string of really terrible boyfriends or girlfriends that give you super low expectations about the potential suitors out there, as in the illustration below. The next person you date is marginally better than the failures you dated in your past, and you end up marrying him. But he’s still kind of a dud, and doesn’t measure up to the great people you could have met in the future.

So obviously there are ways this method can go wrong. But it still produces better results than any other formula you could follow, whether you’re considering 10 suitors or 100.

Why does this work? It should be pretty obvious that you want to start seriously looking to choose a candidate somewhere in the middle of the group. You want to date enough people to get a sense of your options, but you don’t want to leave the choice too long and risk missing your ideal match. You need some kind of formula that balances the risk of stopping too soon against the risk of stopping too late.

The logic is easier to see if you walk through smaller examples. Let’s say you would only have one suitor in your entire life. If you choose that person, you win the game every time — he or she is the best match that you could potentially have.

If you increase the number to two suitors, there’s now a 50:50 chance of picking the best suitor. Here, it doesn’t matter whether you use our strategy and review one candidate before picking the other. If you do, you have a 50 percent chance of selecting the best. If you don’t use our strategy, your chance of selecting the best is still 50 percent.

But as the number of suitors gets larger, you start to see how following the rule above really helps your chances. The diagram below compares your success rate for selecting randomly among three suitors. Each suitor is in their own box and is ranked by their quality (1st is best, 3rd is worst). As you can see, following the strategy dramatically increases your chances of “winning” — finding the best suitor of the bunch: