Mathematician Julius Barbanel of Union College, and political scientist Steven Brams of New York University, both in the US, have published the algorithm in Springer's The Mathematical Intelligencer.
The cut-and-choose method to share divisible goods has been regarded as fair and envy-free.
But what happens when more than two cuts can be made, or when people prefer different, specific sections of whatever is to be divided
Barbanel and Brams believe that with a giveback procedure it is possible to make a perfect division between two people that is efficient, equitable and void of jealousy.
An objective referee (such as a mom or a computer) is essential to the plan. The potential cake eaters first tell the referee which parts of the delicacy they value most.
In mathematical terms these are called someone's probability density functions, or pdfs.
The referee then marks out the cake at all points were the pdfs of the disgruntled would-be cake eaters cross, and assigns portions.
If at this point the two parties receive the same size of cake, the task is over. If not, the giveback process starts.
The party who received the larger part of the cake during the first round must give a part of it back to the other person, starting with those parts in which the ratio of their pdfs is the smallest.
This goes on until the parties value their portions equally, and have the same volume of cake to eat. This method only works with a finite number of cuts if the players' pdfs are straight-lined, or are so-called piecewise linear sections.
The researchers believe the method can be used to share cake and other divisible goods such as land.
In the case of beachfront property being co-owned by two developers, for example, it can help to determine who gets what strips of land to build on based on the pieces of land they value most.
"This allocation is not only equitable but also envy-free and efficient - that is, perfect," said Barbanel.