Infix to Postfix

how do you convert infix to postfix in case of exponents?

is 2^3^2 in postfix

23^2^

or

232^^

quite confused on this. thanks.
LVL 30
thirdAsked:
Who is Participating?
 
mlmccCommented:
Actually the exponent has priority in this case.

2^3^2 = 2^(3^2) = 2^9 = 512

Therefore the second is correct.

mlmcc
0
 
d-glitchCommented:
2^3^2 = (2^3)^2 = 8^2 = 64

The first is correct

(23^)2^  = 82^  = 64

But  232^^  = 2(3^2)^ = 2 9^ = 512
0
 
d-glitchCommented:
Matlab does infix calculatiosns.  Here is a screen paste:

>> 2^3^2

ans =

    64

My HP calculator does postfix

    23^2^  = 64

The two  exponent operators have equal precedence, so you work left to right.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
snoyes_jwCommented:
Type 2^3^2 into Google, and it restates it as 2^(3^2), which is 512.
The Windows calculator, which enforces order of operations (at least, entering 2+3*4 results in 14, not 20) says 64.
0
 
aburrCommented:
when in doubt use ( )
0
 
aburrCommented:
calculators use two main types of arithmatic which will produce different results if ( ) are not used.
TI calculators (and most others) use standard algrbraic operations.
HP and a few others use reverse polish notation which does operations in a different order if ( ) are not used.
0
 
aburrCommented:
23^2^

or

232^^

On an HP calculator the last line would not work.
You use
2 enter
3 ^
2^
and the result is 64.
In your last line you have two operators in a row, which procedure does not work.
In your first line your notation is difficult in that you do not know whether you are dealing with 2 and 3 or 23. You could develop a computer program which would take care of this particular problem but you would still hve a problem with longer first numbers.
0
 
d-glitchCommented:
There is a cute HP Calculator online:       http://www.hpmuseum.org/simulate/hp35sim/hp35sim.htm

Two operators in a row is not a problem.  You do have to use enter twice to terminate digit entry.

2
Enter
3
Enter
2
y^x          Returns 8
Y^x          Returns 64
0
 
d-glitchCommented:
Ignore my last post, except for the HP link.
0
 
GwynforWebCommented:
The answer is

23^2^

There are tons of converters on the web eg. http://webplaza.pt.lu/dostert/infixtopostfix.htm
0
 
d-glitchCommented:
Part of the reason this is confusing is that your example is symmetric:

2^3^5  =  (2^3)^5  =  32768

2 3 ^ 5 ^  =  32768   on my HP-15C  where the exponential function is y^x


5 3 2 ^ ^  =  32768   on the HP-35  where the exponential function is x^y


0
 
NovaDenizenCommented:
> how do you convert infix to postfix in case of exponents?
> is 2^3^2 in postfix
> 23^2^
> or
> 232^^

It depends on whether you have defined your exponent operator as left-associative or right-associative.  I don't think there's any  authoritative answer on this.  Without defining your exponent operator as left-associative or right associative, a^b^c results in an ambiguous expression.

Take a look at http://mathworld.wolfram.com/ExponentLaws.html .   Notice that there are no expressions like x^y^m.  However, there is an expression like (x^m)^n.  
0
 
snoyes_jwCommented:
The TI-92, which allows entry of large equations using infix, evaluates 2^3^2 as 512.
0
 
thirdAuthor Commented:
i guess i would go for 232^^ = 512

i found these websites and a book saying that exponents are evaluated right to left.
http://www.reed.edu/~mcphailb/applets/calc/
http://www.qiksearch.com/javascripts/infix-postfix.htm
0
 
mlmccCommented:
Glad i could help

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.