A mathematician has created a formula for the perfect long-distance relationship - and it's good news for couples who are willing to put in the effort