Link to home
Start Free TrialLog in
Avatar of third
thirdFlag for Philippines

asked on

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.
Avatar of d-glitch
d-glitch
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
when in doubt use ( )
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.
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.
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
Ignore my last post, except for the HP link.
The answer is

23^2^

There are tons of converters on the web eg. http://webplaza.pt.lu/dostert/infixtopostfix.htm
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


Avatar of NovaDenizen
NovaDenizen

> 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.  
The TI-92, which allows entry of large equations using infix, evaluates 2^3^2 as 512.
Avatar of third

ASKER

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
Glad i could help

mlmcc