▼
Posts: 64
Threads: 8
Joined: Oct 2006
One of my technicians brought a math problem to me yesterday. He was working a total harmonic distortion issue, and his numbers weren't what he expected. In the end, he was having an order of operations problem.
While resolving his problem, I noticed some interesting disparities between technologies:
Here are the results from a TI 83+
10^(-2)^2 = .0001
From Wolfram Alpha:
10^(-2)^2 = 10,000
On the HP35s, in algebraic mode I got:
10^(-2)^2 = .0001
On the HP50g
'10^(-2)^2' evaluates to 10,000
While I do appreciate the power of a machine that addresses the order of operations, I've yet to encounter enough consistency in application to allow me to be comfortable trusting this process completely to my hand held device.
I cannot find consensus even within the HP handheld with built-in algebraic entry.
My rational for preferring RPN/L to any other entry method is: I like my devices to do the arithmetic while I do the math.
This is simply my opinion, and other opinions are always welcome,
Very respectfully,
David
▼
Posts: 4,587
Threads: 105
Joined: Jul 2005
Posts: 429
Threads: 31
Joined: Jul 2011
What is the correct way then: from inside out or from outside in?
▼
Posts: 64
Threads: 8
Joined: Oct 2006
I don't have a reference to site, but I think you almost have to work from the inside out. If you try to work from the outside, you end up with a lot of, "But I got to do this first"... until you end up smack dab in the middle crunching your way out.
I'm sure there is a more technical way of saying that, but that's how it adds up, no pun intnended, in my head,
Very respectfully,
David
Posts: 260
Threads: 0
Joined: Oct 2008
We have to be very carefull when writing in-line algebraic expression.
10^(-2)^2 is as much ambigus as 3/2(1+3) because incomplete notation can lead to a bunch of different interpretations.
Only correct practices may guard from ambigus interpretation. Whatever the way from inside out or from outside in, a correct written expression will lead to the same result.
If you have to consider the way to sparse data, you no more in the world of algebra, you already are in the word data processing environement.
10^(-2)^2 = ? ? ? ?
Edited: 29 Mar 2012, 4:36 a.m.
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
We have to be very carefull when writing in-line algebraic expression.
10^(-2)^2 is as much ambigus as 3/2(1+3) because incomplete notation can lead to a bunch of different interpretations.
I don't see any ambiguity in both expressions - there are clearly defined rules of precedence:
1) expressions in parentheses (...) first
2) operations with higher priority first (i.e. ^ before *,/ before +,-)
3) operations with the same priority from left to right (with one exception: ^ from right to left,
i.e. a^b^c = a^(b^c))
So 10^(-2)^2 is definitely 10^((-2)^2)=10^4=10000 and 3/2(1+3)=(3/2)*(1+3)=1.5*4=6
Edited: 29 Mar 2012, 5:28 a.m.
▼
Posts: 429
Threads: 31
Joined: Jul 2011
Quote:
(with one exception: ^ from right to left)
Actually, I also only just found out, that the double up-arrow operator defined by Donald Knuth (the TeX guy) is another exception in being right-assoziative as well.
Posts: 260
Threads: 0
Joined: Oct 2008
Quote:
I don't see any ambiguity in both expressions - there are clearly defined rules of precedence:
1) expressions in parentheses (...) first
2) operations with higher priority first (i.e. ^ before *,/ before +,-)
3) operations with the same priority from left to right (with one exception: ^ from right to left,
i.e. a^b^c = a^(b^c))
So 10^(-2)^2 is definitely 10^((-2)^2)=10^4=10000 and 3/2(1+3)=(3/2)*(1+3)=1.5*4=6
I am sorry not to agree with you. But, this will not prove you are wrong. Au contraire !
By following your rules I have understand why you don't see any ambiguity. Especially rule 3) is of great help to resolve the ambiguity I saw.
But, I am no computer scientist. The rules I use in algebra expression are a bit older than yours. There is no general direction in case of operator of the same priority.
In the rule I was instructed to follow, the sentences only specify that, in the case of equal priority operators, a vinculum have to be used in order to dissolve any ambiguity.
Quote:
Priority rules I was instructed to follow in publications are:
1. The calculations contained in parentheses (or brackets) take precedence over the calculations outside of the parentheses. The fraction bar or the square root bar act as a pair of parenthesis;
2. The exponent takes priority over multiplication, division, addition and subtraction;
3. The multiplication and division take priority over addition and subtraction;
4. Any ambiguity has to be removed by the use of a delimiter (the vinculum, the point or parenthesis) and a spatial organization of the expression.
As more and more algebra are type in computer and calculator, these old style rules of algebra and mathematics’ publications have been supplanted by ‘Data Processing Rules’ style or fashion.
But having a specific direction of evaluating expression from right to left (or inversely from left to right), or from inside – out (or inversely from outside – in) has never been a commonly accepted or applied universal convention. In contrary, the purpose of the most universally followed rules in paper publications is that, whatever are the way (the direction) the reader process, he will get the same result or expression.
Oppositely it is a really common, quite universal, in most of programming languages to have a rule indicating in which way (direction)the expression have to be process or evaluated.
In conclusion, I am not surprise that today well computer educated peoples from this actual millennium encounter or see no ambiguity at all in the abscond and badly delimited expressions such a as the above 10^(-2)^2 or 5/2(3+1).
Whereas an old fashion XXth century scientist will find these expression ambiguous and badly formatted.
▼
Posts: 2,448
Threads: 90
Joined: Jul 2005
You are correct, both from the standpoint that these are data processing issues not algebra issues and secondly but no less importantly, hat data processing rules are now being confounded with the rules of algebra!
For anyone suffering from ambiguity of a written expression, I recommend reading a maths textbook, not a calculator manual--and then when dealing with a calculator, RTFM41 that manual!
Posts: 64
Threads: 8
Joined: Oct 2006
In my opinion, the "in-line algebraic expression" is the culprit here. While orders of operation, left to right, right to left, out-side in, in-side out can vary depending on application; I believe there is little ambiguity when an the expression is re-written as such:
10(-2)2
Which, coincidently, is exactly what the HP50g displays in the stack when I enter '10^(-2)^2'
On my first attempt to demonstrate this to my co-worker, I entered '10^-2^2' which put the following on the stack:
10(-22)
Some may say there is still ambiguity in the notation above (whether it means minus 2 squared or the square of negative 2), but it agrees with the instruction I received in school and still subscribe to. I did have to do a double take, but in the end I quickly saw my error.
In either case, the possibility of my handheld device CAUSING an error by using a different than expected interpretation is eliminated by using the command line or the X register as a grouping symbol.
I'm humbled by the thoughtful responses on this forum. I've never read a thread and failed to learn something,
Very respectfully,
David
Posts: 408
Threads: 45
Joined: Oct 2007
With RPN, it's always working from inside to outside. parenthesis- free.
Posts: 125
Threads: 9
Joined: Oct 2011
I gave a similar comparison in this thread here:
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv021.cgi?read=214739#214739
It turns out that there are even differences within the RPL family
with your example, the HP-28s and 48GX calculators return a value of 0.0001
The R language on the other hand returns the result of 10000
Nick
Edited: 29 Mar 2012, 4:51 a.m.
▼
Posts: 64
Threads: 8
Joined: Oct 2006
Your example hits the nail on the head. Using the stack as a vinculum eliminates all doubt about the desired operand for a desired operation. For example, -2 in the stack followed by x^2 always results in 4, not -4.
Thanks to everybody for sharing their examples and perspectives,
Very respectfully,
David
Posts: 591
Threads: 16
Joined: Feb 2012
Quote: I like my devices to do the arithmetic while I do the math.
Could not express this better.
▼
Posts: 42
Threads: 5
Joined: May 2011
Quote:
I like my devices to do the arithmetic while I do the math.
That is indeed a great quote that summarise the difference of using RPN: you know what you are doing.
I think actually RPN should be the only allowed in schools, as it has a lot more educational value than all those "Textbook Format Display", "Writeview", "Natural TextBook Display", "MultiView" etc.
▼
Posts: 591
Threads: 16
Joined: Feb 2012
Ditto! I support with no restrictions.
Edited: 29 Mar 2012, 9:53 a.m.
Posts: 980
Threads: 239
Joined: Aug 2006
In the tone of the Narnian Dufflepuds, "Well said! Well put!" Check out the article in Volume 5 of the HP Digest entitled "How Programmable Calculators Help Kids Learn"by Dr. John J. Wavrik. You'll find it quite a comprehensive approach to supporting RPN and using its concepts and using calculators to better grasp and understand math concepts.
Edited: 29 Mar 2012, 10:37 a.m.
Posts: 429
Threads: 31
Joined: Jul 2011
Quote:
On the HP50g
'10^(-2)^2' evaluates to 10,000
The odd thing about the 50g is that it yields
10^(-2)^2 after ENTER and 10000 after EVAL. But with
'10^-2^2' yields 10^(-2^2) after ENTER and 1/10000 after EVAL.
Note that the - in both cases is the unary operator on the key [+/-]. I would have thought that with the unary - the parentheses would not be needed and both expressions should evaluate to the same.
▼
Posts: 1,089
Threads: 32
Joined: Dec 2005
Quote: But with
'10^-2^2' yields 10^(-2^2) after ENTER and 1/10000 after EVAL.
Note that the - in both cases is the unary operator on the key [+/-]. I would have thought that with the unary - the parentheses would not be needed and both expressions should evaluate to the same.
The expression -2^2 reads as 0-2^2 = -4, no matter which keys were used, unless the 50G has a special character to identify this 'unary minus' concept. If not, it should automatically place parantheses around minus and the rightmost variable/number to reflect what the user probably intended.
Best thing would be to forbid CHS when writing algebraic expressions.
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
The expression -2^2 reads as 0-2^2 = -4
Another explanation is that -2 is in fact (-1)*2 and thus the operation ^ has priority over this (implicite) * in the expression -2^2 = (-1)*2^2.
▼
Posts: 1,089
Threads: 32
Joined: Dec 2005
Quote:
Another explanation is that -2 is in fact (-1)*2 and thus the operation ^ has priority over this (implicite) * in the expression -2^2 = (-1)*2^2.
But:
(-1) * 2 = 2 * (-1)
;-)
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
But:
(-1) * 2 = 2 * (-1)
;-)
Hmmm? What do you want to say with this? I don't get it ... :(
▼
Posts: 1,089
Threads: 32
Joined: Dec 2005
Quote:
Hmmm? What do you want to say with this? I don't get it ... :(
If you argue just with the higher preceedence of the exponentiation over multiplication, it stops working as soon as you commute it, i.e. 2*(-1)^2 = 4
Don't take it too serious.
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
If you argue just with the higher preceedence of the exponentiation over multiplication, it stops working as soon as you commute it, i.e. 2*(-1)^2 = 4
Don't take it too serious.
You're right, I really can't take this serious at all because it's just nonsense.
Or would you say that a+b*c = b+a*c just because + is commutative???
It's exactly the higher precedence of * over + (or of ^ over * in the example above) why you can't apply the commutative law here.
▼
Posts: 1,089
Threads: 32
Joined: Dec 2005
Calm down, Franz.
This is what I refer to:
Quote: Another explanation is that -2 is in fact (-1)*2 and thus the operation ^ has priority over this (implicite) * in the expression -2^2 = (-1)*2^2.
Rewrite your sentence to:
Quote: Another explanation is that -2 is in fact 2*(-1) [...]
... (which is equal) and you will see where you're mistaken in the following argument, which I have adapted to the above:
Quote: [...] and thus the operation ^ has priority over this (implicite) * in the expression -2^2 = 2*(-1)^2.
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
Calm down, Franz.
Oh, I'm so calm, calmer "geht's nicht mehr". ;-)
At least now I finally understand what you had in mind.
Since the - sign in -2 is called Vorzeichen in German (not Nachzeichen), so I'd say (-1)*2 is more logical than 2*(-1). :-)
But the true mistake on your side is the following:
In -2^2 the - sign doesn't 'belong' to the first 2 but to the whole expression 2^2, so if you would really apply the commutative law then it should be -2^2=(-1)*2^2=2^2*(-1) and not (2*(-1))^2.
Franz
Edited: 29 Mar 2012, 10:57 a.m. after one or more responses were posted
▼
Posts: 52
Threads: 9
Joined: Mar 2008
To all:
Interesting thread, as everyone spouts off about entry methods and math "rules".
My approach would be:
Which "answer" makes sense in view of the problem / question ?
Just a thought from an unschooled, but active mind.
Have a great day, everyone !
John
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
My approach would be:
Which "answer" makes sense in view of the problem / question ?
Well, take the example -2^2:
Would you say that one of the two answers (4 or -4) "make more sense"?
I don't think that math expressions should "make sense" other than being exact and unique, and exactly for that reason we have math rules.
If not then everyone would have his own interpretation of "making sense". ;-)
Posts: 260
Threads: 0
Joined: Oct 2008
Wieder Einmal, gibt es keine Zweideutigkeit.
Sicher ?
-2^2 is another one I have to add in my personal list of ambiguous expressions.
Following your interpretation, -2^2 is '-(2^2)' literally "square two and change the sign”.
One ambiguity I see, that may explain John's mistake, could be a badly formatted ‘(-2)^2’ / literally “square the opposite of two” /
-2^2 -22 -2² -22
Edited: 29 Mar 2012, 5:12 p.m.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
The problem with -2^2 is that an interpretation as (-2)^2 is in contrast to the very similar expression 0-2^2 which isn't ambiguous at all. Many modern calculators solve the problem by introducing a special unary minus, often noted as (-), so that -2^2 becomes (-)2^2 which is, per definition ((-)2)^2.
▼
Posts: 2,448
Threads: 90
Joined: Jul 2005
ugh.
EDIT.
This is one of the AWFUL things about the equation list in the 32sii. And it even has a bug to boot!
Look it up, you'll be shocked. I was getting screwed up results way back when I first got that machine and it all had to do with not only the unary minus (which is defined in the manual) but also with the inconsistent behavior where that unary appears at the beginning of a line.
Edited: 30 Mar 2012, 3:31 p.m.
Posts: 4,587
Threads: 105
Joined: Jul 2005
That's making simple things complicated. There's a very old German calculation rule "hoch vor Punkt vor Strich" covering also this case perfectly: -2^2 is identical to -(2^2) equaling -4. Unambiguous. No 'unary minus' needed!
Due to deviating symbols used in the USA, this rule cannot be translated AFAIK. Sorry, folks :-(
Edited: 30 Mar 2012, 12:59 p.m.
▼
Posts: 429
Threads: 31
Joined: Jul 2011
Quote:
"hoch vor Punkt vor Strich" covering also this case perfectly: -2^2 is identical to -(2^2) equaling -4. Unambiguous. No 'unary minus' needed!
You're sure? ;-)
If by -(2^2) you mean (-1)*(2^2) you arrive at -4. But isn't -(2^2) also equal to (-2)*(1^2)??? So -4=-2! QED!
▼
Posts: 1,216
Threads: 75
Joined: Jun 2011
Quote:
But isn't -(2^2) also equal to (-2)*(1^2)???
It's really funny to see what crazy ideas people are developping for such a simple calculation ... ;-)
I would say the 3 '???' at the end are the only things in your post that make sense.
Edited: 30 Mar 2012, 2:38 p.m.
Posts: 2,448
Threads: 90
Joined: Jul 2005
Quote:
. But isn't -(2^2) also equal to (-2)*(1^2)??? So -4=-2! QED!
No.
2^2 is defined as 2*2. Therefore -(2^2) can be written equivalently as -1 * 2 * 2
1^2 is defined as 1 * 1. This is not the ame as 2 * 2!
You've got a logical fallacy going on there...
Posts: 4,587
Threads: 105
Joined: Jul 2005
Alexander,
bitte gaaanz langsam und vorsichtig noch mal die Matheregeln aus der Mittelstufe durcharbeiten. Klammern usw. HTH,
Walter ;-)
(For our unilingual readers: This was a friendly hint to solve this case.)
Posts: 429
Threads: 31
Joined: Jul 2011
Quote:
You're sure? ;-)
fhub, Bill, Walter - please note the ;-)
I thought we were already beyond being serious in this thread!
▼
Posts: 2,448
Threads: 90
Joined: Jul 2005
Posts: 1,089
Threads: 32
Joined: Dec 2005
Quote: But the true mistake on your side is the following: [...]
There's no mistake. Read my posts again and try to understand.
Enough said, I'm out here.
Posts: 2,448
Threads: 90
Joined: Jul 2005
It is actually even simpler than that. There is no such thing as a "unary minus" in maths. That is a computer coding issue.
X-y^2+z^3-4
We all know what the hell that is. It is no different if you do this:
3-4^2+5^3-4
Maybe I should go edit with advanced formatting but I think it works well enough...
but then someone is going to ask me about:
-x^3-y^2+z^3-4. Guess what. It is still the same as before. You know that you can rearrange it (commutative prop.) to:
z^3-x^3-y^2-4. So pretty obvious once again that without putting parenths. around a leading minus and it's associated absolute value, you never carry the sign into the exponentiation....That's just the way it is and the goal of calculator use is to make ure that comes out correctly!
Indeed, as much as I have been using the algebraic machines more often now, I am always checking and double checking this behavior becuase the really are all different!
Edited: 30 Mar 2012, 11:56 a.m.
▼
Posts: 4,587
Threads: 105
Joined: Jul 2005
It's actually even simpler than that :-) Please see above.
Posts: 3,283
Threads: 104
Joined: Jul 2005
Interestingly the 39gii has a unary minus but the parser treats it the same as the minus key with low priority.
Posts: 2,448
Threads: 90
Joined: Jul 2005
This is NOT how the 48G behaves.
Posts: 6
Threads: 0
Joined: Dec 2011
The TI-84+ returns 10000 for the expression 10^(-2)^2. Interesting.
On the HP-35s you must enter an extra set of parentheses to get 10000 thus 10^((-2)^2)).
Edited: 30 Mar 2012, 6:15 a.m.
Posts: 528
Threads: 40
Joined: Dec 2008
A nice side effect of RPN is that it points out ambiguities like this. Once you realize that you aren't sure which way it should go, you can investigate to figure it out.
The unary minus really is there. In the expression "-x=3" there is only one value that "-" operates on, so it's unary. To say that -x is really 0-x just invites the argument that multiplication is ternary. After all, a*b is really just 1*a*b.
Moving further off topic, programming languages have another issue that trips people up: order of evaluation. In an expression like a+b, order of evaluation tells you whether a is evaluated first and then b, or vice versa. The order of evaluation matters when the operands are function calls that have side effects.
|