Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To calculate an average in reverse polish notation (RPN) is the following correct (assuming a-j are variables representing numbers):


If it is correct, are there other ways that this could be expressed in RPN?

share|cite|improve this question
It's much easier to read if you use space instead of comma. – TonyK Feb 6 '11 at 17:00
up vote 3 down vote accepted

This is correct. There are more ways to compute this but I would call your solution fairly canonical. For example, you could have started like this:


or like this:


However, these are fairly obvious variants and you are probably looking for a completely different way.

share|cite|improve this answer

It does work as correct, and if Zev is correct here (I think he is) there exist 4862 different ways of writing this average in RPN or PN, since there exist 4862 different ways of parenthesizing the part which just involves the addition symbols in infix notation.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.