This calculator accompanies a blog post about how to fairly split cab fare.
Every rider pays the same amount.
Each rider pays the amount they contributed to the distance. This algorithm is order-dependent, so if the second passenger goes less far than the first then the second passenger will pay nothing.
We first calculate the savings from sharing as compared to the sum of the costs of separate rides. That savings is distributed equally among all riders.
Like equal discounts, but without the issue that short-riders sometimes profit instead of paying in. If a contribution would be negative, that rider pays $0.00 and their remaining savings is distributed among the other riders.
We first calculate the savings from sharing as compared to the sum of the costs of separate rides. That savings is distributed among the riders in proportion to their distances traveled. As a result, each mile costs the same amount.
While there are n riders in the cab, the fare for that segment is equally split n ways among them. When someone gets out, a new segment begins.
The riders pairwise satisfy the Nash bargaining solution. It's explained excellently by this Mathologer video. This algorithm achieves values given in a Talmudic example.