RPN logic question « Next Oldest | Next Newest »

 ▼ Victor Quiros Unregistered Posts: 9 Threads: 2 Joined: Jul 2011 02-27-2013, 07:35 AM 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. ▼ Raymond Del Tondo Unregistered Posts: 1,841 Threads: 54 Joined: Jul 2005 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. fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 07:43 AM Quote: 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. 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. In fact you calculate 6-(1*0+2/2) Franz Johnny Bjoern Rasmussen Unregistered Posts: 173 Threads: 41 Joined: Aug 2007 02-27-2013, 08:30 AM Five is the only true result. ▼ Didier Lachieze Unregistered Posts: 248 Threads: 5 Joined: Feb 2008 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. ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 09:02 AM Quote: Without further details such as explicit operator precedence rules, other results can be valid. No, there are no further details about operator precedence necessary, there are already clearly defined precedence rules in mathematics: 1) expressions in parentheses (...) 2) ^ 3) * and / 4) + and - 5) for equal-precedence operators from left to right (except for ^, where it's from right to left) Franz Edited: 27 Feb 2013, 9:03 a.m. ▼ Didier Lachieze Unregistered Posts: 248 Threads: 5 Joined: Feb 2008 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. ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 02-27-2013, 10:29 AM 'Chain mode' is no proper calculation method, it's the name of a disease IMHO. d:-/ ▼ Harald Unregistered Posts: 455 Threads: 39 Joined: Jan 2011 02-27-2013, 10:43 AM Quote: 'Chain mode' is no proper calculation method, it's the name of a disease IMHO. A disease that is even taught at school sometimes. *shiver* fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 10:30 AM Quote: 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. 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 ▼ Didier Lachieze Unregistered Posts: 248 Threads: 5 Joined: Feb 2008 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. ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 10:47 AM Quote: However nothing in the original post is telling you this is not an expression used in a different context where chain mode rules apply. 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: Just look to the hp 20b/30b or others financial calculators with chain mode. WHAT??? Do you really want to say that the HP-20b/30b use these completely wrong chain-mode rule? [shock] Franz ▼ Didier Lachieze Unregistered Posts: 248 Threads: 5 Joined: Feb 2008 02-27-2013, 10:56 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' :-)) Gene may have the background to provide such examples. Quote:WHAT??? Do you really want to say that the HP-20b/30b use these completely wrong chain-mode rule? [shock] 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. ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 11:33 AM Quote: Yes, and Chain Mode is the default mode on these calculators. Algebraic and RPN are the two other modes supported. 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 ▼ Marcus von Cube, Germany Unregistered Posts: 3,283 Threads: 104 Joined: Jul 2005 02-28-2013, 11:58 AM It looks like financial guys demand it. No wonder where the last crisis must have come from... aurelio Unregistered Posts: 312 Threads: 25 Joined: Sep 2009 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 aurelio Unregistered Posts: 312 Threads: 25 Joined: Sep 2009 02-27-2013, 12:37 PM 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 Saint words, Franz, saint words.... Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 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:-) fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 02-27-2013, 08:51 AM Quote: Five is the only true result. I would say: back to school! ;-) Franz ▼ Ethan Conner Unregistered Posts: 236 Threads: 18 Joined: Aug 2011 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. Les Bell Unregistered Posts: 540 Threads: 22 Joined: Jan 2005 02-28-2013, 10:25 PM Quote: Five is the only true result. 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 [http://www.lesbell.com.au] Pete Wilson Unregistered Posts: 74 Threads: 1 Joined: Nov 2011 03-01-2013, 01:09 AM Quote: Five is the only true result. APL FTW! ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 03-01-2013, 02:54 AM Quote: APL FTW! Australian Pork Limited For The Worms?? Speach was invented for communication, wasn't it? d:-? ▼ Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 03-01-2013, 03:03 AM We do arefmetik good here. - Pauli ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 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;-) Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 03-01-2013, 08:43 AM Quote: Speach was invented for communication, wasn't it? "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: "La parole a été donnée à l'homme pour déguiser sa pensée". ;-) Dieter ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 03-01-2013, 10:29 AM Point taken. Speech is one of my favourites ;-) But speech was invented at a place far, far away and long, long before Taillerand abused it ... d;-) C.Ret Unregistered Posts: 260 Threads: 0 Joined: Oct 2008 02-27-2013, 10:42 AM Quote: Hi there. Someone posted this on Facebook: 6-1*0+2/2= . Most people answer 7, In this specific case, most people are correct. Note that isn't the case for every situation. Quote:however being accustomed to RPN logic my answer is 5: 1 [enter] 0 [x] 2 [enter] 2 [/] [+] [6] [stack swap] [-]. The RPN logic doesn't require you change the order of arguments or operations. Keeping the initial order of the expressions, greatly help making things clearer, easier and free of errors… `6 [ENTER^] 1 [ENTER^] 0 [ x ] [ - ] 2 [ENTER^] [ / ] [ + ]` Quote: 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. 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. In RPN, the user is in charge of applying the correct logic, not the system. That’s exactly the opposite situation of an 'interpreted expression' in AOS or 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. ▼ Victor Quiros Unregistered Posts: 9 Threads: 2 Joined: Jul 2011 02-27-2013, 11:13 AM Thank you very much for this detailed, instructive answer. It really helped. Lesson learned. Cheers. Manolo Sobrino Unregistered Posts: 79 Threads: 3 Joined: Jun 2010 02-27-2013, 01:43 PM Quote: 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. 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. Dieter Unregistered Posts: 653 Threads: 26 Joined: Aug 2010 02-27-2013, 02:31 PM Simple answer: ``` 6 - 1 * 0 + 2 / 2 = 6 - (1*0) + (2/2) = 7 ``` On the other hand, your key sequence... ``` 1 [enter] 0 [x] 2 [enter] 2 [/] [+] [6] [stack swap] [-] ``` ...actually calculates... ``` 6 - ((1*0) + (2/2)) = 6 - (1*0) - (2/2) = 5 ``` q.e.d. Dieter Nick_S Unregistered Posts: 125 Threads: 9 Joined: Oct 2011 02-28-2013, 02:42 AM Quote: 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] [-]. 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 ▼ C.Ret Unregistered Posts: 260 Threads: 0 Joined: Oct 2008 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". ▼ Nick_S Unregistered Posts: 125 Threads: 9 Joined: Oct 2011 03-01-2013, 02:29 AM Thanks for the reminder about the short cut for my HP15c. Here, it's a case of me using RPL since 1988 on a HP28S and HP48GX where the extra [enter] keystroke appears to be required. Nick Edited: 1 Mar 2013, 3:35 a.m. Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 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. ▼ C.Ret Unregistered Posts: 260 Threads: 0 Joined: Oct 2008 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 ▼ Walter B Unregistered Posts: 4,587 Threads: 105 Joined: Jul 2005 02-28-2013, 08:44 AM Quote: The good new is that any RPN calculators are ready to process any type of "crap" and "sandard" logics ! "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. ▼ C.Ret Unregistered Posts: 260 Threads: 0 Joined: Oct 2008 03-01-2013, 03:40 AM Quote: "Sand art" or "standard"?? How about measuring the quality of posts in "errors per line of text"? d#-/ Sorry, miss typed again. It was "Standard". You right, I have to improve my english. I also have to refrain me posting when I have too short time to carefully check my typing. 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. Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 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. PS Apparently your spelling skills get worse when you are shaken. Take it easy. Edited: 28 Feb 2013, 8:35 p.m. ▼ Neil Hamilton (Ottawa) Unregistered Posts: 255 Threads: 22 Joined: May 2011 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: Sure it is, did't you now the above? :) 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. ▼ Kiyoshi Akima Unregistered Posts: 325 Threads: 18 Joined: Jul 2006 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. ▼ aurelio Unregistered Posts: 312 Threads: 25 Joined: Sep 2009 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. For example I'm one of those who write all the time at PC and in typing has for that reason a lot of trouble, even in italian language.... (we call in Italy this kind of mistake "refuso", in english, maybe "typo") but I've always thought that an e-mail is an unformal way to communicate, like the spoken language. I know a lot of people expecially at work (colleagues), that reading my communications and instructions, reports to me, only the presence of these typos, like two words toghether , without space, the lack of a letter..... this is the best way to avoid the effort to understand and apply the meaning of the text! 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. Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 03-01-2013, 05:18 AM There was or there is? Is this an error, mr. English grammar expert? ▼ Kiyoshi Akima Unregistered Posts: 325 Threads: 18 Joined: Jul 2006 03-01-2013, 11:37 AM Quote: There was or there is? Is this an error, mr. English grammar expert? It may or may not be, depending on whether you edit your post to correct the original error. Since I have no control over that, I merely confined my statement to the original post. Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 03-01-2013, 05:14 AM so you noticed my errors only? because i'm not native english speaker, true? ▼ Neil Hamilton (Ottawa) Unregistered Posts: 255 Threads: 22 Joined: May 2011 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. ▼ Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 03-01-2013, 10:18 PM I apologise to you, Neil. ▼ Neil Hamilton (Ottawa) Unregistered Posts: 255 Threads: 22 Joined: May 2011 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... Kiyoshi Akima Unregistered Posts: 325 Threads: 18 Joined: Jul 2006 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. ▼ Reth Unregistered Posts: 556 Threads: 9 Joined: Jul 2007 03-01-2013, 10:22 PM I only shared my view and gave my advise to the OP. All I wanted to say was that this particular forum is RPN oriented, to say the least. ps The hp39gII follows the mainstream of today - nothing wrong with that, simply the vast majority of the attenders here are old school guys with nostalgia to past times. I consider myself one of them. Edited: 1 Mar 2013, 10:28 p.m. ▼ René Franquinet Unregistered Posts: 29 Threads: 3 Joined: Jan 2011 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. I hope to see many more of these problems, especially because they obviously arouse both emotions and knowledge (wisdom?). As you know the drive of much knowledge is emotion. And I really hope I will not be advised to never visit the forum again with these irrelevant remarks that even do not contribute to the one and only right solution of the problem, which is 7, as everybody knows. Les Koller Unregistered Posts: 253 Threads: 20 Joined: Jun 2012 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, ▼ Victor Quiros Unregistered Posts: 9 Threads: 2 Joined: Jul 2011 03-12-2013, 02:59 PM Here it is a suggestive article on this issue:

 Possibly Related Threads… Thread Author Replies Views Last Post Integration question and "RPN" mode comment Craig Thomas 16 5,841 12-05-2013, 02:32 AM Last Post: Nick_S [PRIME] RPN: another attempt at returning more than one value to the RPN stack Marcus von Cube, Germany 5 2,465 11-05-2013, 02:44 AM Last Post: Marcus von Cube, Germany HP-65 logic board repair - help required Alberto Fenini 1 1,213 02-17-2013, 06:39 PM Last Post: John Robinson HP-50G Equation Editing Logic Matt Agajanian 4 1,423 04-20-2012, 11:21 PM Last Post: Matt Agajanian The story of HP's Logic Analyzers Steve Leibson 3 1,501 02-19-2012, 11:44 PM Last Post: Bruce Larrabee OT: Help with Logic Dart AC adapter Donald Williams 9 2,696 03-19-2011, 10:22 AM Last Post: Donald Williams USB Logic Analyzer Thomas Chrapkiewicz 7 1,961 03-09-2010, 04:54 PM Last Post: Adrian Godwin Classic Series Logic Board - Desoldering Temp ? John Robinson 7 2,071 09-17-2009, 09:36 PM Last Post: Dan W Voyager series, logic PCA and keyboard PCA Geoff Quickfall 7 2,113 07-28-2009, 04:20 PM Last Post: Eric Smith Technical question; HP-41CV logic PCA Geoff Quickfall 11 2,901 07-22-2009, 01:22 AM Last Post: Eric Smith

Forum Jump: