RPN logic question



#22

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.


#23

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.

#24

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

#25

Five is the only true result.


#26

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.


#27

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.


#28

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.


#29

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

d:-/


#30

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*

#31

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


#32

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.


#33

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


#34

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.


#35

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


#36

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

#37

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

#38

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

#39

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

#40

Quote:
Five is the only true result.

I would say: back to school! ;-)

Franz


#41

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.

#42

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]

#43

Quote:
Five is the only true result.

APL FTW!


#44

Quote:
APL FTW!

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

d:-?


#45

We do arefmetik good here.

- Pauli


#46

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

d;-)

#47

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


#48

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

#49

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.


#50

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

#51

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.

#52

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

#53

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


#54

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


#55

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.

#56

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


#57

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


#58

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.


#59

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.

#60

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.


#61

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.


#62

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.


#63

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.

#64

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


#65

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.

#66

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


#67

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.


#68

I apologise to you, Neil.


#69

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

#70

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.


#71

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.


#72

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.

#73

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


#74

Here it is a suggestive article on this issue:

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Integration question and "RPN" mode comment Craig Thomas 16 5,965 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,548 11-05-2013, 02:44 AM
Last Post: Marcus von Cube, Germany
  HP-65 logic board repair - help required Alberto Fenini 1 1,245 02-17-2013, 06:39 PM
Last Post: John Robinson
  HP-50G Equation Editing Logic Matt Agajanian 4 1,497 04-20-2012, 11:21 PM
Last Post: Matt Agajanian
  The story of HP's Logic Analyzers Steve Leibson 3 1,553 02-19-2012, 11:44 PM
Last Post: Bruce Larrabee
  OT: Help with Logic Dart AC adapter Donald Williams 9 2,799 03-19-2011, 10:22 AM
Last Post: Donald Williams
  USB Logic Analyzer Thomas Chrapkiewicz 7 2,033 03-09-2010, 04:54 PM
Last Post: Adrian Godwin
  Classic Series Logic Board - Desoldering Temp ? John Robinson 7 2,133 09-17-2009, 09:36 PM
Last Post: Dan W
  Voyager series, logic PCA and keyboard PCA Geoff Quickfall 7 2,197 07-28-2009, 04:20 PM
Last Post: Eric Smith
  Technical question; HP-41CV logic PCA Geoff Quickfall 11 3,023 07-22-2009, 01:22 AM
Last Post: Eric Smith

Forum Jump: