Order of operations - what is 6÷2(1+2) ? - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Calculators (and very old HP Computers) ( /forum-3.html)+--- Forum: General Forum ( /forum-4.html)+--- Thread: Order of operations - what is 6÷2(1+2) ? ( /thread-11916.html) |

RE: Order of operations - what is 6÷2(1+2) ? - toml_12953 - 12-21-2020 11:54 PM
(12-21-2020 08:39 PM)EugeneNine Wrote: I was always taught that you do the () first (without mention of implied * or not)But that's only if you multiply (or distribute) the 2 by what's in the parentheses before you do the division. RE: Order of operations - what is 6÷2(1+2) ? - Dave Britten - 12-22-2020 12:56 PM
Let's make a deal here: if people get to claim that 6/2(1+2)=1 then I get to say that -2^2=4. RE: Order of operations - what is 6÷2(1+2) ? - toml_12953 - 12-22-2020 03:41 PM
(12-22-2020 12:56 PM)Dave Britten Wrote: Let's make a deal here: if people get to claim that 6/2(1+2)=1 then I get to say that -2^2=4. Of course it does! That's something we can all agree on. Negation does take priority over powers in all versions of the hierarchies I've seen. (-2)^2 = 4 RE: Order of operations - what is 6÷2(1+2) ? - robve - 12-22-2020 08:03 PM
(12-22-2020 03:41 PM)toml_12953 Wrote:(12-22-2020 12:56 PM)Dave Britten Wrote: Let's make a deal here: if people get to claim that 6/2(1+2)=1 then I get to say that -2^2=4. Not so for Python: >>> -2**2 -4 Yes for Prolog: ?- X is -2^2. X = 4. Yes for Unix bc: bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. -2^2 4 Not so for Basic (all Sharp PC and Visual Basic): -2^2 -4 Yes for Fortran. Not so for Casio fx-115ES+. The jury is still out on this one... RE: Order of operations - what is 6÷2(1+2) ? - trojdor - 12-22-2020 10:33 PM
When I went to college, I was fortunate enough to have a professor who was part of the massive layoff from NASA at the end of the Apollo program. His advice .... hammered into us constantly .... was to NEVER write an equation, a line of code, or make a drawing that required any "assumption" on the part of the reader. (At NASA, it was observed many times that if you gave someone multiple ways to interpret your equation/design, and one of those ways could cause a massive failure .... that would invariably be the one they chose to use.) He would frequently write the word "assume" on the chalkboard, and do the standard "Why we never assume." comedic routine. He also mentioned .... apparently in direct conflict with many current math teachers .... that it doesn't actually cost money (or effort) for each parenthesis you use. I found his advice invaluable when writing code for real-time data acquisition and control systems, as it seemed/seems every programming language handled equations differently, and indeed the parenthesis became my best friend. RE: Order of operations - what is 6÷2(1+2) ? - klesl - 12-22-2020 10:42 PM
Article about Order of arithmetic operations; in particular, the 48/2(9+3) question. https://math.berkeley.edu/~gbergman/misc/numbers/ord_ops.html RE: Order of operations - what is 6÷2(1+2) ? - Albert Chan - 12-22-2020 10:50 PM
(12-22-2020 08:03 PM)robve Wrote: Yes for Prolog: Prolog should return -4 for this, according to its precedence table. (pow higher than unary minus) Problem is it parsed first number as -2, removed the unary minus. Forcing it to parse first number as 2, we get the right answer. B-Prolog Version 8.1, All rights reserved, (C) Afany Software 1994-2014. | ?- X is -2**2 X = 4 yes | ?- Two = 2, X is -Two**Two Two = 2 X = -4 yes You should not get 2 different answers by replacing Two for 2. This bug had been fixed in Picat Picat> X is -2**2 X = -4 yes Picat> Two = 2, X is -Two**Two Two = 2 X = -4 yes RE: Order of operations - what is 6÷2(1+2) ? - franz.b - 12-22-2020 11:33 PM
(12-22-2020 10:33 PM)trojdor Wrote: When I went to college, I was fortunate enough to have a professor who was part of the massive layoff from NASA at the end of the Apollo program. RE: Order of operations - what is 6÷2(1+2) ? - Valentin Albillo - 12-23-2020 12:38 AM
(12-22-2020 08:03 PM)robve Wrote: Not so for Basic (all Sharp PC and Visual Basic): ... and the always-forgotten-by-most-MoHPC-members HP-71B BASIC as well. Matter of fact, if I ever saw a BASIC evaluating -2^2 as 4 I'd get rid of it. V. RE: Order of operations - what is 6÷2(1+2) ? - toml_12953 - 12-23-2020 01:46 AM
(12-23-2020 12:38 AM)Valentin Albillo Wrote:(12-22-2020 08:03 PM)robve Wrote: Not so for Basic (all Sharp PC and Visual Basic): The ANSI/ISO committees agree with you. The international Standard for Full BASIC calls for -2^2 to be -4. RE: Order of operations - what is 6÷2(1+2) ? - robve - 12-23-2020 03:14 AM
(12-22-2020 10:50 PM)Albert Chan Wrote:(12-22-2020 08:03 PM)robve Wrote: Yes for Prolog: I agree. Parsers should not consider the - to be part of the number to avoid this flaw. So it is ridiculously funny to see the following (note the spacing between - and 2): ?- X is -2^2. X = 4. ?- X is - 2^2. X = -4. On the other hand, SWI-Prolog has a reasonably powerful implementation of multi-precision arithmetic with bigint and rationals (bigint/bigint) https://www.swi-prolog.org/pldoc/man?section=arith something I contributed to to this project many years ago and now fully integrated. RE: Order of operations - what is 6÷2(1+2) ? - CMarangon - 12-23-2020 07:06 AM
Hello! The answer is 1, but why? We must keep in mind that the sequence of operations is "x" and "÷" and after "-" and "+". First solve "( )" after, "[ ]" and after "{ }" For the given expression: Lets assume this expressiona as X =6÷2x(1+2) Soving "( )" X = 6÷2x(1+2) X =6÷2x(3) X = 6÷6 X =1 In RPN: 6 2 1 2 + x ÷ Solution, X = 1 RE: Order of operations - what is 6÷2(1+2) ? - Wes Loewer - 12-23-2020 09:03 AM
I am finding this whole discussion rather humorous as it all boils down to which convention you are using, like spelling color or colour. The Prime completely eliminates this issue in Textbook entry by always using a horizontal fraction bar. Problem solved! Everyone is happy! Every multi-line calculator should do this. Some have indicated that we use juxtaposition when writing by hand. I encourage my students to avoid using / for division unless there is only one value after it, like 2/3 or 1/x. If a student writes "1/2x", I might interpret it as 1/(2x). But "1/2 x" with a space might be interpreted as (1/2)x. But when you write with pencil and paper, spaces can vary in size. At what point do you switch meanings? 1/2x 1/2 x 1/2 x 1/2 x 1/2 x 1/2 x Therefore, I avoid using / except for the unambiguous cases. Even the symbol can be problematic. I had one former engineer tell me that he would say that a + b ÷ c + d = a + (b ÷ c) + d but a + b / c + d = (a + b) / (c + d) because he took the / to be a text replacement of the horizontal fraction bar. RE: Order of operations - what is 6÷2(1+2) ? - Wes Loewer - 12-23-2020 09:19 AM
(12-22-2020 03:41 PM)toml_12953 Wrote:(12-22-2020 12:56 PM)Dave Britten Wrote: Let's make a deal here: if people get to claim that 6/2(1+2)=1 then I get to say that -2^2=4.Of course it does! That's something we can all agree on. Negation does take priority over powers in all versions of the hierarchies I've seen. (-2)^2 = 4 At first I thought you were being facetious, but now I'm not sure. If -2^2 = (-2)^2 = 4 then would \(e^{-x^2}\) be \(e^{(-x)^2}\) ? If so, then you'd have to write the bell-curve equation written as \(e^{-(x^2)}\) which I've never seen done. RE: Order of operations - what is 6÷2(1+2) ? - toml_12953 - 12-23-2020 10:41 AM
(12-23-2020 09:19 AM)Wes Loewer Wrote:(12-22-2020 03:41 PM)toml_12953 Wrote: Of course it does! That's something we can all agree on. Negation does take priority over powers in all versions of the hierarchies I've seen. (-2)^2 = 4 I really was on the fence but since I'm a BASIC programmer, I use the Standard BASIC convention of -2^2 = -(2^2) = -4. RE: Order of operations - what is 6÷2(1+2) ? - Thomas Radtke - 12-23-2020 03:25 PM
-2^2=x -> x+2^2=0 -> x=-(2^2)=-4 IAW: -x^2 is comfortable way to write 0-x^2 RE: Order of operations - what is 6÷2(1+2) ? - grsbanks - 12-24-2020 08:31 AM
(12-23-2020 03:25 PM)Thomas Radtke Wrote: -2^2=x This is only true if -2^2 is interpreted as -(2^2). If it is interpreted as (-2)^2 then your second line should be: x - (-2^2) = 0 And this is just as ambiguous as the first line RE: Order of operations - what is 6÷2(1+2) ? - Albert Chan - 12-30-2020 05:41 PM
(12-23-2020 03:14 AM)robve Wrote: Parsers should not consider the - to be part of the number to avoid this flaw. You are right. I peeked at Lua 5.4 source code, llex.c, llex() read_numeral() only allowed to convert non-negative numbers. Code: `case '-': { /* '-' or '--' (comment) */` RE: Order of operations - what is 6÷2(1+2) ? - WrongWay - 01-04-2021 04:16 AM
-2^2 on the 41CV evaluates to 4 RE: Order of operations - what is 6÷2(1+2) ? - rprosperi - 01-04-2021 04:26 AM
(01-04-2021 04:16 AM)WrongWay Wrote: -2^2 on the 41CV evaluates to 4 No, that's not correct. You have interpreted the algebraic equation shown there to be (-2) ^ 2 and you entered it as 2 CHS ENTER 2 Y^X which is not what is written, and that's what this entire discussion is about. If an equation is written in an ambiguous manner, the results are meaningless. The above equation could also mean - (2^2) which would be -4; most systems that state the orders of precedence put exponentiation at a higher priority than unary negation, so the way I wrote at the start of this sentence would be the correct way to process it. If the equation is ambiguous and precedence rules are not provided, a 'correct' answer is not possible, and it probably means someone is trying to lure you in to a conversation like this one. |