Math Problem: 1 or 16? - Page 1
Forum section: electronics / general

author: bostonman
author_rank: Super Contributor
timestamp: August 03, 2019, 12:55:38 pm
content: I don't understand, the article states it depends on which method a person is taught (BODMAS or PEMDAS) will depend on the answer.How can the order of operations have changed from division first to multiplication first (or vice versa)? The Internet isn't "divided" because the answer is 16; and confirmed by Excel.So how can people be taught two different methods thus changing the order of operations? This would mean math problems would have different answers.https://www.inc.com/dave-kerpen/this-basic-math-problem-is-breaking-internet.html

author: awallin
author_rank: Frequent Contributor
timestamp: August 03, 2019, 01:02:40 pm
content: that notation is just ambiguous - there's no real math question here...

author: Rerouter
author_rank: Super Contributor
timestamp: August 03, 2019, 01:06:42 pm
content: 8 / 2 * (2 + 2) =?Both methods describe division / multiplication to be interchangeable, and to solve them in left to right order when not otherwise marked out, it would only be if you forgot the rul for the PEDMAS acronym, that MD and AS are local groupings treated left to right, not a fixed order.so8 / 2 * (4)4 * (4)16

author: ciccio
author_rank: Frequent Contributor
timestamp: August 03, 2019, 01:57:02 pm
content: I really disagree.I don't know what BODMAS or PEMDAS mean (I'm too old for it) , but my anser is1or maybe8, but please ask a correct question.The original question isbadly written.There should be more brackets... Missing them, it can be read in many ways:- 8/(2*(2+2)) = 8/(2*4) = 8/8 =1 (this was my first answer) or- (8/2) * (2+2) = 4 * 4 = 16I'm open to any explanation about the second being correct one and the first wrong.I could not have an answer from Excel, my copy (2003) cannot solve the question by writing the equation in a single cell, but maybe it's my fault...edit: I've read the article quoted by the OP, and I find interesting that the majority of readers gave the wrong (according to the author ) answer.This coud open a Pandora box of discussions, so I will not go further...Best regards

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 03, 2019, 02:00:06 pm
content: Quote from: bostonman on August 03, 2019, 12:55:38 pm

author: mathsquid
author_rank: Frequent Contributor
timestamp: August 03, 2019, 02:11:08 pm
content: Quote from: Rerouter on August 03, 2019, 01:06:42 pmExactly. This is unambiguous, but horribly written. It reminds me of the Obfuscated C contest.https://www.ioccc.org

author: nixxon
author_rank: Frequent Contributor
timestamp: August 03, 2019, 02:11:28 pm
content: The top answer seems reasonable:https://www.quora.com/Should-we-follow-BODMAS-or-PEMDAS-in-mathematical-calculations-One-says-to-do-multiplication-first-and-then-division-and-the-other-says-the-reverse-To-evaluate-an-expression-like-6-2*3-which-set-of-rules-are-to-be-followedOnly division/addition is the problem. Then left to right solving seems sensible.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 03, 2019, 02:23:12 pm
content: It is ambiguous. It is exactly the same thing as whether 1/2x is equal to (1/2)x or 1/(2x). There is no universal rule which one is correct (even if you happen to have been taught one, others have been taught a different one, and the rest of us that the order depends on the context).The correct answer is that the stated math problem is underspecified: no answer exists unless the exact precedence of multiplication and division is specified. The easiest, and most common, way to do that is to add one set of parentheses to remove the ambiquity.And before you ask, no, (1/2)x is not always equal to 1/(2x). For example, when x =i, i.e. x2= -1, (1/2)x = -1/(2x).

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 03, 2019, 02:29:13 pm
content: What many people don't realize is that BODMAS and PEMDAS can't be mathematically proven or constructed. They're taught their local version as gospel in school and too much weight gets attached to. In reality it's just agreed upon shorthand to imply absent information. People get confused and subsequently annoyed when they realize what they've learnt as truth is arbitrary and not an intrinsic part of mathematics and that's why you see these discussions. As is so often the case it's not a matter of one being right or the other. It's a matter of having a badly defined and constrained problem and therefore more than one valid output. A few brackets would have eliminated any ambiguity and nipped any discussion in the bud.

author: ajb
author_rank: Super Contributor
timestamp: August 03, 2019, 02:33:07 pm
content: Quote from: bostonman on August 03, 2019, 12:55:38 pmOrder of operations isn't a mathematical law, it's a convention for interpreting expressions. A much simpler convention would have been to just evaluate left to right, but for whatever reason the dominant convention became that you always multiply or divide before adding or subtracting. That's why 2+3*4 is conventionally 12 instead of 20. The fact that you can use brackets to override the standard order of operations is only possible because the standard way is arbitrary to begin with.I didn't realize that there were two popular conventions that placed multiplication and division in different orders. I vaguely recall being taught that those were supposed to be done left-to-right, but maybe my elementary school education and programming experience are just voting together at this point.

author: SparkyFX
author_rank: Frequent Contributor
timestamp: August 03, 2019, 02:49:57 pm
content: 8 / 2 * (2 + 2) =?it is either82 * (2+2)or8--- * (2+2)2No idea what BODMAS or PEMDAS might mean, but a slash is an improper division line here, and thats the whole "problem". Which means whoever wrote it needs to clarify what he or she means.

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 03, 2019, 02:52:04 pm
content: Yeah it's absolutely not a math problem and is not breaking anything except asses who think that pressing keys on a calculator is doing math.Good lord...

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 03, 2019, 02:59:14 pm
content: Quote from: SiliconWizard on August 03, 2019, 02:52:04 pmAsk an ambiguous question everyone has an ill informed opinion about and profit. I've seen multiple versions of this go around and nothing is breaking the internet. It's just simple clickbait to incentivize traffic. I guess we fell for it too although I'm reassured by the amount of sense in this thread.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: August 03, 2019, 03:02:55 pm
content: I just feel sorry for people who don't represent everything in RPN and for cases where RPN isn't available I fallback on what I was taught in my BCPL lecture!

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 03, 2019, 03:23:36 pm
content: I wouldn't say everyone has an "ill informed opinion"; I think it is more about human tendency to seek authority or authoritative answers rather than accept ambiguity.For example, if you check the history of bugs in Excel, you know it cannot be trusted as an authority for, well, anything. Or, whether colour, or color, is the correct spelling. Or whether one should use ß or ss. Or how many letters are there in the alphabet.Even mathematical notation is just a matter of agreement. We have several, including reverse Polish (RPN) or postfix notation; no single one is more correct than any other. (Some are less ambiguous than others, however; postfix notation being among the most unambiguous ones.)In fact, what most people call math, is itself a system based on root axioms which we must accept as "truths" for it to make sense; other mathematics are equally possible.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 03:32:01 pm
content: Quote from: NivagSwerdna on August 03, 2019, 03:02:55 pmBCPL? Pah.Importantly neither BCPL nor ALP is maths, but use APL to evaluate777-707-7-777-7-7-70https://tryapl.org/

author: schmitt trigger
author_rank: Super Contributor
timestamp: August 03, 2019, 03:33:06 pm
content: The New York Times has an article written by a mathematician about this debate:https://www.nytimes.com/2019/08/02/science/math-equation-pedmas-bemdas-bedmas.html?nl=todaysheadlines&emc=edit_th_190803?campaign_id=2&instance_id=11317&segment_id=15843&user_id=10ca517e806ee8b2b6c2d219d309c7d0&regi_id=371077490803

author: SiliconWizard
author_rank: Super Contributor
timestamp: August 03, 2019, 03:37:54 pm
content: Again that's a problem of people thinking that writing a succession of digits and operators like they would press them on a typical calculator is writing correct algebraic expressions. It's not.Learning how to use a calculator, be it in algebraic or RPN mode, is not learning math, and it doesn't define correct math notation either.Now obviously every time people don't have easy access to a proper math notation tool for publishing an algebraic expression, they can fall into the trap. The way to go is pretty simple though, every time the computer-like (pure "ASCII" we could say) notation could be ambiguous compared to the proper math notation, use parentheses. And don't try to be overly clever about the use of operator precedence, because in many cases it won't end up clever at all.But sure this kind of clickbait "problems" are ubiquitous on the internet, it goes from simple math stuff like here, to erroneous "proof" that 1=-1, to ambiguously perceived colors on some ugly pictures, etc.The list is endless. It does create huge traffic because it all works on the same principle: it drives people into a competitive mode in which everyone will be dead sure they are right and, the other side, wrong, regardless of the relevance of the question.

author: soldar
author_rank: Super Contributor
timestamp: August 03, 2019, 03:38:52 pm
content: Didn't we do this topic quite recently?There is no right or wrong. The order of operations is a convention. Whatever is the convention being used that is the right answer.

author: IanB
author_rank: Super Contributor
timestamp: August 03, 2019, 03:43:30 pm
content: Some considerable discussion here:https://youtu.be/vaitsBUyiNQApparently the conventional answer would have been different 100 years ago.What is wrong with this question is it asks people to apply rules defined by other people. If you follow the rules you are "right", and if you don't follow the rules you are "wrong". This divides people into two camps: rule followers or free thinkers. So this question is actually not a math question, it is a social question.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 04:01:38 pm
content: Quote from: IanB on August 03, 2019, 03:43:30 pmThank heavens for that. IknewI was right to think the answer is 42.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 04:07:10 pm
content: Quote from: SiliconWizard on August 03, 2019, 03:37:54 pmHere's nice proof that 1=-1. It doesn't involve "hidden" zeros, most people can correctly state where the error occurs, but too few can saywhatthe error actually isnow 1: sqrt(-1) = sqrt(-1)therefore 2: sqrt(-1/1) = sqrt(1/-1)therefore 3: sqrt(-1)/sqrt(1) = sqrt(1)/sqrt(-1)therefore 4: sqrt(-1)*sqrt(-1) = sqrt(1)*sqrt(1)therefore 5: -1 = 1Q.E.D.EDIT: correct that in the light of IanB's correct observations. I am annoyed (at myself)

author: Nusa
author_rank: Super Contributor
timestamp: August 03, 2019, 04:20:13 pm
content: Multiple issues here. Note that the original posters linked example is "8 / 2(2+2)"First is that many people are mis-using the mnemonic they may have learned, assuming they ever learned it correctly. The PEMDAS, BODMAS, BIDMAS and similar mnemonics actually all agree with each other. It's just that some have forgotten that multiplication and division are grouped as equals, as are addition and subtraction.PEMDAS = Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction.BODMAS = Brackets, Order, Division and Multiplication, Addition and SubtractionBIDMAS = Brackets, Indicies, Division and Multiplication, Addition and SubtractionInterestingly, most people that have trouble treating division and multiplication as equals don't have that same problem with addition and subtraction. For instance, does 10-5+2 equal 7 or 3?Second is that there is another issue in the original example, which is whether implied multiplication has a higher precedence than normal multiplication. Namely, is 8/2x the same as 8/2*x? Even some professionals have disagreed on this one. It's even better to use brackets for clarity.

author: HighVoltage
author_rank: Super Contributor
timestamp: August 03, 2019, 05:33:13 pm
content: I am more confused about the fact that this little math question confused people !

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 03, 2019, 05:45:04 pm
content: Quote from: HighVoltage on August 03, 2019, 05:33:13 pmThat's why it's fertile clickbait. The other camp can't imagine the confusion either but has another solution and thus a holy war is born. Note that quoting Excel, calculators or Wolfram Alpha doesn't prove a point either way for reasons already discussed.

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 03, 2019, 05:55:49 pm
content: Python says 16. Don't have the time to test it in every programming language, but it would be interesting to find one that gave a different answer and why.Quote from: tggzzz on August 03, 2019, 04:07:10 pmI wonder how many incorrectly say that taking the square root of a negative number is "impossible" and how many correctly explain the weird world of imaginary numbers.

author: IanB
author_rank: Super Contributor
timestamp: August 03, 2019, 06:19:40 pm
content: Quote from: IanB on August 03, 2019, 03:43:30 pmQuote from: tggzzz on August 03, 2019, 04:01:38 pmIndeed. I was perhaps being a bit too radical there. Anarchists of the world unite!Perhaps I should have said instead: if you follow one set of rules you are "right", and if you follow a different set of rules you are "wrong". Thus dividing people into two camps, "us" and "them".Mathematics is about playing games with logic, and everyone playing a given game should agree on a common set of rules or the game doesn't hold together. But there can be other games with different rules. It just requires everyone to agree up front what the rules are for a given game. If the rules are internally and logically consistent you have mathematics, and if not you don't.

author: IanB
author_rank: Super Contributor
timestamp: August 03, 2019, 06:23:23 pm
content: Quote from: tggzzz on August 03, 2019, 04:07:10 pmLet me see...now 1: a = atherefore 2: a/b = b/aLet's test this with an example: 2 = 2, therefore 2/10 = 10/2?Um, I don't think so...Seems like we can't get beyond step 2.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 06:36:29 pm
content: Quote from: IanB on August 03, 2019, 06:23:23 pmNow you are simply being annoying... by being correct. Trynow 1: sqrt(-1) = sqrt(-1)therefore 2: sqrt(-1/1) = sqrt(1/-1)therefore 3: sqrt(-1)/sqrt(1) = sqrt(1)/sqrt(-1)therefore 4: sqrt(-1)*sqrt(-1) = sqrt(1)*sqrt(1)therefore 5: -1 = 1and I've edited the original.

author: Domagoj T
author_rank: Frequent Contributor
timestamp: August 03, 2019, 06:45:28 pm
content: BODMAS and PEMDAS are equivalent.Multiplication and division have equal "rank", just like addition and subtraction. When there are more than one of them, then the first one to be solved is the one on the left. That means that the order is as follows:1. Brackets AKA parenthesis2. Orders AKA exponents3. Multiplication or division, whichever is the leftmost, repeat until there are no more4. Addition or subtraction, whichever is the leftmost, repeat until there are no moreThe reason for inverted order of DM/MD in acronyms BODMAS and PEMDAS is linguistic, not mathematical.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 06:49:42 pm
content: Quote from: NiHaoMike on August 03, 2019, 05:55:49 pmAPL, arguably thefifth programming language after Fortran, COBOL, LISP, Algol, and RPG:8 ÷ 2(2+2)4 28 ÷ 2 * (2+2)0.58 / 2 * (2+2)16 16 16 16 16 16 16 168 / 2(2+2)2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4The "why" is left as an exercise for the student. For further fun and games, go and play athttps://tryapl.org/https://en.wikipedia.org/wiki/History_of_programming_languages

