Monday, August 24, 2009

Algebra in real life, part II

This post is dedicated to the memory of Mr. Earl Wog, who taught us about Joe Pythagoras and also taught me how to drive. :)

I've needed to know this two different times in the last six months or so, and had to figure it out from scratch both times, so it's time to document it for posterity.

When you're trying to get payment from somebody via, say, an online credit card processor such as PayPal, and the processor takes a percentage of the total transaction as its transaction fee, how much do you need to charge in order to receive the amount of money you actually want? Here is the correct formula:

[amount you want to receive] ÷ ( 1 - [fee, as a decimal] )

The following, seemingly plausible formula does not work, and will result in you receiving less money than you wanted:

[amount you want to receive] + ( [amount you want to receive] × [fee, as a decimal] )

Pro tip! If you accidentally used the second formula instead of the first one, don't make an indignant post in the credit card processor's user support forums demanding to know why they're shorting you.

Thanks, Mr. Wog, wherever you are!

Update: I received a suggestion that the following formula may also yield the desired result:

[amount you want to receive] × ( 1 + [fee, as a decimal] )


x(1+y) == (x × 1) + (x × y) == x + xy

which is the same as the second formula above and isn't correct. Thanks to GAM for helping me with the proof on this. Make no mistake, my algebra skillz are tenuous and that's why I have to struggle through formulas and post them on my blog. :)

No comments: