W. Marshall Leach, Jr. 
  
 
 
 Equation with parenthesis (1 + 2) * 3 Prefix notation * 3 + 1 2 or * + 1 2 3 Postfix notation 1 2 + 3 * or 3 1 2 + * Postfix notation has since become known as reverse Polish notation. In the HP implementation of rpn, the ENTER key is pressed between any two numbers that are not separated by an operation. The Algorithm
 ![]() Examples
 
 Example 1: Algebraic Expression (4 + 2 * 5) / (1 + 3 * 2) Reverse Polish Expression 4 2 5 * + 1 3 2 * + / HP Calculator Implementation X Y Z T 4 4 . . . ENTER 4 4 . . 2 2 4 . . ENTER 2 2 4 . 5 5 2 4 . * 10 4 . . + 14 . . . 1 1 14 . . ENTER 1 1 14 . 3 3 1 14 . ENTER 3 3 1 14 2 2 3 1 14 * 6 1 14 . + 7 14 . . / 2 . . . Reordered Algebraic Expression (2 * 5 + 4 )/(3 * 2 + 1) Reverse Polish Expression 2 5 * 4 + 3 2 * 1 + / HP Calculator Implementation X Y Z T 2 2 . . . ENTER 2 2 . . 5 5 2 . . * 10 . . . 4 4 10 . . + 14 . . . 3 3 14 . . ENTER 3 3 14 . 2 2 3 14 . * 6 14 . . 1 1 6 14 . + 7 14 . . / 2 . . . The answer is 2 for both methods. Note that the numbers never reach the T register in Method 2. 
 Example 2: Algebraic Expression [5 + 8 * sin(2 * 15)] / [2 + tan(45)] Reverse Polish Expression 5 8 2 15 * sin * + 2 45 tan + / HP Calculator Implementation X Y Z T 5 5 . . . ENTER 5 5 . . 8 8 5 . . ENTER 8 8 5 . 2 2 8 5 . ENTER 2 2 8 5 15 15 2 8 5 * 30 8 5 . SIN 0.5 8 5 . * 4 5 . . + 9 . . . 2 2 9 . . ENTER 2 2 9 . 45 45 2 9 . TAN 1 2 9 . + 3 9 . . / 3 . . . Reordered Algebraic Expression [sin(2 * 15) * 8 + 5] / [tan(45) + 2] Reverse Polish Expression 2 15 * sin 8 * 5 + 45 tan 2 + / HP Calculator Impelementation X Y Z T 2 2 . . . ENTER 2 2 . . 15 15 2 . . * 30 . . . SIN 0.5 . . . 8 8 0.5 . . * 4 . . . 5 5 4 . . + 9 . . . 45 45 9 . . TAN 1 9 . . 2 2 1 9 . + 3 9 . . / 3 . . . The answer is 3 for both methods. 
 Example 3: 
   Algebraic Expression [3 * ln(e^2) + 8 * cos(60)] / [3 * 4^0.5 - 1]
   Reverse Polish Expression 3 e ^2 ln * 8 60 cos * + 3 4 ^0.5 * 1 - /
   HP Calculator Implementation
			X	Y	Z	T
        3               3       .       .       .
        ENTER           3       3       .       .
        1               1       3       .       .
        e^x             2.718   3       .       .
        x^2             7.389   3       .       .
        LN              2       3       .       .
        *               6       .       .       .
        8               8       6       .       .
        ENTER           8       8       6       .
        60              60      8       6       .
        COS             0.5     8       6       .
        *               4       6       .       .
        +               10      .       .       .
        3               3       10      .       .
        ENTER           3       3       10      .
        4               4       3       10      .
        ROOT(x)         2       10      .       .
        *               6       10      .       .
        1               1       6       10      .
        -               5       10      .       .
        /               2       .       .       .
   Reordered Algebraic [ln(e^2) * 3 + cos(60) * 8] / [4^0.5 * 3 - 1]
   Reverse Polish e ^2 ln 3 * 60 cos 8 * + 4 ^0.5 3 * 1 - /
   HP Calculator Implementation
			X	Y	Z	T
       1                1       .       .       .
       e^x              2.718   .       .       .
       x^2              7.389   .       .       .
       LN               2       .       .       .
       3                3       2       .       .
       *                6       .       .       .
       60               60      6       .       .
       COS              0.5     6       .       .
       8                8       0.5     6       .
       *                4       6       .       .
       +                10      .       .       .
       4                4       10      .       .
       ROOT(x)          2       10      .       .
       3                3       2       10      .
       *                6       10      .       .
       1                1       6       10      .
       -                5       10      .       .
       /                2       .       .       .
   The answer is 2 for both methods.
 Home. 
  |