The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

Infix interpretation
Message #1 Posted by Matt Agajanian on 18 Mar 2012, 2:09 p.m.

Here's an illustration in favor of RPN:

I cannot simulate super/subscript so imagine my examples written in the natural typography.

How would I know to interpret

       2
 sin  x   as X [SQ] [SIN] and not x [SIN] [SQ]  ?

Shouldn't x [SIN] [SQ] be written in tech notes, textbooks, etc as:

   2
sin  x  ?

On another note, what's clarifying

  3
-x as x  3 [y^x] [CHS] and not x [CHS] 3 [y^x]  ?

Edited: 18 Mar 2012, 2:37 p.m. after one or more responses were posted

      
Re: Infix interpretation
Message #2 Posted by Walter B on 18 Mar 2012, 2:19 p.m.,
in response to message #1 by Matt Agajanian

Hi Matt,

It will help if you use [pre] in formatting your text input. Please see here.

Edit: OK, you were faster in editing your mail than I was in pointing you to the link about formatting ;-)
Nevertheless, you're preaching to the choir emphasizing the advantages of RPN to the members of this forum IMHO.

Edited: 18 Mar 2012, 2:25 p.m.

            
Re: Infix interpretation
Message #3 Posted by Matt Agajanian on 18 Mar 2012, 2:34 p.m.,
in response to message #2 by Walter B

Okay, got it. My OP says what I want it to say. Thanks.

                  
Re: Infix interpretation
Message #4 Posted by Bart (UK) on 19 Mar 2012, 4:31 a.m.,
in response to message #3 by Matt Agajanian

When you are typing a message, below the message box are test formatting buttons, if you click "more" you can see a whole array of formatting marks you can use in your post (heading, underlines, super- and subscripts, lists etc.).

      
Re: Infix interpretation
Message #5 Posted by Dieter on 18 Mar 2012, 3:09 p.m.,
in response to message #1 by Matt Agajanian

Hi Matt,

Quote:
Shouldn't x [SIN] [SQ] be written in tech notes, textbooks, etc as:
   2
sin  x  ?

Well, actually it is. ;-)

The textbooks I know of use the common mathematical notation which is quite unambigous:

  • sin2x is the square of the sine of x
  • sin x2 is the sine of the square of x
  • -x3 is -1 times the cube of x
  • (-x)3 is the cube of -x
Although the one or other calculator manufacturer may claim that the user can enter expressions just the way they are found in the textbook, this usually is not true for cases like the ones you mentioned. At least I do not know of a device that accepts something like sin^2(x) instead of the transscription (sin(x))^2 that is also used in most programming languages. Or have I missed something?

Yes, of course that's an advantage of RPN. ;-)

Dieter

            
Re: Infix interpretation
Message #6 Posted by Marcus von Cube, Germany on 18 Mar 2012, 3:45 p.m.,
in response to message #5 by Dieter

Quote:
At least I do not know of a device that accepts something like sin^2(x) instead of the transscription (sin(x))^2 that is also used in most programming languages. Or have I missed something?
I just detected one: Derive 6 on Windows allows the entry of sin^2x which is then transformed to SIN(x)2. The interpretation of the latter is unambiguous because the opening parenthesis is tied to the function name SIN. The TI-92 which has a CAS that is supposedly derived from Derive doesn't allow this.
            
Re: Infix interpretation
Message #7 Posted by Kiyoshi Akima on 18 Mar 2012, 3:50 p.m.,
in response to message #5 by Dieter

Quote:
sin2x is the square of the sine of x

And of course sin-1x is the sine of x raised to the -1 power. Oh, no, that's csc x. The superscript -1 means something completely different in this case.

Does the power appear between the function name and its argument in anything other than trig (and hyperbolic) functions? Anyone ever seen something like ln2x ?

                  
Re: Infix interpretation
Message #8 Posted by Marcus von Cube, Germany on 18 Mar 2012, 4:03 p.m.,
in response to message #7 by Kiyoshi Akima

Quote:
Anyone ever seen something like ln2x ?
At least Derive accepts it as such.
                  
Re: Infix interpretation
Message #9 Posted by Walter B on 18 Mar 2012, 4:27 p.m.,
in response to message #7 by Kiyoshi Akima

