Hi there. Someone posted this on Facebook: 6-1*0+2/2= . Most people answer 7, however being accustomed to RPN logic my answer is 5: 1 [enter] 0 [x] 2 [enter] 2 [/] [+] [6] [stack swap] [-]. At the beginning I was certain it was 5, but so many people answering 7 got me puzzled. I know there must be one valid answer only. Any thoughts? Thanks and cheers from the tropics.
RPN logic question
|
|
« Next Oldest | Next Newest »
|
▼
02-27-2013, 07:35 AM
▼
02-27-2013, 07:42 AM
Just take a look at the wikipedia entry for "Operator precedence" which will clarify the problem;-)
HTH
Ray Edited: 27 Feb 2013, 7:43 a.m.
02-27-2013, 07:43 AM
Quote:Well, 1*0=0 (and 2/2=1), so in fact it's 6-0+1=7.
With your changed order you're calculating 6-1 instead of 6+1. Franz
02-27-2013, 08:30 AM
Five is the only true result. ▼
02-27-2013, 08:40 AM
Without further details such as explicit operator precedence rules, other results can be valid.
For example, just enter the sequence of operations above on a chain mode calculator (such as the recent hp 20b) and you’ll got: 1.00 Edited: 27 Feb 2013, 8:48 a.m. ▼
02-27-2013, 09:02 AM
Quote:No, there are no further details about operator precedence necessary, there are already clearly defined precedence rules in mathematics:
1) expressions in parentheses (...) Franz
Edited: 27 Feb 2013, 9:03 a.m. ▼
02-27-2013, 10:20 AM
What I meant is that if you just have the list of operations: "6-1*0+2/2=" without an explicit statement telling you that you should apply operator precedence rules, then this can be considered as a chain mode sequence leading to different but still valid result.
Edited: 27 Feb 2013, 10:22 a.m. ▼
02-27-2013, 10:29 AM
'Chain mode' is no proper calculation method, it's the name of a disease IMHO. d:-/ ▼
02-27-2013, 10:43 AM
Quote: A disease that is even taught at school sometimes. *shiver*
02-27-2013, 10:30 AM
Quote:And what I meant is that you don't need an explicit statement about operator precedence rules, because there are implicit precedence rules for all mathematical expressions - you don't even have to mention them. ;-) Franz ▼
02-27-2013, 10:38 AM
It's all about context. You're making the implicit assumption that this is a mathematical expression and that operator precedence rules should apply as defined and taught in schools. However nothing in the original post is telling you this is not an expression used in a different context where chain mode rules apply. Depending on the context 1+3x2=7 or 1+3x2=8 ...
Just look to the hp 20b/30b or others financial calculators with chain mode. Edited: 27 Feb 2013, 10:44 a.m. ▼
02-27-2013, 10:47 AM
Quote:Could you please show me one serious example where a so-called 'chain-mode-rule' is (or should be) used??? (it's in fact as Walter said: 'chain-mode' is a disease, the so-called 'Chain-Mode-Syndrome' :-)) Quote:WHAT??? Do you really want to say that the HP-20b/30b use these completely wrong chain-mode rule? [shock] Franz ▼
02-27-2013, 10:56 AM
Quote:Gene may have the background to provide such examples.
Quote:Yes, and Chain Mode is the default mode on these calculators. Algebraic and RPN are the two other modes supported. Edited: 27 Feb 2013, 10:57 a.m. ▼
02-27-2013, 11:33 AM
Quote:Oh my god, I would never have expected that HP would implement such a crap in any of their calculators. :-( That's almost a reason for removing the HP-20b/30b emulators from my calculator emulation package! Franz ▼
02-28-2013, 11:58 AM
It looks like financial guys demand it. No wonder where the last crisis must have come from...
02-27-2013, 12:41 PM
math has its rules, and calculators (sure wonderful machines) are only tools, that we should use in the best way
02-27-2013, 12:37 PM
Quote: Saint words, Franz, saint words....
02-27-2013, 08:48 AM
I dare to disagree. With multiplications and divisions preceding additions and subtractions (I assume you were taught that common rule as well), seven is the solution. d:-)
02-27-2013, 08:51 AM
Quote:I would say: back to school! ;-) Franz ▼
02-27-2013, 12:56 PM
I am going to buy a lottery ticket today.....Walter and Franz agree on something! Seriously though i have seen a couple of these problems on FB and it's scary how many people don't apply order of operations even when someone has explained this in their answer.
02-28-2013, 10:25 PM
Quote: The only true response is, "What a silly way to write out a problem". I doubt any of us would write down such an algebraic expression without reducing some of the terms, using parentheses - even redundant parentheses where an ambiguity could arise - or even (possibly subconsciously) adding extra space on the paper to make clear the precedence. I routinely deal with much more complex calculations and equations with either pencil-and-paper or LaTeX, and there's never any kind of ambiguity over algebraic precedence like in this problem - it's screamingly obvious. In the course of solving a real-world problem, we'd probably note the zero factor in the second term, and just write:
x = 6 + 2/2 I cringe when I see those silly Facebook posts - they're deliberately written without all the clues and cues people who actually work with numbers give ourselves to make sure things get done right. They're just a little trick by which high-schoolers with a little mathematical nous can get to feel superior over their less-numerate friends. Best,
--- Les
03-01-2013, 01:09 AM
Quote: APL FTW! ▼
03-01-2013, 02:54 AM
Quote:Australian Pork Limited For The Worms?? Speach was invented for communication, wasn't it? d:-? ▼
03-01-2013, 03:03 AM
We do arefmetik good here. - Pauli ▼
03-01-2013, 03:20 AM
I believe it - your symptoms look like another disease but at least not that AAS (American abbreviation syndrom). d;-)
03-01-2013, 08:43 AM
Quote:"Speach" ?-) Do you remember your own post from yesterday, 8:44 a.m.? SCNR.
Regarding speech and communication, consider this quote of Charles-Maurice de Talleyrand-Périgord: Dieter
02-27-2013, 10:42 AM
Quote: In this specific case, most people are correct. Note that isn't the case for every situation.
Quote:
The RPN logic doesn't require you change the order of arguments or operations.
6 [ENTER^] 1 [ENTER^] 0 [ x ] [ - ] 2 [ENTER^] [ / ] [ + ]
Quote: There is only one solution in the case this expression has to be interpreted with implicit standard rules of precedence.
If it is state that "chain computation" rules have to be applied, then the only expected result is 1. And the corresponding RPN sequence will be :
6 [ENTER^] 1 [ - ] 0 [ x ] 2 [ - ] 2 [ / ] In the hypothetic case where same exotic rules of interpretation are imposed, another RPN sequence may have to be applied… As can be seen on this short example, the power of RPN logic system is exactly that the user may adapt its computations to any rules and specific situations.
As a conclusion, RPN logic is not a proof from the correct logic in expression's (or equation's) interpretations. This is not the case with AOS or other CAS systems. That why RPN systems are still preferred by well-to-do people, who exactly know how to get the correct answers in any specific circumstances. And the others systems are preferred by unskilled people who frenziedly hope that a sophisticate digital assistant will suffice in masking personal unawareness.
Edited: 27 Feb 2013, 10:47 a.m. ▼
02-27-2013, 11:13 AM
Thank you very much for this detailed, instructive answer. It really helped. Lesson learned. Cheers.
02-27-2013, 01:43 PM
Quote: I'm getting a little bit tired of this... It really depends. If you are the kind of person that does the algebra on paper in order to get a closed result in terms of parameters (introducing ad-hoc ones if necessary), then (EOS) 'equation' algebraic makes a lot of sense. If you'd rather perform transformations with the values of all parameters as soon as you can, then RPN makes easier to get to the numerical answer. Usually in Physics the first strategy is encouraged, as your algebraic result is essential to the calculation of error propagation (in real life it is expected that you deal with uncertainties properly). Maybe I'm biased, but I think it's quite elegant: you get your numerical results just by plugging the required values, then again editing the last line for any change. Engineers (and freshmen... -sorry, but you had it coming XD-) tend to use the second approach as probably it is faster for a single-time, not too involved calculation... and a reasonable number of decimal places will do the job fairly well.
They're just different tools for different needs. Edited: 27 Feb 2013, 1:47 p.m.
02-27-2013, 02:31 PM
Simple answer: 6 - 1 * 0 + 2 / 2On the other hand, your key sequence... 1 [enter] 0 [x] 2 [enter] 2 [/] [+] [6] [stack swap] [-]...actually calculates... 6 - ((1*0) + (2/2))q.e.d. Dieter
02-28-2013, 02:42 AM
Quote:Being accustomed to both RPN and the norms of infix operator precedence for multiplication and addition I calculated the answer as: 6 [enter] 1 [enter] 0 * - 2 [enter] 2 / + = 7 Nick ▼
02-28-2013, 08:39 AM
Hi, Nick, you can spare a really few keystroke, the last [ 2 ] doeasn't need to be input, the [ENTER^] key has kept a copy of the firt entry in the x: register. I agree, this is a really small economy, but "a keystroke is a keystroke" as we say it as home : "un sou est un sou".
02-28-2013, 05:07 AM
If there is a logic that evaluates that expression to anything other than 7, so it must be called "crap" logic. ▼
02-28-2013, 08:34 AM
The good new is that any RPN calculators are ready to process any type of "crap" and "sandard" logics ! EDIT:
The good new is that any RPN calculators are ready to process any type of "crap" and "standard" logics ! Edited: 1 Mar 2013, 3:42 a.m. after one or more responses were posted ▼
02-28-2013, 08:44 AM
Quote:"Sand art" or "standard"?? How about measuring the quality of posts in "errors per line of text"?
d#-/ Edited: 28 Feb 2013, 8:51 a.m. ▼
03-01-2013, 03:40 AM
Quote: Sorry, miss typed again. It was "Standard".
You right, I have to improve my english. Please continue to point me out any errors and typos. I only progress under pressure. Good teachers make better students ! Sorry again for my broken english and the numerous typos making my low quality posts hard to read or to understand.
Edited: 13 Mar 2013, 3:34 a.m.
02-28-2013, 08:33 PM
Are you going to walk after me and try to play smart? Thank God you're not a stand-up comedian, you'd be starving to death with that sense of humor.
Edited: 28 Feb 2013, 8:35 p.m. ▼
02-28-2013, 10:22 PM
We have a saying in English about the "pot calling the kettle black". It seems your house may be very much made of glass... This is a quote of you from another thread. In it I count 2 spelling errors.
Quote: Perhaps you yourself were rattled due to the quite deserved rebuke against your unreasonable and offensive post there. I am not sure what your issues are but they certain grow on others nerves -- at least mine.
▼
02-28-2013, 11:23 PM
There was also a grammatical error in the next sentence. It's an all too common error, so perhaps Reth thinks that if enough people make the error then it's okay. ▼
03-01-2013, 05:00 AM
I think that for a lot of people, here on the MoHPC, english is not the mother tongue, so that I think that we must consider more important facts and ideas than grammar rules or spelling corrections. Different thoughts of course for a official printed document. I think that sometimes most of us on this Forum love to play with this matter like children. My 2 cents.
Edited: 1 Mar 2013, 5:02 a.m.
03-01-2013, 05:18 AM
There was or there is? Is this an error, mr. English grammar expert?
03-01-2013, 05:14 AM
so you noticed my errors only? because i'm not native english speaker, true? ▼
03-01-2013, 07:50 AM
No, it was not your spelling errors to which my comments were addressed. I would never cast stone at others spelling since mine is typically so atrocious -- not to mention the fact that I, like others, simply cannot type accurately on an iPad or iPhone. It was more your inhospitable attitude I was referring to. I will second (third?, fourth?, ...) statements made in earlier posts by others that if you are not interested in a topic, have the good grace to ignore it and leave it to others to enjoy. I am sure we will all be much happier then.
▼
03-01-2013, 10:18 PM
I apologise to you, Neil. ▼
03-02-2013, 06:39 AM
Accepted. However, I think it would be better directed at the OP of the 39GII thread than to me. I, like you, thoroughly enjoy RPN (and lately, RPL as well) and really can't understand a world that doesn't "see the light" as we do. I also own a 39GII, and though I really can't make much use of it because I keep stumbling over prefix/postfix, etc. (old RPN reflexes) I recognize that it is an incredible machine and enjoy reading about it. Will I ever replace my collection of backward machines? NEVER!, but I will continue to read about others none the less. As far as new vs. old, native compiled vs. emulator vs. simulator, they all have their uses and they all have merit. There are many opinions that this specific family or that specific series is by far the best. They all have their quirks and issues. Many have golden ideas. I would prefer to hear about as many of them as possible. (And for the record, I have a much maligned 35s which I quite like -- even with its foibles -- and be damned what others may say.) Just because David has arbitrarily decided that the world ended at HP48SX (with mention of a few "interesting laters models" -- including the 42S, no less!) does not mean that this constantly evolving forum cannot examine and debate other machines we find interesting -- including non-HP, such as my beloved (though overwhelming) WP34S, or even TI. I hope you will again come to embrace the diversity of this group and enjoy the wide variety it has to offer. Best regards...
03-01-2013, 11:33 AM
So, you are the only one allowed to point out mistakes in other people's posts? Just as you are the only one allowed to decide what subject matter is and isn't appropriate? As for not being a native English speaker, neither am I. ▼
03-01-2013, 10:22 PM
I only shared my view and gave my advise to the OP.
Edited: 1 Mar 2013, 10:28 p.m. ▼
03-02-2013, 06:23 AM
Gentlemen (as I have not noticed a name of feminine origin),
I have enjoyed this forum topic very much as at the same time it contained very meaningless and meaningful elements. The extremes being language and mathematics, but as you know the latter cannot live without the former, I have enjoyed this stand-up comedian like discussion of a rather insignificant problem, whether it could be handled by RPN or by CAS or by a yet unnamed method.
03-08-2013, 09:08 PM
Doesn't matter what the calculator does, PEMDAS is always right. That's the accepted order and one we must all follow, |