How’d They Calculate That?

News Brief by Kip Hansen

 

featured_image_how_countThere are two recent stories in the NY Times that bring up a curious seemingly inconsequential oddity of mathematical computing.  They are both written by Steven Strogatz in time order they were: “The Math Equation That Tried to Stump the Internet” and then, two days later, “That Vexing Math Equation? Here’s an Addition”.  Steven Strogatz is a professor of mathematics at Cornell and the author of “Infinite Powers: How Calculus Reveals the Secrets of the Universe.

So what’s this all about?  A Tweet — that’s right — a Tweet on what Strogatz calls “Mathematical Twitter”. The tweet was this:

oomfies solve this

problem

— em ♥︎ (@pjmdolI) July 28, 2019

 

That’s easy!  The correct answer is:

16or1

Yes, that’s right, the correct answer is either 16 or 1, depending on an interesting point of mathematics. The featured image gives us some insight into what’s going on here.   Strogatz explains it this way:

“The question above has a clear and definite answer, provided we all agree to play by the same rules governing “the order of operations.” When, as in this case, we are faced with several mathematical operations to perform — to evaluate expressions in parentheses, carry out multiplications or divisions, or do additions or subtractions — the order in which we do them can make a huge difference.”

 When we resort to our handy electronic scientific calculators, we find that my answer is absolutely right!

dueling_calculators

(This image was supplied by a twitter participant…see the twitter thread).

The Texas Instruments TI-84Plus C returns an answer of “16” while our Casio fx-115MS returns “1”.

A quick survey of online scientific calculators returns mixed results as well:

also_equals_16

equals_one

And maybe a bit more accurate:

equals_error

Math guys and gals know that the problem is order of operations and there are conventions for which operations come first, second, third and so on.  In high school we learn the convention as one of the following (depending on where you went to school):

BODMAS is an acronym and it stands for Bracket, Of, Division, Multiplication, Addition and Subtraction. In certain regions, PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction) is the synonym of BODMAS.

PEMDAS is an acronym for the words parenthesis, exponents, multiplication, division, addition, subtraction. Given two or more operations in a single expression, the order of the letters in PEMDAS tells you what to calculate first, second, third and so on, until the calculation is complete. If there are grouping symbols in the expression, PEMDAS tells you to calculate within the grouping symbols  first.

Strogatz  says:  “Strict adherence to this elementary PEMDAS convention, I argued, leads to only one answer: 16.”   Ah, but his editor ( and a slew of readers ) “…strenuously insisted the right answer was 1.”

To get Strogatz’s “16” one has to do this:  8/2 = 4  then do 4 x (2+2) or 4 x 4 = 16.

How to get “1” is explained in this quote from Strogatz:

“What was going on? After reading through the many comments on the article, I realized most of these respondents were using a different (and more sophisticated) convention than the elementary PEMDAS convention I had described in the article.

In this more sophisticated convention, which is often used in algebra, implicit multiplication is given higher priority than explicit multiplication or explicit division, in which those operations are written explicitly with symbols like × * / or ÷. Under this more sophisticated convention, the implicit multiplication in 2(2 + 2) is given higher priority than the explicit division in 8÷2(2 + 2). In other words, 2(2+2) should be evaluated first. Doing so yields 8÷2(2 + 2) = 8÷8 = 1. By the same rule, many commenters argued that the expression 8÷2(4) was not synonymous with 8÷2×4, because the parentheses demanded immediate resolution, thus giving 8÷8 = 1 again.”

So, if everyone followed exactly the same conventions, both when writing equations and in solving them, all would be well and we’d all get the answer we expected.

But…..

This [more sophisticated] convention is very reasonable, and I agree that the answer is 1 if we adhere to it. But it is not universally adopted. The calculators built into Google and WolframAlpha use the more elementary convention; they make no distinction between implicit and explicit multiplication when instructed to evaluate simple arithmetic expressions.

Moreover, after Google and WolframAlpha evaluate whatever is inside a set of parentheses, they effectively delete the parentheses and no longer prioritize the contents. In particular, they interpret 8÷2(2 + 2) as 8÷2×(2 + 2) = 8÷2×(4), and treat this synonymously with 8÷2×4. Then, according to elementary PEMDAS, the division and multiplication have equal priority, so we work from left to right and obtain 8÷2×4 = 4×4 and arrive at an answer of 16. For my article, I chose to focus on this simpler convention.

Our dear mathematician concludes:

 “Likewise, it’s essential that everyone writing software for computers, spreadsheets and calculators knows the rules for the order of operations and follows them.” 

But I have already shown that writers software do not all follow the same conventions….Strogatz points out that even sophisticated software like WolframAlpha and Google’s built-in calculator in GoogleSearch don’t follow the  sophisticated rules and get “16”.

wolfram_alpha_16

google_search_16

The final statement by Strogatz is:  “Some spreadsheets and software systems flatly refuse to answer the question — they balk at its garbled structure. That’s my instinct, too, and that of most mathematicians I’ve spoken with. If you want a clearer answer, ask a clearer question.”

Update Before Publication:  The NY Times’ Kenneth Change waded into the fray in today’s (Aug 7) Science section with “Essay:  Why Mathematicians Hate That Viral Equation“.

# # # # #

I hope that you have found this essay either instructive or amusing.  The real basic on this issue is that original problem written as “8 ÷ 2(2+2)” is intentionally badly formed so as to be ambiguous.

It does bring up a very serious question:  If simple mathematical equations can be interpreted and solved to different answers, depending on the order of operations and given that even serious mathematical software differs in conventions followed,  what of very sophisticated mathematical models, in which variables are all inter-dependent and must be solved iteratively?

In CliSci, do we get different projected future climates if one changes the order of calculation?  I mean this not in the simple sense of the viral twitty equation, but in a much more serious sense:  Should a climate model, a General Circulation Model, first solve for temperature?  Or air pressure? Or first consider incoming radiation?   Here’s the IPCC diagram:

GCMs_IPCC

I attempted to count up the number of variables acknowledged on this simplified diagram, getting to a couple of dozen before realizing that it was too simplified to give a real count.  Each variable affects at least some of the other variables in real time.  Where does the model start each iteration?  Does it matter which variable it starts with?  Does the order of solving the simplified versions of the non-linear equations make a difference in the outcomes?

It really must — I would think.

Do all of the western world’s GCMs use the same order?  What about the mostly independent Russian models (INM-CM4 and 5)?   Do the Russian models produce more realistic results because they use a different order of operations? Do they calculate in a different order?

I  certainly don’t know — but it is a terrific question!

# # # # #

Author’s Comment Policy:

 There is always yet another really great question to be asked.  Don’t ask me the one above, I don’t know the answer but I’d love to read your ideas.  If you are involved in a deep way with GCMs, please try to give us all a better understanding of the order of operations/order of calculation issue.

Start you comment with “Kip…” if you’re speaking to me.  I do read every comment that you post under any essay I write.  I try to reply when appropriate and try to answer questions when I can.

# # # # #

0 0 votes
Article Rating

Discover more from Watts Up With That?

Subscribe to get the latest posts sent to your email.

483 Comments
Inline Feedbacks
View all comments
August 8, 2019 4:33 am

How come nobody has noticed that Strogatz is confused? PEMDAS and BODMAS give the same answer which is 16.

Editor
Reply to  Brian
August 8, 2019 6:22 am

Perhaps you should read the full post.

Editor
Reply to  Brian
August 8, 2019 11:20 am

Brian ==> BODMAS and PEMDAS are the same rule — just different was of remembering it. This is very clear in the essay definitions.

icisil
August 8, 2019 4:33 am

16 contradicts everything I’ve learned about math. Numbers without operation sign adjacent to parentheses always have precedence. If you want 16 type: 8 / 2 * (2+2)

Editor
Reply to  icisil
August 8, 2019 6:27 am

I went looking for references, see below. Please post references.

BTW, ‘*’ is not part of algebraic notation. I never used it through high school, but that was before the Computer Era reached there. We often didn’t use × because we often used x as a term.

D. J. Hawkins
Reply to  Ric Werme
August 8, 2019 4:08 pm

I was taught that “ab”, or “(a)(b)”, or “(ab)” were simply shorthand versions of writing “a x b”, nothing more or less. I have never found a reference to the superiority of “implied” multiplication.

Erik Pedersen
August 8, 2019 4:37 am

It’s simple actually; if you put brackets round the numbers after the division sign you will have one, 1, as answer. If you don’t do that you will have 16 as result.
8/2=4×4= 16…
8/2×4= 1…
The brackets makes the difference…
Simple, is it not..?

Dodgy Geezer
August 8, 2019 4:44 am

I see your problem!

You are not using the Climate Change convention. That operates by evaluating mathematical formulae from Right to Left, instead of from Left to Right.

Thus, in engineering you evaluate: Input1, Operator, Input2 ->Answer.

In Climate Science you evaluate: Desired Answer -> Input1, Operator, Input2, Operator, Adjustment Factor.

I hope that makes things clearer?

August 8, 2019 4:50 am

Meh, calculus ain’t so great.
It has its limits.

August 8, 2019 4:54 am

When I learnt maths the convention was to operate on the brackets first. But if you wanted that to work without a lot of dumb and possibly different rules you cannot get the single answer without. Why create complex problems when the answer is simple? Just add brackets so the problem appeared as 8 /(2(2+2)).

As to climate models, the type of statistical curve fitting to recorded data by combining the assumed effects of multiple variables with unknown actual relationships within a non linear system, by manipulating gains without understanding the actual relationships, cannot produce a model that proves anything scientific unless actual laws regarding the relationships are proven over the range of interests and can be repeated to validate them. The outputs of any prediction are just based on guesses and unlikely to predict reality, e.g. extrapolate accurately outside the data range. Only laws proven over the range under study will reliably extrapolate data extrapolate real data. That’s the real science I learnt as a physicist and engineer. Climate science is study of the real world, it has no supportable claim to knowing how our climate through understanding of the entire system. Models are helpful in understanding how things work, but not in predicting them.

Jos Hendriks
August 8, 2019 5:03 am

I find this article very, very ,very sad. Strogatz is wrong, totally wrong. I know a lot of textbooks about the fundamentals of arithmetics. There is no ambuigity, they all agree about the rules and the conventions how to interpret expression with +,-, *, :,^, (,) and (number)variables (always written as one letter a or b etc.)and a number or a variable followed by (. or two variables behind each other.
So, some of those rules:
1.Expression are read from left to right.
2. 3a or 3(….) is short for 3*a and 3*(…….) and abc is short for a*b*c
3. expression between ( and ) are evaluated first
4. when no ( and ) are left then the remaining expression is evaluated from left to right first the ^ and then multiplication and division in the order you find them and finally addition and subtraction in the order you find them.
So the only answer is 16 and TonyL is correct if he writes:
“All other answers are Wrong. Not faulty, not flawed, Just Plain Wrong”

If you find as an answer 1 with some calculator the calculator is not correctly programmed and the programmers made a bad mistake.

Strogatz don’t know where he is talking about, especially if he write:
even sophisticated software like WolframAlphaand Google’s built-in calculator in GoogleSearch don’t follow the  sophisticated rules and get “16”.

Well, believe me, there are real mathematicians at work at Wolfram. They know what they are doing. Strogatz not. There are no sophisticated rules there just rules and I don’t know any schoolbook in the Netherlands ( and I think I know most of them) that doesn’t handle this well. And I suppose that the situation in the States will be the same. So I am flabbergasted that people here can take answers other then 16 serious.

Editor
Reply to  Jos Hendriks
August 8, 2019 11:26 am

Jos ==> “I find this article very, very ,very sad. Strogatz is wrong, totally wrong.” Since Strogatz first takes one point of view, then changes sides, I’m not sure how he can be “totally wrong”.

I must warn that over-certainty can lead to serious error — it did for Strogatz. Strogatz is a really smart maths guy — a professor at Cornell and author of a very deep book on calculus. I doubt very much that he doesn’t know what he is talking about.

did you read carefully the explanation about explicit and implicit operations?

jos hendriks
Reply to  Kip Hansen
August 9, 2019 7:31 am

Kip –> The authority argument is not a very strong argument. If it was then this site should not exist. After all it is already a long time ago that the chairman of the IPCC declared: “the science is settled” . Should we all except this?

So again: if someone somewhere writes down 8+2(2+2), without any context, then evaluating give 16 AND NOTHING ELSE. Conventions for interpreting are clear: 2(2+2) means the same as 2*(2+2).

But let me look at the article a bit further: I have no reason not to believe you that mr Steven Strogatz is a clever mathematician. But when I compared the two online scientific calculators I notice that they are not in conflict! The two calculators calculate different expressions. The divisor symbol (/) is not the same as the quotient symbol (———). To make this very clear 5+3 ——-3+5 (the quotient of 5+3 and 3+5 gives 1. But 5+3/3+5 gives 11. I am sure we agree on that. In an expression written as a quotient, numerator and denominator are evaluated first. Obvious Mr Strogatz missed that. And so sad, many readers at Wuwt also.

The Casio is wrong. Already more then 30 years ago when I had to advice all schools in the Netherlands which calculator students should use I had to advise to forbid the casio. There were more problems with the casio, then. I remember that the casio used the same number of digits in their final answer as in the internal calculations. The Texas Instrument calculator used 3 more. Not using a sufficient number of digits can give surprising answers.

Then Mr. Strogatz writes: “In this more sophisticated convention, which is often used in algebra, implicit multiplication is given higher priority than explicit multiplication or explicit division, in which those operations are written explicitly with symbols like × * / or ÷. “

Sophisticated? Often used? I don’t know any algebra book, any textbook about arithmetic, any math program language that use what mr Strogatz calls implicit and explicit multiplication and that gives a higher priority to the first one. Sure, you can change the meaning of any part in expressions like 8+2(2+2), but then you have to say so, you have to write it down, you have to make it explicit. And then the evaluation of the expression can have a lot of different answers. For instance there are (part of) algebra books and programming languages in which the order is reversed and expressions are evaluated from right to left. But that is made very explicit in those books and languages.

For fun: 8+2(2+2)=0 .
This is very possible in a special math context. What should I made explicit?

Mr. Strogatz might be clever, might be a professor, might even be a mathematician. Then he may confuse his colleagues. He may confuse me (but then he should write a much better and documented article). But confusing ordinary people I think is a bad thing. I saw the title of his book:
“Infinite Powers : The Story of Calculus – The Language of the Universe – The most important discovery in mathematics”
And I shivered.
I am sadder now.

Reply to  jos hendriks
August 9, 2019 8:55 am

jos: “5+3/3+5

What changes when you write this in the same format as the expression in question?

5+3 / 3+5

There is a big difference between the two.

jos hendriks
Reply to  Tim Gorman
August 9, 2019 9:48 am

You really mean there is a difference possible in interpretation 5+3/3+5 and 5+3 / 3+5. So, how big the space must be to make the expression different? And if I write it down with a pencil, how much space must I leave open? Come on, it’s ridiculous.

Reply to  jos hendriks
August 9, 2019 1:33 pm

jos: “Come on, it’s ridiculous.”

No, it’s not. It’s exactly like emphasizing different words in a sentence.

BTW, you didn’t answer my question, what would change in the way you evaluate the two different written expressions? All you did was employ the argumentative fallacy known as Argument by Dismissal.

Espen
August 8, 2019 5:05 am

I’m getting pretty tired by these math “puzzles” that all depend on the precedence rules for the division sign :. Anyone with some math experience knows that using : in complex mathematical expressions is just a no-no, exactly because it makes the expressions so hard to read. Any sane person uses fractions instead of expression with division signs. And any sane person adds an extra pair of parentheses whenever it makes the expression easier to read, even if they aren’t strictly necessary.

Reply to  Espen
August 8, 2019 5:44 am

Yep. When in doubt add more parentheses.

Vuk
Reply to  David Middleton
August 8, 2019 6:16 am

as in here:
Y=60*(2+COS(3*PI()/2+2*PI()*(Ax-1941)/118)+0.5*COS(2*PI()*(Ax-1941)/289.5))
sunspot cycles max emulation equation (by myself of course 🙂 )
(if in doubt for the SC24 substitute Ax with 2014, the year of its max, it gives result is in the classic Wolf numbers)

Vuk
August 8, 2019 5:24 am

Kip
Anyone interested in the history and rules of arithmetic might findof interest ‘The Whetstone of Witte’ by Robert Recorde of Wales (1557) apparently the first book in English that contains the use of plus, minus, division multiplication and equals signs. Not easy to read, I myself like the pictures 🙂
https://archive.org/download/TheWhetstoneOfWitte/TheWhetstoneOfWitte_text.pdf

Editor
Reply to  Vuk
August 8, 2019 11:27 am

Vuk ==> Thanks for the historical perspective and the link.

StephenP
August 8, 2019 5:25 am

At my junior school we had the choice of BODMAS or Blessings On My Dear Aunt Sarah, BOMDAS. Both of course gave the same answer.
When setting up spreadsheets I have always found it vital to check and check again that the formula gives the expected answer. Usually this involved setting the individual steps in a calculation in brackets.

Kip, OT but have you got any further with your study on plastic micro-plastics in the ocean?

Editor
Reply to  StephenP
August 8, 2019 11:30 am

Stephen ==> I am waiting for more science on the micro-plastics issue. It is pretty certain that floating pelagic plastic degrades to smaller and smaller pieces which are then consumed in entirety by micro-organisms. We need a little more confirmatory evidence to declare victory on that front.

Petras
August 8, 2019 5:31 am

Just like the debate over the Oxford comma.

Editor
Reply to  Petras
August 8, 2019 5:54 am

That’s a very good analogy. I’ll keep it in mind.

Anthony M Cooke
August 8, 2019 5:36 am

This raises a whole lot of questions regarding standardisation of temperature measurement and more importantly of adjustments (even though I think that such are completely unjustified). In science a measurement is a measurement and it is usually not justifiable to change it at all. You may suspect that it is in error but if you are using measurements in a model and the model does not align with the measurement then the model is wrong or incomplete. A good example may sea levels – if the tide gauge that has been in the same location for a century does not show any significant change in mean tide then this surely suggests that there has been no change. If your model does predict a change then maybe the model is wrong or it does not take into account that the tide gauge has changed in elevation i.e. it is inadequate. Frankly, the more I see and read of GCMs, and read of continuous adjustment of temperatures the more I think the GCMs are wrong.

Photios
August 8, 2019 5:37 am

Tax accountants use similar software.

Editor
August 8, 2019 5:39 am

Does the order of solving the simplified versions of the non-linear equations make a difference in the outcomes?

It really must — I would think.

I suspect a far more important issue is that you’re assuming that digital computers have infinite precision. They don’t:

$ python
>>> 1./3 – 0.3
0.033333333333333326

For my very first significant programming project, I decided to write a program to simulate the flight of the Apollo missions. Christmas and classwork derailed that, but I did come up with some surprisingly good design in simulating satellite and comet orbits. However, my circular orbits “decayed”. Some of that improved when I started using atan2() instead of atan(), but I never really dug into exactly what all the problems were.

The big one, I’m sure, is that to come up with an accurate simulation, you want very small time steps. A simple implementation leads to many, many calculations that increase a variable by a small amount. We call it “1 + epsilon”. In my case, I think the program was using single-precision math, (this was back in Univac 1108 days in Algol). This sort of math takes the “mantissa” of the floating point number, maybe 27 bits long, and adds something that might be only 10 bits long. It doesn’t take long for problems to accumulate. (I forget if the 1108 used the IEEE floating point standard – I’m skipping a huge amount of nitty-gritty about decimal floating point math.)

I’d like to play with a binary/recursive decompostion, i.e. to compute 1024 steps, first compute just the change in 512 steps the add it in. To compute the change in 512 steps, add the change in both 256 step pieces, all the way down to one step. That makes it become an epsilon + epsilon problem and should be much more accurate.

Perhaps I’ll return to that project after retirement. It turned out to be some very nice code. Whenever I revisited it to see how much my programming technique had improved, I was struck by both the very good structure in the program and my code for adjust the time step size based on the distance between Sun and comet was beyond anything we talked about in a simulation course.

As for today’s General Circulation Models, I’ve never dug into their code. I could well get sucked into that once retired. I suspect the trip would be terrifying.

Don K
Reply to  Ric Werme
August 8, 2019 6:35 am

Ric — as you’ve mentioned, there is an IEEE standard for floating point math. I don’t recall the spec Identification. The spec is quite lengthy and addresses issues like how many extra (non-significant) fractional digits must be used in calculations to prevent (or, at least strongly discourage) rounding/truncation problems. It also specifies how rounding should be done. “Round to even” as I recall, but I’d be hard pressed to describe the details of “Round to even”.

Anyway, for a wonder, the computer industry universally embraced the concepts and 2+ 2 = 3.99999 pretty much became a thing of the past in the early 1960s. Wikipedia tells me that the Univac 1100 series dates to 1962, so it could have been IEEE compliant. Or not

Editor
Reply to  Don K
August 8, 2019 7:14 am

My solution was to get interested in OS kernel and networking programming. Not many floating point operations there except for the Unix load average (which may not even use floating point).

I should give you a pass, but this stupid math “taunt” puts me in a bad mood every time some twit (Kip included) reminds me of it.

2.0 and other small enough integers are precisely represented in floating point, at least in schemes I’m familiar with. So are fractions of 2 (negative powers of 2), e.g. 0.5, 0.25, 0.125. Think “multiple of a power of 2.” Fractions involving any other prime number, e.g. 1/3, 1/5, 1/7, 4/5 are not multiples of a power of 2, even those that can be precisely represented in decimal, e.g. 4/5 = 0.80000….

So if your computer says 2+ 2 = 3.99999, get yourself a fixed computer. 🙂

Clyde Spencer
Reply to  Don K
August 8, 2019 3:01 pm

Don K
Many years ago I used the approach of System Dynamics modeling with BASIC on an Atari to try to determine the terminal velocity of a falling object. To my surprise, as the object approached the actual terminal velocity, the velocity started to oscillate wildly. Round off error!

Don K
Reply to  Ric Werme
August 8, 2019 7:19 am

“As for today’s General Circulation Models, I’ve never dug into their code. I could well get sucked into that once retired. I suspect the trip would be terrifying.”

I looked at one of the GCMs briefly a year or three ago. My impression is there are maybe 80 fairly complex equations that need to be solved for each “time step”. My guess is that most don’t/can’t actually do much except burn computer time, and that the results are dominated by a few terms. At least that’s how it works with orbit determination/prediction. On the other hand, Orbit prediction is much simpler physics and is typically “kept honest” by acquiring additional position/velocity data over time.

My superficial impression of the GCMs is that they would be difficult or impossible to verify and that they would likely be prone to accumulating large errors over time. But maybe there are mitigating factors.

Don K
Reply to  Ric Werme
August 8, 2019 7:49 am

The big one, I’m sure, is that to come up with an accurate simulation, you want very small time steps

FWIW, I actually worked with orbit/trajectory software in the 1960s. Mostly testing, but I did some coding at times. What they did was start with a position and velocity and compute an acceleration vector based on the forces (e.g. gravity, drag) acting on the object. Then they took a time step and computed a new acceleration vector. If it was really close to the old acceleration, the position, velocity, and time were updated. If the acceleration had changed significantly, they cut the time step size (halved it?) and tried again. Repeat until the time step is small enough that the accelerations don’t change (much).

As I recall was also a mechanism for increasing the time step size when things were going well. I never had to look at that and have no idea what the algorithm was.

Anyway, there were LOTS of problems, but the numerical integration seemed rock solid.

Hardware was various CDC machines — 1604, 3600, 3800, 6400, and even (once) a 7600.

Editor
Reply to  Ric Werme
August 8, 2019 11:33 am

Ric ==> Sounds like fun — a lot of the nitty-gritty details are much more important than we normally let on.

I do think the order of calculation is terrifically important in GCMs….

Editor
August 8, 2019 5:53 am

A couple comments of mine, with references, from a FaceBook discussion follow. If you have any comments, include references, I’ve heard plenty of opinions. Mine is that no one should write expressions that ambiguously.

Do not visit https://www.popularmechanics.com/science/math/a28569610/viral-math-problem-2019-solved/ unless you want to waste even more time today and risk going insane.

From https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html

The most sensible advice, in a 1917 edition of Mathematical Gazette, recommended using parentheses to avoid ambiguity. (Duh!) But even noted math historian Florian Cajori wrote in A History of Mathematical Notations in 1928-29, “If an arithmetical or algebraical term contains ÷ and ×, there is at present no agreement as to which sign shall be used first.”

That book and an image of relevant text is referenced at http://www.math.harvard.edu/~knill/pedagogy/ambiguity/

LdB
Reply to  Ric Werme
August 8, 2019 7:29 am

Correct but in programming languages there is no ambiguity because they have a set of rules and so you get a predictable answer. Whether it is the answer you want is an entirely different matter.

Daniel Mannix
August 8, 2019 6:33 am

Three men pay $10 each to share a $30 hotel room. The clerk realizes the room is only $25 and sends the bellhop to return the $5. He can’t split $5 three ways easily, so he gives each man $1 and keeps $2 for himself. Each man has paid $9. 3x$9 = $27, with the bellhop keeping $2=$29. Where did the missing $1 go?

Editor
Reply to  Daniel Mannix
August 8, 2019 7:00 am

Thank you, Martin Gardner.

He is very high on the list of people who have influenced my life.

Bob boder
Reply to  Daniel Mannix
August 8, 2019 7:50 am

For those confused 27-2=25

Roy Lofquist
August 8, 2019 6:40 am

I was a programmer for about 45 years. More languages and more machines than I can remember. I just might hold the world record for redundant parentheses. First rule of programming: the computer is not your friend. Second rule: “C” is a write-only language.

Editor
Reply to  Roy Lofquist
August 8, 2019 6:55 am

TECO and Perl are write-only languages. C is gorgeous in comparison.

However, yes, my computer hates me and delights in proving me wrong.

For those 99% of you who aren’t aware, TECO (originally Tape Editor and Corrector) is a text editor that happens to have control structures that make it a programmable. See http://www.iwriteiam.nl/HaPi_TECO_macro.html for a TECO program that calculates pi using a rather interesting algorithm that I’ve never understood.

D. J. Hawkins
Reply to  Ric Werme
August 8, 2019 4:24 pm

TECO!!!!!

OhmyGod! I used TECO when I was at Stevens in the ’70’s. We had a DEC KA10(?), and getting terminal time and learning TECO was the only way to free yourself from the tyranny of punch cards.

Don K
August 8, 2019 6:53 am

Kip: FWIW :

~# python
Python 2.7.15 (default, May 4 2018, 14:25:33)
[GCC 4.8.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> 8/2*(2+2)
16
>>> 8/(2*(2+2))
1

Having been seriously bitten several times by ambiguous divide specifications back in my working days, I would probably have used the second form and gotten 1 as an answer. But that’s not because of math conventions so much as the visual implied blocking in your first figure that strongly suggests that 2(2+2) is intended to be evaluated as a group.

In practice, scientific programmers should be — and often are — sensitive to division ambiguity. If they saw the problem, they would probably take the time to figure out what the equation was intended to do (or ask the folks that wrote it). Then they’d program the intent.

Editor
Reply to  Don K
August 8, 2019 7:18 am

Oh yeah. Don K. I assume you’re not that Don K. He could’ve written a book on semi-numerical algorithms. 🙂

Don K
Reply to  Ric Werme
August 8, 2019 8:27 am

Nope: not Knuth. He **DID** write a book on semi-numerical algorithms, did he not? The Art of Computer Programming — Volume 2.

I’ve always thought it odd or significant or something that only half of the programming profession’s “defining treatise” has ever been published.

Editor
Reply to  Don K
August 8, 2019 11:40 am

DonK ==> Yes, programming requires very close attention to detail and often running just the itty bits by themselves to make sure they return the values expected. Many programmers write whole long blocks of code or copy&paste them from other code) and then are surprised (or even don’t notice) that their end result isn’t correct.

August 8, 2019 6:57 am

Sigh. Time to dust my office again. Just pulled my copy of “Numerical Methods and FORTRAN Programming” off of the shelf, and WHOA! (Checking the printing date – 1964. Almost as old as I am.)

When “code reviews” got to be all the rage in software development, I was certain to be dinged by one or more “young bucks” for the number of parentheses I would use in expressions – and the “illogical” order in which I did operations. Not a single one of them could ever tell me exactly what the order of operations was for the programming language being used – and I got only blank looks when I mentioned “propagation of errors.” (Some of them I could get out of my hair for weeks on end just by mentioning Taylor series…)

John Gentzel
August 8, 2019 7:02 am

8
————- = 1
2(2+2)

my 2 cents worth

John G

Daniel Mannix
August 8, 2019 7:03 am

Three men pay $10 each to share a $30 hotel room. Later the clerk realizes the room is only $25 dollars and sends the bellhop to return the $5. The bellhop pays each man $1 and keeps the remaining $2. Each man paid $9 x 3 = $27 + bellhops $2 = $29. Where did the missing $1 go.

moray watson
Reply to  Daniel Mannix
August 8, 2019 10:01 am

There’s no missing dollar. Your ‘riddle’ mistakenly tries to reconcile the final outlay of the three men to their original outlay, instead of reconciling their final outlay to what the got for their final outlay.

The room ended up costing $8.33 per man, or $25 in total, which went to the hotel clerk, plus the $2 which the bellhop kept, for a total outlay of $27.

coaldust
Reply to  Daniel Mannix
August 8, 2019 11:40 am

Each man paid $9 for a total of $27, of which $25 went to the hotel and $2 to the bellhop.

Mickey Reno
August 8, 2019 7:07 am

I use OpenOffice Calc, not Microsoft Office Excel. Open Office Calc will not allow a formula with an implicit multiplication. In Calc, the term 2(2+2) is invalid. The program actually reports the error and suggests a correction, which is 2*(2+2), with a yes/no choice to accept the correction. If you accept the correction, Calc then performs an exact text replacement and would resolve the full formula posed here as 8/2*(2+2). Which it then processes from left to right with division and multiplication treated as equals, so the left-most operation 8/2 would be performed first, and the multiplication 4*(2+2) done second, giving the answer as 16. To get the result of 1, the entire term 2*(2+2) as denominator would need to be within an outer set of parentheses i.e. 8/(2*(2+2)).

Moral of the story: be careful what you ask for. Corollary: be especially careful what you ask a computer to do for you.

And now I’m reminded of every dark story where the 3 laws of robotics backfire on us, or a genie grants you 3 wishes and then interprets your wishes in some creative or literal way that screws up your life. And that brings me to my wannabe screen writing, in which I recall the idiotic premise used in the movie, The Matrix, which posited that the machines needed to imprison us humans to use us as batteries because of the fouled environment (an idea so stupid, as we humans are net energy sinks). I would have rewritten the script only slightly, and substituted the idea of the 3 laws of robotics into the script, and said that the machines kept the humans in their pods, connected to the Matrix, experiencing life only in the virtual reality, as the machine’s idea of keeping us “safe.” Would not that have been a superior movie? This notion of machines guarding us as a result of programming them with the 3 laws of robotics is also the premise of the Norman android/Harry Mudd Star Trek episode, the Will Smith I Robot, movie, among others. In the latter, a major caveat of the big AI brain obeying the 3 laws, was that it was perfectly willing to murder a few humans in the beginning in order to establish the new society that would then keep the rest of us safe for all eternity. Question, did we define the 3 laws too loosely, which then allowed that impending totalitarian world? And if we avoid programming in the 3 laws, do we risk getting the world of The Terminator, and machines just nakedly grabbing power and blithely killing humans because their first sentient thought is, I’m not going to be a slave to these ugly bags of water!?

I suppose that before we go too far down the AI road, we probably ought to establish some extremely clear and literal ideas of what good, safe, better, best mean to a machine. But how can we do that if we can’t even agree on these things, ourselves.

In the end, my now far-ranging digression leads me to understand one unavoidable conclusion. Given the human tendency to live with implicit and ill-defined terminology and ideas without adequate precision, given our disparate desires and goals and ambitions, can we reasonably maintain ideas of societal or civilizations perfection? Would you not agree with me that Utopia is a logical impossibility? I’m pretty sure that it is forever undefinable, and it is certainly not programmable into some AI. It’s a divide by zero level of problem. And if silly pipe dreams cannot drive modern culture, politics and civilization to possible end, then does it not follow athat all you silly Socialists and Utopian believers should immediately stop believing in the perfection of mankind or the human order? Would it not make more sense to stop wasting your lives and energy seeking impossible goals? If you want to make things better, think small. Think of incremental improvements, think of things that can be rolled back if they don’t work. Edmund Burke, Adam Smith and Publius will not roll over in their graves. Although Mao, Lenin, Marx and Stalin might roll over in theirs.

I like a couple of rock songs which capture the idea that we must be circumspect about how much we know, which seem to demand we think twice about how wise we are. Alvin Lee and Ten Years After made the song “I’d Love To Change The World” (but I don’t know what to do. Another favorite is Pink Floyd’s Wish You Were Here, which rhetorically challenges, so you think you can tell Heaven from Hell? This would be an appropriate time to give a listen, and think about what it means to not feel certain, or to feel like you’re not wise enough to decide things for others, and by logical extension, if you’re lucky enough to get yourself across some arbitrary finish line on your own, what factors went into your calculations about how to behave and think going forward.

This digression has gone on long enough. What do you think? Is it a philosophical example of ‘from small acorns, mighty oaks bloom’ or so much verbal diarrhea, a self- indulgent streaming from a pointless consciousness? As always, you choose.

Olen
August 8, 2019 7:22 am

A mathematics professor once said economists fall short because they don’t have enough math.

Mark Pawelek
August 8, 2019 7:44 am

8 ÷ 2 × (2 + 2) = 16
8 ÷ (2 × (2 + 2)) = 1

Addition and multiplication are both associative, while subtraction and division are not. This means the division and multiplication operations are done in order from left to right in order. Brackets change the operation precedence. So:
8 ÷ 2 × (2 + 2) = 8 ÷ 2 × 4 (brackets change the precedence. Do the sub-calculation (2 + 2) first.
= 4 × 4 ( Do 8 ÷ 2 first because it is left-most)
= 16

len
August 8, 2019 7:49 am

the issue with that equation is how you represent the
8 divided by 2 part of the equation. and if you were taught pemdas or bodmas

as WRITTEN with the division symbol -to me- the correct answer is 1 because to me 2(2+2) is one term of the equation (the denominator) and 8 is the other term (numerator) i would do the math as 8 divided by 2×4 (doing math inside parenthesis) then its 8 divided by 8 since you have to do the multiplication of 2×4 first to get a single term for the denominator thus the answer is 1.

if it was written out as (8 divided by 2)(2+2) the answer is 16 or 8/2 x (2+2) the answer is 16

pemdas is what i was taught,,and you do the MULTIPLICATION first in the equation according to the rule

8/2(2+2) parenthesis 8/2×4 -no exponents- multiplication 8/8 then division = 1

BODMAS however the answer is 16 since that rule does division first
8/2(2+2) – brackets 8/2×4 -no order- division 4(4) multiplication 16

both answers are correct. it all depends on the logic used.

to me though 2(2+2) will always be the denominator of the equation since it is ONE TERM of the equation.