author: amyk
author_rank: Super Contributor
timestamp: August 03, 2019, 09:38:51 pm
content: Quote from: NiHaoMike on August 03, 2019, 05:55:49 pmEvery programming language I can think of that has operator precedence will give 16, which is the correct answer when multiplication and division have the same precedence and associate left-to-right. If you think the answer is 1, then either you think multiplication has higher precedence than division or that they have the same precedence but right-to-left associativity (or both) leading to 8/2*4 ?= 8/(2*4) = 1.Ideally operator precedence should be taught by memorising a table, and not some stupid acronym (which can't express more than one operator at the same level, nor left vs. right associativity.)http://www.math.harvard.edu/~knill/pedagogy/ambiguity/index.html

author: Red Squirrel
author_rank: Super Contributor
timestamp: August 03, 2019, 10:16:49 pm
content: I've never been good at math so I guess my logic is wrong, but the way I always saw it is that when you use "/" as opposed to the actual division sign, you are grouping chunks of equation. You do everything on both sides separately. But I guess that's wrong, as the answer has clearly been established to be 16, and I won't argue that.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 03, 2019, 10:36:15 pm
content: Quote from: Red Squirrel on August 03, 2019, 10:16:49 pmIt's been clearly established both answers are correct as the problem hasn't been properly constrained.

author: Nusa
author_rank: Super Contributor
timestamp: August 03, 2019, 11:08:17 pm
content: Quote from: Red Squirrel on August 03, 2019, 10:16:49 pmWhen it comes to computers, how many people even know how to type the ÷ symbol? It's not found on most keyboards, so it doesn't get used at all for the most part. It may be someones attempt to explain away the problem they perceive, but it's clearly not a functional rule for communicating online. (Ditto for the older technology, which I'm old enough to have learned on. That symbol was unlikely to be found on most typewriters. Although many symbols were available as a special order for the better typewriters that had some keys and typebar slugs designed be swapped out.)Offline, there is no problem, because one can clearly show where the unwritten parenthesis belong by using horizontal lines for division and putting things above or below them as appropriate.

author: BrianHG
author_rank: Super Contributor
timestamp: August 03, 2019, 11:20:14 pm
content: How the hell is this so difficult?A)8 ÷ 2(2+2) = 16B)8= 12(2+2)Since the problem was written in format A), the answer is 16.

author: tggzzz
author_rank: Super Contributor
timestamp: August 03, 2019, 11:31:23 pm
content: Quote from: Nusa on August 03, 2019, 11:08:17 pmIBM selectric typewriters had golf balls that were changed on the fly. That's how typists could write things like "51" - rather slowly.In standard mathemetic notation the question as posed is unambiguous, and does not need any (more) parentheses. Similarly, 1+2*3 = 2*3+1 = 3*2+1 = 1+3*2 = 9.

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: August 03, 2019, 11:52:13 pm
content: Strictly using bodmas/bidmas its 16.I program a lot and always use plenty of brackets so there is no confusion.Its especially important when programming embedded C.Sometimes the compiler writer had their own ideas about precedence.

author: Nusa
author_rank: Super Contributor
timestamp: August 04, 2019, 12:09:48 am
content: Just for fun, since I already said plenty above:8 ÷ 2(2+2) =8 ÷ 2(4) =8 ÷ 2 * 4 =8 * (1/2) * 4 =8 * 0.5 * 4 =16Yes, multiplying by 1/x is the same as dividing by x, when x is not 0. And if x had been 0, you would have had a problem anyway.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 04, 2019, 12:14:27 am
content: Quote from: tggzzz on August 03, 2019, 11:31:23 pm7 = 8 = 9 = 8 = 9?

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 12:24:32 am
content: Quote from: nigelwright7557 on August 03, 2019, 11:52:13 pmYup.QuoteYou need to understand what the language standards allow the compilers to optimise. You will be unpleasantly surprised that brackets won't necessarily help you.I've only been programming in C since 1981, so I'm not an expert. For a solid answer, consult a language lawyer about "undefined behaviour" and "implementation dependent behaviour"

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 12:26:38 am
content: Quote from: Mr. Scram on August 04, 2019, 12:14:27 amNope. They all equal 9.Any other statement is mathematically innumerate. Full stop.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 04, 2019, 12:48:11 am
content: Quote from: tggzzz on August 04, 2019, 12:26:38 amJust badly constrained problems. The order of operation isn't part of mathematics as it cannot be proven or deduced and isn't a basic premise from which the rest is deduced. It's just cultural shorthand.

