Sunday, 24 November 2013

Some math about tipping

I went to a restaurant with friends yesterday night and since service was not included, so we decided to tip 10% (I live in the UK!).

Restaurants account for tips separately when you pay by card (some card reader have a tip option). We all paid by card separately and shared the tip equally between us. Since it would be slow to tip every one of us, the tip was added at the end and I happened to pay last, so the tip for the whole dinner was paid by me.

This makes sense as we all paid the same amount, even if it looks like I paid a smaller amount with a huge tip, leading to funny receipts as this one:

math about tipping
"If you really liked the service, you don't just tip 10%, but 110%"

What is even funnier, though, is the peculiarity that the gratuity was almost exactly 10% of the sale plus the original price. 10% was also our original tip on the whole dinner, so I was wondering if this happened by pure chance or if there was a connection between these two numbers.

This can be easily solved by some math:

By setting these variables:

x - total price of the dinner
n - number of people with which the dinner is shared
t - tip (in percentage)

You can describe mathematically the different way in which tip can be payed:

$ \sum_{j=1}^{n} {\frac{x(1+t)}{n}} = x (1+t) $

$ (\sum_{j=1}^{n-1} {\frac{x(1+t)}{n}}) + (\frac{x(1+t)}{n}-xt)+xt = x (1+t) $

which is at each card payment, or at the end, respectively. This holds making the assumption that the tip $xt$ is smaller than the price paid for each person $x/n$:

$ t < \frac{1}{n} $

This is a simplification to make sure only the last person pays the tip. It can get more complicated, in cases where the last person pays part of the tip and second last pays a fraction of the remaining tip. But let's stick to the easy case!

For the last person, the total to pay each (Total in the receipt), minus the tip (Gratuity in the receipt) gives the Sale, as in the receipt. Expressing this mathematically:

$ \frac{x(1+t)}{n}-xt=\frac{xt}{1+t_{1}} $

Here, I have expressed the Sale, which is on the right hand side, as the untipped amount before applying a tip $t_{1}$, which gets us the Gratuity $xt$.

So, that's where we get our answer. We have observed the peculiar fact that $t=t_{1}$. Does this happen for any amount and number of people? Which is: does this happen for any $x$ and $n$?

You can immediately notice that x (being non-zero and positive) can be removed from any part of the equation. So this result does not depend on the amount spent.

Rearranging the equation above in $t$, we get a simple quadratic equation:

$ (2-n)t^2+(1-2n)t+1=0 $

This DOES depend on $n$, which means that the result depends on the number of people. As we require $t>0$ (negative tips?!) we can also check our solution:

Close enough!

You can see that the solution is for $t$ very close to 10%, the original amount of tip. You can notice that the result depends on $n$, which is the number of people.

In fact, if you try to change the number of people in the equation, you get different results for $t$ (smaller for bigger n, smaller for bigger n).

In conclusion, this shows that it was indeed a peculiar result of chance, and it depended on how many people shared their bill.

BONUS: from the numbers in the receipt you can find out how many people I was with yesterday and how much did we spend.