NEW YORK ( TheStreet) -- Buying a home is a bet the future will be good -- and, for married folks, a bet the union will last. But often it doesn't, and dealing with a jointly owned home can be one of the most contentious issues in a divorce. What's the best way to do it?

It may come down to which party has the strongest will or the toughest lawyer. But Jack M. Guttentag, emeritus professor of finance at The Wharton School, suggests couples try a formula that ties each party's share of any sale proceeds to the share of cash put in over the years.

Of course, this assumes the home is sold. A different calculation would have to be done if the husband or wife kept the home, and that can get very complicated. A sale creates the simplest, cleanest break, because it's easier to apportion cash than to figure each party's stake if one stays and the other goes.

"Unless the couple can agree to accept the judgment of a neutral third party, it will have to be delegated to lawyers to negotiate, at which point the costs begin to mount," Guttentag writes on his website, The Mortgage Professor.

Assuming there is equity in the home -- cash left from the sale after the mortgage is paid off -- each party's share of the net proceeds can be calculated fairly easily if the couple has good records.

In Guttentag's example, a couple pays $100,000 for a home, with a $20,000 down payment and $80,000 mortgage, plus $3,000 in closing costs. After five years the couple splits and sells, with a loan balance of $74,000.

Together, the couple put in $23,000 at closing and $6,000 in principal payments -- $29,000. If one party had contributed 60% of the cash at closing and 40% of the principal payments, he or she contributed 60% of $23,000, or $13,800, and 40% of the $6,000, or $2,400. That $16,200 investment was 56% of the $29,000 put in. So this party would be entitled to 56% of any net proceeds from the home's sale.

This process can also be used if one party keeps the home. The calculation would determine how much cash the departing spouse is entitled to. The payment would be that party's share of the equity. In this case, the equity would be the difference between the home's current value and the remaining mortgage debt.

"Since the property is not being sold, its value must be based on an appraisal, which requires the parties to agree on who will select the appraiser, on who will pay for it," Guttentag says. "A clean break also requires that the departing party be removed from any existing mortgage obligation. This means that the remaining party must have the income and credit required to refinance the mortgage in her own name."

In some cases, especially if there is little equity, the spouse who leaves may simply want to be free of the mortgage obligation. Although the spouse who stays may be willing to take on the entire loan payment, the lender will continue to require that each spouse be responsible for the entire payment, if it was a joint loan to begin with. That's because the lender's risk will be greater if only one income is supporting the payment rather than two.