author: Rerouter
author_rank: Super Contributor
timestamp: August 04, 2019, 02:43:01 am
content: Its an agreed upon language of mathematics. Not very different from most programming languagesm by having a consistant order of operations you can take your math writted in the early 1900's and not have any ambiguity issues like this thread is discussing. If subtraction and division got flipped every few decades. That adds a lot of problems.

author: nigelwright7557
author_rank: Frequent Contributor
timestamp: August 04, 2019, 04:58:19 am
content: QuoteI find the embedded c compilers are worst for falling over with precedence, I rarely have problems with Microsoft C#.I once had a C programming exam.One of the questions was what is 2^5.Most people would have said its 2*2*2*2*2.In C there is no power function, ^ means xor.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 04, 2019, 05:23:25 am
content: Quote from: tggzzz on August 04, 2019, 12:24:32 amAlthough casts, since C99, oftendo:(float)(expression)yields the value ofexpressionlimited tofloatprecision and range, no need to use temporary variables. When you need efficient floating-point math, and don't mind subnormals being truncated to zero or how infinities/NaNs are handled, you can enable unsafe math optimizations (i.e., not exactly IEEE 754), but use such casts to ensure the compiler does not optimize entire expressions away at the algebraic level. It can make a significant difference to speed, as quite a lot of time spent in trigonometric function evaluation involves getting the corner cases (subnormals, infinities, etc.) right.That won't help with expressions involving undefined or implementation defined behaviour, of course.And, if your math does involve an occasional divide-by-effectively-zero and similar floating-point issues, you still need to do proper checks. I use Maple for most of my math grunt work, but there is always a lot of cleanup work to subdivide the expressions into "units" I can calculate and check at runtime (against zeros/infinities/negative values, etc). Yes, I know all about thecodegenmodule; even that won't help with this hand work, because it essentially operates at a different level than the expressions themselves.Which is exactly the issue in the topic of this thread:notationis not math, and some problems are underspecified, or require hidden assumptions to make sense. Context matters, especially the rules the context applies/requires to work or make any sense.

author: IanB
author_rank: Super Contributor
timestamp: August 04, 2019, 07:10:34 am
content: Quote from: tggzzz on August 04, 2019, 12:24:32 amThis is one of the reasons Fortran has been favored for numerical computations. Traditionally Fortran has honored parentheses, since they may be intentional to avoid loss of precision in an expression.

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 07:23:14 am
content: Quote from: Mr. Scram on August 04, 2019, 12:48:11 amPlease stop inventing strawman arguments; it doesn't make you look good.I've re-inserted the context you conveniently snipped to make your strawman argument, andemphasisedthe key clause so you can't miss it.If you use non-standard notation, thenyou can have any answer you want. That strikes me as pretty useless. For example, using APL the answer is indeed 4 2. Fromhttp://tryapl.org:8 ÷ 2(2+2)4 2

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 07:42:07 am
content: Quote from: IanB on August 04, 2019, 07:10:34 amYup. C and C++ can be entertaininly surprising in that respect, especially at high optimisation levels when the compiler canmake inferences about possible valuesmake use of "undefined behaviour" or "implementation defined" behaviourThere's alotmore of the latter than most people realise. A classic example is arithmetic operations on signed integers that result in an overflow. Many people will incorrectly presume the result wraps, but the compiler can correctly (as defined by the standard) optimise such operations away, or delete your source files, or cause demons to fly out of your nose!

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 04, 2019, 08:35:55 am
content: Quote from: tggzzz on August 04, 2019, 07:42:07 amAh yes, nasal daemons: my favourite.The implementation defined or undefined behaviour excuse from compiler writers when a single specific behaviour makes practical sense, but the compiler writers choose something utterly inane, is what made really turned me off from programming language lawyerism. GCC is no better than others in this manner, although there are a few devs that are also involved in the Linux kernel development, and are actually interested in how GCC behavesas a toolalso, not just what some mouldy standard says.(Plus, I think the C standard is basically lost from C11 onwards; so much ridiculously silly stuff, and so hardcore rejection of known-good POSIXy stuff, likegetline(). C++ people usually disagree, even if the two are completely separate languages.)Because of this, truly portable and maintainable software has unit test cases for its internal assumptions. If the code assumes that integers and floating-point values have the same byte order (because it does floating-point radix sorting, for example), it better have an optional test case to verify that at build time. At minimum, such assumptions should be documented as comments where relevant.In the context of the topic at hand, it means that theproper questionregarding8/2(2+2)or8÷2(2+2)iswhat makes it ambiguous, so that some believe the answer is 1, and others 16, and maybe yet others something else.That sort of attitude is very important for computational physicists, those that use computers in an attempt to solve mathematically described physical problems. Whenever you get an answer, the first question one must ALWAYS ask isDoes this make any sense?In other words, do the built-in or hidden assumptions and rules in how this calculation or simulation was constructed, and the answers derived, support the context at hand?What does the answer actually mean? Does it answer the question I posed, or something completely different? Is it an answer at all?I wish more people cared enough to do that step, whenever they encounter a divisive question. Surprisingly often it is not the answers, but the hidden assumptions and axioms ("given truths"), that clash. Which means that people spend lots of energy arguing whose unstated/hidden set of truths (that they are not willing to reconsider or even describe in detail, usually), is better than everyone elses. Silly supremacists, stop stupremicing!