Quote:
And of course sin-1x is the sine of x raised to the -1 power. Oh, no, that's csc x. The superscript -1 means something completely different in this case.
AFAIK, that use of superscript -1 for the inverse is special for trig and hyperbolic (and some more functions of advanced math). We were taught earlier its called e.g. arcsin - compare the HP-35 - or arcosh. Personally, I observed the notation tan-1 meaning arctan the first time on scientific calculators and remember it confused me - I think TI (horribile dictu) found a better solution with their key INV. Would be interesting to know who invented sin-1 = arcsin - any experts here from the old days?
                        
Re: Infix interpretation
Message #10 Posted by Kiyoshi Akima on 18 Mar 2012, 5:28 p.m.,
in response to message #9 by Walter B

And it can get really messy sometimes. I've seen sin-2x to mean the inverse of the square of the sine (csc squared), not the square of the arcsine or the arcsine of the arcsine.

            
Re: Infix interpretation
Message #11 Posted by Matt Agajanian on 18 Mar 2012, 4:50 p.m.,
in response to message #5 by Dieter

Quote:
Hi Matt,

Well, actually it is. ;-)

The textbooks I know of use the common mathematical notation which is quite unambigous:

  • sin2x is the square of the sine of x
  • sin x2 is the sine of the square of x
  • -x3 is -1 times the cube of x
  • (-x)3 is the cube of -x
Although the one or other calculator manufacturer may claim that the user can enter expressions just the way they are found in the textbook, this usually is not true for cases like the ones you mentioned. At least I do not know of a device that accepts something like sin^2(x) instead of the transscription (sin(x))^2 that is also used in most programming languages. Or have I missed something?

Yes, of course that's an advantage of RPN. ;-)

Dieter


But, what's preventing #3 from being interpreted as -x raised to the third power?

                  
Re: Infix interpretation
Message #12 Posted by Marcus von Cube, Germany on 18 Mar 2012, 4:55 p.m.,
in response to message #11 by Matt Agajanian

Current algebraic calculators have two different minus signs, unary and binary. Unary minus binds stronger than binary minus.

                  
Re: Infix interpretation
Message #13 Posted by Dieter on 18 Mar 2012, 5:33 p.m.,
in response to message #11 by Matt Agajanian

Quote:
But, what's preventing #3 from being interpreted as -x raised to the third power?
The missing parentheses.

By the way, in this case it doesn't matter - both expressions are equivalent since -(x3) equals (-x)3. ;-)

Dieter

      
Re: Infix interpretation
Message #14 Posted by Matt Agajanian on 18 Mar 2012, 4:48 p.m.,
in response to message #1 by Matt Agajanian

Thanks for the thorough analyses

      
Re: Infix interpretation
Message #15 Posted by Paul Dale on 18 Mar 2012, 5:29 p.m.,
in response to message #1 by Matt Agajanian

You can use [super]...[/super] and [sub]...[/sub] to get super and sub scripts.

- Pauli

            
Re: Infix interpretation
Message #16 Posted by Matt Agajanian on 18 Mar 2012, 6:21 p.m.,
in response to message #15 by Paul Dale

Thanks for the tip.

      
Re: Infix interpretation
Message #17 Posted by peacecalc on 18 Mar 2012, 5:33 p.m.,
in response to message #1 by Matt Agajanian

Hello Matt,

I miss another possible interpretation for

sin2(X) = sin(sin(X)) 

That is similar to the repeated useage of deriviation operator:

dn/dxn

Sincerely peacecalc

      
Re: Infix interpretation
Message #18 Posted by Nick_S on 20 Mar 2012, 3:27 a.m.,
in response to message #1 by Matt Agajanian

On a similar theme, yesterday I was looking at the differences in the order of evaluation of powers, which appears to be a potential trap.

In RPL:

'2^2^3' EVAL
1:        64

in R

2^2^3
[1] 256

and in Wolfram Alpha

2^2^3 =
Input:
223
Result:
256

Nick

Edited: 20 Mar 2012, 3:56 a.m.

            
Re: Infix interpretation
Message #19 Posted by Chris Randle (UK) on 20 Mar 2012, 12:49 p.m.,
in response to message #18 by Nick_S

I don't see the same result on my 50g:

'2^2^3' EVAL
256

but my 48SX:

'2^2^3' EVAL
64

Never noticed that before.

                  
Re: Infix interpretation
Message #20 Posted by Nick_S on 21 Mar 2012, 3:20 a.m.,
in response to message #19 by Chris Randle (UK)

I get a result of 64 on both my 28S and 48GX calculators. It is interesting to see that HP changed the order of evaluation for the 50g.

Nick

Edited: 21 Mar 2012, 3:21 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall