HP Forums
RPN logic question - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: RPN logic question (/thread-239677.html)



RPN logic question - Victor Quiros - 02-27-2013

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.


Re: RPN logic question - Raymond Del Tondo - 02-27-2013

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.


Re: RPN logic question - fhub - 02-27-2013

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


Re: RPN logic question - Johnny Bjoern Rasmussen - 02-27-2013

Five is the only true result.


Re: RPN logic question - Didier Lachieze - 02-27-2013

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.


Re: RPN logic question - Walter B - 02-27-2013

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:-)


Re: RPN logic question - fhub - 02-27-2013

Quote:
Five is the only true result.

I would say: back to school! ;-)

Franz


Re: RPN logic question - fhub - 02-27-2013

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.


Re: RPN logic question - Didier Lachieze - 02-27-2013

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.


Re: RPN logic question - Walter B - 02-27-2013

'Chain mode' is no proper calculation method, it's the name of a disease IMHO.

d:-/


Re: RPN logic question - fhub - 02-27-2013

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


Re: RPN logic question - Didier Lachieze - 02-27-2013

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.


Re: RPN logic question - C.Ret - 02-27-2013

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.


Re: RPN logic question - Harald - 02-27-2013

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*


Re: RPN logic question - fhub - 02-27-2013

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


Re: RPN logic question - Didier Lachieze - 02-27-2013

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.


Re: RPN logic question - Victor Quiros - 02-27-2013

Thank you very much for this detailed, instructive answer. It really helped. Lesson learned. Cheers.


Re: RPN logic question - fhub - 02-27-2013

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


Re: RPN logic question - aurelio - 02-27-2013

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....


Re: RPN logic question - aurelio - 02-27-2013

math has its rules, and calculators (sure wonderful machines) are only tools, that we should use in the best way


Re: RPN logic question - Ethan Conner - 02-27-2013

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.


Re: RPN logic question - Manolo Sobrino - 02-27-2013

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.


Re: RPN logic question - Dieter - 02-27-2013

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


Re: RPN logic question - Nick_S - 02-28-2013

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


Re: RPN logic question - Reth - 02-28-2013

If there is a logic that evaluates that expression to anything other than 7, so it must be called "crap" logic.


Re: RPN logic question - C.Ret - 02-28-2013

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


Re: RPN logic question - C.Ret - 02-28-2013

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".




Re: RPN logic question - Walter B - 02-28-2013

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.


Re: RPN logic question - Marcus von Cube, Germany - 02-28-2013

It looks like financial guys demand it. No wonder where the last crisis must have come from...


Re: RPN logic question - Reth - 02-28-2013

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.


Re: RPN logic question - Neil Hamilton (Ottawa) - 02-28-2013

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.




Re: RPN logic question - Les Bell - 02-28-2013

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]


Re: RPN logic question - Kiyoshi Akima - 02-28-2013

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.


Re: RPN logic question - Pete Wilson - 03-01-2013

Quote:
Five is the only true result.

APL FTW!


Re: RPN logic question - Nick_S - 03-01-2013

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.


Re: RPN logic question - Walter B - 03-01-2013

Quote:
APL FTW!

Australian Pork Limited For The Worms?? Speach was invented for communication, wasn't it?

d:-?


Re: RPN logic question - Paul Dale - 03-01-2013

We do arefmetik good here.

- Pauli


Re: RPN logic question - Walter B - 03-01-2013

I believe it - your symptoms look like another disease but at least not that AAS (American abbreviation syndrom).

d;-)


Re: RPN logic question - C.Ret - 03-01-2013

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.


Re: RPN logic question - aurelio - 03-01-2013

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.


Re: RPN logic question - Reth - 03-01-2013

so you noticed my errors only? because i'm not native english speaker, true?


Re: RPN logic question - Reth - 03-01-2013

There was or there is? Is this an error, mr. English grammar expert?


Re: RPN logic question - Neil Hamilton (Ottawa) - 03-01-2013

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.




Re: RPN logic question - Dieter - 03-01-2013

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




Re: RPN logic question - Walter B - 03-01-2013

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;-)


Re: RPN logic question - Kiyoshi Akima - 03-01-2013

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.


Re: RPN logic question - Kiyoshi Akima - 03-01-2013

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.


Re: RPN logic question - Reth - 03-01-2013

I apologise to you, Neil.


Re: RPN logic question - Reth - 03-01-2013

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.


Re: RPN logic question - René Franquinet - 03-02-2013

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.


Re: RPN logic question - Neil Hamilton (Ottawa) - 03-02-2013

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...


Re: RPN logic question - Les Koller - 03-08-2013

Doesn't matter what the calculator does, PEMDAS is always right. That's the accepted order and one we must all follow,


Re: RPN logic question - Victor Quiros - 03-12-2013

Here it is a suggestive article on this issue:

What Is the Answer to That Stupid Math Problem on Facebook?