author: StillTrying
author_rank: Super Contributor
timestamp: August 04, 2019, 09:54:31 am
content: My cheap "Tronic" calculator gives8 / 2(2+2) = 18 / 2*(2 +2) = 16

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 10:35:09 am
content: Quote from: Nominal Animal on August 04, 2019, 08:35:55 amYes, "sanity checking" is too rare. Sensitivity analysis is another rare activityLast I heard you couldn't implement the multicore/multithread aspects of POSIX in C - POSIX relies on things that the C standard explicitly doesn't define.That may have changed with the latest standards, now that they've included a memory model - a quarter of a century after Java. Whether that model is correct/sufficient (it is a hard problem!) and whether a compiler implements it correctly is still to be proven. And then a mere mortal programmer has to understand it, get their code and compiler flags right, and hope the library authors did so too.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 04, 2019, 12:08:15 pm
content: Quote from: tggzzz on August 04, 2019, 07:23:14 amCalling it "standard" implies it's some kind of rule or intrinsic part of mathematics, which it obviously isn't. Standard, convention, The Super Secret We've Learnt Math the Same Way in School So This is How it's Done According to Us Club. Call it what you want, it all boils down to the same thing. Define a problem properly within the mathematical system that does exist and there's no issue.

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 12:38:49 pm
content: Quote from: Mr. Scram on August 04, 2019, 12:08:15 pmNo, it doesn't, unless you are using the word "standard" like Humpty Dumpty uses the word "glory".QuotePrecisely -and necessarily so. If you don't have a common language, you can't communicate.Basically your position appears to be that memorably skewered by a mathematician (Lewis Carroll) in his justly famous conversation between Alice and Humpty Dumpty...QuoteUnless you can't be bothered to communicate with others, I strongly suggest you read that classic and very pertinent chapter:http://www.alice-in-wonderland.net/resources/chapters-script/through-the-looking-glass/chapter-6/

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 04, 2019, 01:07:55 pm
content: Quote from: tggzzz on August 04, 2019, 12:38:49 pmLet's approach this from a different angle. Let's get out of the land of fairy tales and even mathmatics and into the world of practical engineering and primate to primate communication. Let's for the sake of this discussion suppose there's an order of operation rule which is as hard as the actual deduced and constructed rules in maths. Let's also establish that where this rule is mentioned there's a lot of discussion and different answers are proposed for different reasons. That's not only true amongst the general public but also amongst trained engineers as is evidenced by this thread. It is from an engineering perspective a good idea to communicate your intent in such a way which leaves room for such discussions to arise and erroneous conclusions to be arrived at? We're not looking at the discussion itself and whether people are right or wrong, just at the fact that it exists. In engineering and design it's best practice to leave as little room for error as you can, especially when you can reasonably expect error to be introduced as is obviously the case here. Leaving room for error introduces error. Constrain your problem properly and there's no problem to be had.

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 01:33:04 pm
content: Quote from: Mr. Scram on August 04, 2019, 01:07:55 pmStrawman argument, again. The standard maths rulesarewell defined and understood.I, and everybody else at my school, was taught the standard rules of precedencewhen we were 12yo. And that was the case for people that wouldneverbe engineers nor mathematicians, and who would drop all STEM subjects as soon as they could (at 16)!So, where did you say you were educated in maths? What are your engineering qualifications?What evidence do you have that the people discussing things in this thread are "trained engineers"? If you do have any evidence, you had better define "trained" and "engineer", since you would be using those words in a way that is unfamiliar to me.Finally, the Alice books are remembered and quoted after 150 yearsbecausethey contain a lot of relatively subtle truths and get them over in a very entertaining way.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 04, 2019, 02:34:55 pm
content: Quote from: tggzzz on August 04, 2019, 10:35:09 amPOSIX adds constrains C leaves implementation defined, yes. If you are referring to things like the socket address structure implementation details, that goes into language lawyerism I don't want to get into. Note that I only referred to completely unambigously C-friendly aspects of POSIX; getline() is trivially implemented, but efficient really only when implemented in the C library (stdio implementation, using library internals) itself. There are quite a few others, implemented for at least two decades in SVr4/BSD/SUS/POSIX. I am not suggesting incorporating POSIX into C, because a certain company will rather shit on the standard than let that ever, EVER happen.At one point, I did try to push a bit for amemrepeat(dst, size, count)ormemrepeat(dst, offset, length)type function, that would allow one to fill a region of memory by repeating an initial part. It is obvious, but only relevant in such rare cases (initializing matrices to floating-point values in particular) that nobody cares.I do not think the C standards committee is interested in developing the language to better suit the needs of programmers anymore. They are interested in enabling their respective compiler vendors to changes that allow them to combine their C and C++ compilers, and add "extensions" that discourage programmers to investigate how to port their software to other vendors' operating systems. You know what I'm talking about, I'm sure. (I get called a conspiracy theorist, but anyone looking at the C11 standard is either utterly stupid, or sees the basis behind my accusation.)Memory models are one set of axioms that seem to have slipped in to computer architectures without proper examination of their interaction with speculative execution. (Again, similar to how in the math problem at hand, it is the "rules" that clash, or rather the assumptions of which rules ought to be followed.)Personally, I utterly dislike speculative execution due to the exponential increase in complexity (and combined with the security aspects, just makes the potential boost not worth it), just like I dislike hidden rules that are assumed to be sacrosanct.Quote from: tggzzz on August 04, 2019, 01:33:04 pmYouclaimthere are standard math rules, then defend it by saying that was how you and your cohorts were taught at age twelve.No. Just because you think there is a fixed set of rules everyone follows, or at least should follow, does not make it so.Because there are people who believe the result is 1 and not 16, your claim is refuted.You can claim everybody else is wrong, but because both infix and postfix notation are relatively common, and other mathematical notations exist (especially strict left-to-right, as implemented by many calculators), and those are used successfully to solve mathematical problems, such a claim is just silly and juvenile; completely without any basis in reality.You can base your claim on some authority, but that is just another fallacy.

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 04, 2019, 02:41:38 pm
content: The infix precedence rules that e.g.Wikipedialists, are only about fifty, sixty years old. Even math texts from early 1900s may have different rules.It makes it rather interesting, when one tries to look at some of the old groundbreaking articles. The notation they used was wildly different. In fact, they often used their own notation, because they felt it was easier to express the underlying ideas that way; and it wasn't considered anything weird back then.I wonder if human minds are becoming increasingly inflexible and ossified, only capable of considering one set of facts or rules at a time as plausible?

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 03:08:04 pm
content: Quote from: Nominal Animal on August 04, 2019, 02:34:55 pmQue? How do you get that chain of reasoning?QuoteThere are standard maths rules, and I am quite explictly talking about those.There are also many other rules, and I have given examples of those.QuoteNot true. Just because other people areunwittinglyusing different rules doesn't change the fact that there are standard maths rules.QuoteThere are some correct facts in there (and I have given some more unusual examples w.r.t. APL), but that chain of reasoning is faulty.

author: Fred27
author_rank: Unknown
timestamp: August 04, 2019, 03:18:56 pm
content: If you got all worked up over that, then you'lllovethis one!QuoteThe original source worth checking out for the comments:https://twitter.com/kj_cheetham/status/1149966666836656128

author: bson
author_rank: Unknown
timestamp: August 04, 2019, 05:08:50 pm
content: Quote from: Nusa on August 03, 2019, 04:20:13 pmThat's what I was taught, that implied multiplication has higher precedence than explicit multiplication, or division. So 8/2(2+2) = 8/(2*(2+2)) = 1. Or even 8/(1+1)(2+2) = 1.Maybe this stopped being the standard in STEM programs at some point.But it certainly makes notational sense as it blends with operator notation (like dx/dt, or fx). If you write 8/f(2+2) otherwise you'd need to know what 'f' is to correctly parse it. (More specifically, you run into the fortran problem where syntax depends on typing.)But this is probably all out of scope for non-STEM fields and underscores the importance of writing for your audience.

author: tggzzz
author_rank: Super Contributor
timestamp: August 04, 2019, 05:33:51 pm
content: Quote from: bson on August 04, 2019, 05:08:50 pmWith tongue in cheek, I've noted that "exotic" maths notations are designed so that you can have addition, subtraction and multiplication operators/operations. Division is usually missed out

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 05, 2019, 06:59:52 am
content: Quote from: tggzzz on August 04, 2019, 03:08:04 pmJust because you were taught that "these are the standard rules", does not make it so.For example, I could claim that I am a standard human, and everyone who differs from me is a deviant. Any attempt you make at defeating that argument, I can use to defeat your argument.There just isn't that kind of an agreement among humans. You could say that the intent in the last fifty, sixty, or seventy years has been to try andestablishsuch a standard, but it has failed, chiefly because of the adoption of the two most common mnemonics (PEMDAS and BODMAS), as they fail to account for left-to-right order among operations with the same priority.Simply put, this is because there is no standards body for human behaviour. For a standard to emerge, almost all humans would have to agree. This is exactly why there is no single "English" language either.Quote from: tggzzz on August 04, 2019, 03:08:04 pmUnwittingly or not, out of stupidity or of brilliance, does not matter, because there is no standards body for humans.(Note that I do wish you were right, and there were standards we could rely on. It is just that I acknowledge that we simply do not have a reliably established one for math notation. There is also a more fundamental issue beneath, one related to the "stupremacy" I referred to earlier, and that is the futility of forcing "standards" of any kind on humans from above: it will not work without violence. For any kind of standard to emerge, you have to have agreement first. Here, the true culprit is the use of mnemonics that do not capture the rules correctly, their adoption, and general human unwillingness to discard "stale knowledge" and adopt new patterns of thinking.)

author: tggzzz
author_rank: Super Contributor
timestamp: August 05, 2019, 08:09:28 am
content: Quote from: Nominal Animal on August 05, 2019, 06:59:52 amWhat left to right order?Ah! The light bulb goes on.You don't seem to realise thatarithmetic operations in computer languages or calculators only have a passing relationship with mathematics, even though they use similar notation.Have a look athttps://en.wikipedia.org/wiki/Commutativity#Commutative_operations_in_mathematicshttps://en.wikipedia.org/wiki/Associative_propertyRealise that arithmetic operations in computers arenotassociativehttps://en.wikipedia.org/wiki/Associative_property#Nonassociativity_of_floating_point_calculation

author: Nominal Animal
author_rank: Super Contributor
timestamp: August 05, 2019, 08:46:59 am
content: Quote from: tggzzz on August 05, 2019, 08:09:28 amPity that it goes on in a room in a completely different building.Quote from: tggzzz on August 05, 2019, 08:09:28 amYou don't seem to realize that tides are caused by the moon.Perhaps you should re-read this thread, so that you start talking about the topic at hand, and not about something completely different that happens to interest yourself.

author: soldar
author_rank: Super Contributor
timestamp: August 05, 2019, 11:54:07 pm
content: I can't believe this stupid issue is getting so much attention and traction.A formula means whatever the person who wrote it wanted it to mean.If there are several conventions then writer and reader need to follow the same convention to arrive at the same result. Does the convention being used deliver the intended result? That is the only thing that counts.If writer and reader follow different conventions then the formula needs to be translated from writer's convention to reader's convention.Conventions are not write nor wrong. They are conventions.In America, by convention, nautical lights are red on the right and green on the left when returning from the sea. In Asia the opposite is true, also by convention. Which one is right? Both are right in their own spheres.

author: SparkyFX
author_rank: Frequent Contributor
timestamp: August 06, 2019, 01:17:35 am
content: This is not about operator precedence, it is about how much of a term is tokenized and included in the divisor. Not that a different precedence or a single assumption about it could not lead to the expected result, it is one how someone shorted a 3 line term to one line and lost the information if the last part is in the divisor or not.My math teacher once said if the term is ambigiously written he will give 0 points in the test.Use parantheses, ffs.And of course ambigous questions are what trolls thrive in, so i don´t know what is so special about this one.

author: Mr. Scram
author_rank: Super Contributor
timestamp: August 06, 2019, 01:57:18 am
content: Quote from: tggzzz on August 04, 2019, 01:33:04 pmI'll ignore the ad hominem argument. As some have pointed out in this thread before, most people are looking for absolute truths and are generally uncomfortable with ambiguity. Learning something as truth at age 12 and having this enforced by endless exercises and then learning it's actually completely arbitrary would fit that category. The standard you're talking about is a standard and not the only standard which is why the problem isn't properly defined.

author: SparkyFX
author_rank: Frequent Contributor
timestamp: August 07, 2019, 01:26:16 pm
content: Quote from: Fred27 on August 04, 2019, 03:18:56 pmTotally got me, it´s really 5!

author: macboy
author_rank: Super Contributor
timestamp: August 07, 2019, 06:18:28 pm
content: Various math texts disagree about whether implicit multiplication is higher precedence or equivalent to explicit multiplication.If implicit is higher precedence, then:a(b) / c(d) = (a•b) / (c•d)or:a(b) / c(d) = \$\frac{a\cdot b}{c\cdot d}\$If they are of the same precedence, then:a(b) / c(d) = ((a•b) / c)•dor:a(b) / c(d) = \$\frac{a\cdot b}{c}\cdot d\$You can probably see why there is disagreement.