Exponents - Page 1
Forum section: electronics / beginners

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 01:00:25 am
content: What is the answer to this?-34

author: Nusa
author_rank: Super Contributor
timestamp: April 09, 2019, 01:15:27 am
content: Quote from: metrologist on April 09, 2019, 01:00:25 am-81

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 01:39:37 am
content: Well, the question was why isn't the negative considered in the calculation. It seemed obvious if one says y=3x-34, but not so much when you mouth minus three to the fourth. It sounds a lot like the square root of minus two. How would you mouth that properly? Minus two to the point five? But what if you wanted to actually say square root?

author: Nusa
author_rank: Super Contributor
timestamp: April 09, 2019, 01:51:48 am
content: It was considered in the WRITTEN calculation, using the traditional order of precedence, and you got the entire answer you asked for.Verbally, you need to make clear the order of operations in some manner.Minus three to the fourth vs The negative of three to the fourth.Square root of minus three vs negative square root of three.

author: Buriedcode
author_rank: Super Contributor
timestamp: April 09, 2019, 01:59:48 am
content: Consider x4. If x = -3 then the answer is 81. If the equation was -x4and x = -3 then it would be -(x4) or -1 * x4= -81. In that second instance because the exponent is even, the answer would be -81 for x = 3, or x= -3. Brackets are important and I do see them left out of equations fairly often.

author: MyEEVBlogAccount
author_rank: Contributor
timestamp: April 09, 2019, 02:04:20 am
content: It is because operators have a property called "precedence." Precedence, sometimes called "binding strength" or "binding level," determines the order that the operations are done. In mathematics, the exponentiation operation is done before any addition (and, by extension, subtraction) operations are done. Now, negation is actually considered to be subtracting the number from zero. So, -3**4 is actually (0 - (3**4)) when you put in the parentheses sets to disambiguate.Now, why the operators are evaluated in that order is a more complicated, due the need to understand their iterative nature, and need to understand identity elements and inversion elements.

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 02:14:52 am
content: Yes, thanks all. I see no reasonable solution to my problem.

author: Nerull
author_rank: Frequent Contributor
timestamp: April 09, 2019, 02:27:49 am
content: The reasonable solution is to pay attention to order of operations and use parenthesis where needed. I'm not really sure what about that is too difficult.

author: MyEEVBlogAccount
author_rank: Contributor
timestamp: April 09, 2019, 02:29:24 am
content: I think I read past your real question my first time reading. I would say something like "what is the negation of three to the power of four" and "what is the negation of the square root of three," respectively. Although, I did have a professor in graduate school who insisted you included the zero and parentheses and say something like "what is zero minus the quantity of three to the power of four." Ether way, saying "negation" makes it more clear what you are doing and sounds more like -(3**4) than using the word "minus." It does to me anyway. Perhaps the compromise of "what is the negation of the quantity of 3**4," is the right way to go on ambiguity.

author: Brumby
author_rank: Unknown
timestamp: April 09, 2019, 02:37:31 am
content: Quote from: Nerull on April 09, 2019, 02:27:49 amIndeed. The rules have been set out for quite some time now. There is NO ambiguity in what was written.If there IS an issue with the expression, then that lies with the person who prepared it. THAT is, actually, a much more important step than resolving it. If it is not written correctly, then you will not - andcannot- get a correct answer.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: April 09, 2019, 02:49:43 am
content: Quote from: metrologist on April 09, 2019, 02:14:52 amNusa gave a good answer. The problem is that language is less precise than written mathematics. If you can't write it down you have to get verbose to get the same level of precision.Another way to get the verbal precision -Spoken RPN. 4, Enter, 3, Enter, X^Y, CHS. Again verbose, but that is the price you pay. Writing it down solves the other problem. The listener often cannot keep track of the verbage required for precision.

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 09, 2019, 02:56:47 am
content: If a chicken and a half lays an egg and a half in a day and a half, how long does it take for a chicken to lay two eggs?

author: 0culus
author_rank: Super Contributor
timestamp: April 09, 2019, 02:57:21 am
content: Quote from: metrologist on April 09, 2019, 01:39:37 amThink of it like this: $$0-3^4 = 0-81 = -81$$There's no square root of -1 involved.(yes you can in fact embed LaTeX in the forum!)

author: tggzzz
author_rank: Super Contributor
timestamp: April 09, 2019, 07:48:35 am
content: Quote from: Buriedcode on April 09, 2019, 01:59:48 amThere were no brackets, so using the normal laws of arithmetic the answer is unambiguously -81.Isn't BEDMAS taught any more? (Brackets, exponents, division, multiplication, addition, subtraction).Of course if non-normal laws are being used, the answer can be anything you want; see APL for some interesting examples

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2019, 08:41:50 am
content: Quote from: metrologist on April 09, 2019, 02:14:52 amPerhaps you meant this:(-3)4= 81Note the brackets!I've also seen using superscript for the minus, but don't know whether it's correct or not.-34= 81Everyone who's posted above is right: -34= -81

author: soldar
author_rank: Super Contributor
timestamp: April 09, 2019, 08:48:35 am
content: Quote from: metrologist on April 09, 2019, 02:14:52 amWhat's your problem?

author: tggzzz
author_rank: Super Contributor
timestamp: April 09, 2019, 09:13:12 am
content: Quote from: Zero999 on April 09, 2019, 08:41:50 amIt isn't correct for normal arithmetic/maths.In APL "high minus" is normal notation for a negative number (i.e. part of the number itself), with minus being reserved for the subtraction operation. I've heard "high minus 3" pronounced "neg 3".https://en.wikipedia.org/wiki/APL_syntax_and_symbols

author: Datman
author_rank: Regular Contributor
timestamp: April 09, 2019, 09:45:31 am
content: If you write -3x, it should be negative independently on x. The sign can not depend on x even or odd!

author: taydin
author_rank: Frequent Contributor
timestamp: April 09, 2019, 10:04:31 am
content: Quote from: Wimberleytech on April 09, 2019, 02:56:47 amInfinity ... Chicken in our world aren't linearly scalable, so if you cut off 1/3 of the "one and a half chicken", you'll get a dead chicken

author: soldar
author_rank: Super Contributor
timestamp: April 09, 2019, 10:50:28 am
content: Quote from: taydin on April 09, 2019, 10:04:31 amChickens don't lay eggs. Hens lay eggs. Chickens lay drumsticks.Half a chicken lays dead. In a supermarket. For $5.25 a pound.

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 09, 2019, 11:26:08 am
content: QuoteWe use the mnemonic: Please Excuse My Dear Aunt Sally

author: ebastler
author_rank: Super Contributor
timestamp: April 09, 2019, 11:44:12 am
content: Quote from: metrologist on April 09, 2019, 02:14:52 amIt is really simple. Due to the operator priorities which are agreed upon in mathematical notation, -34= -(34) = -81.If you were thinking of (-3)4, then that's what you have to write, including the parentheses. And that would evaluate as (-3)4= 81.

author: Brumby
author_rank: Unknown
timestamp: April 09, 2019, 02:38:48 pm
content: Quote from: ebastler on April 09, 2019, 11:44:12 amThis is exactly my point here:Quote from: Brumby on April 09, 2019, 02:37:31 am

author: Andrew Morton
author_rank: Newbie
timestamp: April 09, 2019, 02:55:47 pm
content: The - is part of the number, not an operator, so it's the same as -3 * -3 * -3 * -3.

author: ebastler
author_rank: Super Contributor
timestamp: April 09, 2019, 03:02:13 pm
content: Quote from: Andrew Morton on April 09, 2019, 02:55:47 pmWow - it's brave to claim that, after about ten people have stated the opposite.And I'm afraid it is wrong:https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign

author: RandallMcRee
author_rank: Frequent Contributor
timestamp: April 09, 2019, 03:08:31 pm
content: Quote from: ebastler on April 09, 2019, 03:02:13 pmYeah:https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/artnege.htm

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 09, 2019, 03:13:29 pm
content: Quote from: Andrew Morton on April 09, 2019, 02:55:47 pmNo!

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 03:13:54 pm
content: Quote from: soldar on April 09, 2019, 08:48:35 amMy applied calculus exam had 10 parts to solve: a bowling ball is dropped onto a table at t0. Show the derivations of the equations to, and calculate a number of things, such as the speed of ball at impact and time; the position, velocity, and acceleration of point (x,y) on the table at time tn. You are given such things as the modulus of expansion of the table (legs considered infinitely rigid), its thickness, density, and all the other things I've forgotten that you'd need to actually solve the problem. I got all 10 parts correct and aced the course. I ranked the top fifth in my graduating class, and have both physics and applied engineering degrees.I was trying to apply context of primary school introduction to exponents. The only question I had was the one I could not answer. I looked at it, tried to apply context, and arrived at the wrong answer.I'm sure the image below will illustrate another failure of applied context.

author: tggzzz
author_rank: Super Contributor
timestamp: April 09, 2019, 03:25:25 pm
content: Quote from: metrologist on April 09, 2019, 03:13:54 pmOooh, tasty.That ranks alongside 1+2*3=9.RPN rulesz

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 09, 2019, 03:34:05 pm
content: Quote from: tggzzz on April 09, 2019, 03:25:25 pmDitto re RPNExcel is wrong. However, MS does tell you what rules they are following as shown in the attached from MS.

author: ebastler
author_rank: Super Contributor
timestamp: April 09, 2019, 03:34:52 pm
content: Quote from: metrologist on April 09, 2019, 03:13:54 pmAt the danger of repeating myself:https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_signQuote

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 09, 2019, 03:44:43 pm
content: http://mathforum.org/library/drmath/view/69058.html

author: RandallMcRee
author_rank: Frequent Contributor
timestamp: April 09, 2019, 03:58:20 pm
content: Quote from: metrologist on April 09, 2019, 03:13:54 pmAre you trolling? I ask because you put in a lot of stuff about your past performance but left out the most important piece of information that would allow someone to help you! I.e. What exactly are you confused about??My guess is that you were never taught properly about operator precedence. It creates ambiguity in expressions like -3^4.If you are actually still confused try to explain (in words).

author: newbrain
author_rank: Super Contributor
timestamp: April 09, 2019, 04:18:05 pm
content: Quote from: tggzzz on April 09, 2019, 07:48:35 amAPL, my first love...though sadly mostly forgotten.Its rules areis astonishingly easy: right to left evaluation of expression, and that's it.Even the tirade on WP about long right and short left function context seems a bit of mental wankery: it is simply the application of the same rule.

author: soldar
author_rank: Super Contributor
timestamp: April 09, 2019, 04:37:19 pm
content: Quote from: metrologist on April 09, 2019, 01:00:25 amOK, with the additional information you have provided the answer is most definitely "it depends".Theorder of operationsis a matter of convention and, as such, there is no universal correct answer.Unless otherwise stated the most common convention is what Wikipedia says and has been said here.Then Excel states and abides by the exception:QuoteIt is not "wrong". It is just another convention. If you do not specify people will assume the most widespread convention is in use. If you ask "what is the correct result in Excel?" that is a different question with a different answer.Note that it is easy to avoid any ambiguity by just using parentheses.This is like asking if people should drive on the right hand side of the road. The answer is yes because people are assuming you are in a country where that is the convention but if you further clarify you are talking of England then the answer changes.So,Quote from: metrologist on April 09, 2019, 01:00:25 amMy answer is "where?".

author: Nusa
author_rank: Super Contributor
timestamp: April 09, 2019, 05:21:22 pm
content: Quote from: tggzzz on April 09, 2019, 03:25:25 pmAnd that's exactly the answer you would have gotten in the original spreadsheet, VisiCalc! The original designers, in hindsight, admit that ignoring precedence was a poor choice on their part.I don't know how Microsoft got their rules for Excel, but they're stuck with them now. Documenting them is safer than changing them and breaking umpteen existing spreadsheets.So the problem with the OP's original question is that he presented it without the relevant context.

author: soldar
author_rank: Super Contributor
timestamp: April 09, 2019, 06:05:51 pm
content: Context is everything.OTOH, I use Excel quite a bit and have never really been aware of this "problem". I don't know if I have unconsciously worked around it or just been lucky or what. Or maybe I have been getting wrong results and never became aware of their wrongness.

author: rstofer
author_rank: Super Contributor
timestamp: April 09, 2019, 06:23:48 pm
content: This has been linked a couple of times above:https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_signThere is no universal agreement on the precedence of the unary minus. In some languages it might mean (-3)4in others it might mean -(34)And that's why we have parentheses.

author: MyEEVBlogAccount
author_rank: Contributor
timestamp: April 09, 2019, 07:04:38 pm
content: This question and circumstance seems awfully close to being anhttps://en.wikipedia.org/wiki/XY_problem. It seemed as though the question was asked within the standard mathematical domain, but in actually had to do how different systems may not work the same. For the Excel formula language, they probably chose higher strength for negation because that is what most people without their mathematician hat on would probably think should happen.Now, because of my academic background, I tend to write math problems that are complicated or are beyond the DMAS operations inhttps://en.wikipedia.org/wiki/Well-formed_formulaformat without implied multiplication. No ambiguity in reading, transcribing, or in reading off to another person.

author: Nusa
author_rank: Super Contributor
timestamp: April 09, 2019, 07:11:29 pm
content: There's no universal agreement on anything, because you can always find one person who will disagree with everything.In the context of written math, the agebra meaning is about as close to internationally universal as one can get in this day and age. The verbal languages the reader speaks is largely irrelevant to this understanding, other than some tolerable differences in notation.In the context of computer applications, it's less universal, obviously, but trends toward the algebraic meaning unless otherwise identified.In the context of spoken languages, confusion reins for anyone but expert speakers of formula without written props. Math precedence isn't even on the minds of most people when language is created or evolved.

author: rstofer
author_rank: Super Contributor
timestamp: April 09, 2019, 08:15:08 pm
content: MATLAB:>> -3^4ans = -81wxMaxima(%i1) -3^4(%o1) -81GNU FortranProgram Exponentsprint *, -3**4end program Exponents-81Symbolab.com-3^4=-81Of the math tools I am currently using, exponentiation has a higher precedence than the unary minus. This is what I expected. But it's nice to be certain!

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 08:42:32 pm
content: Quote from: ebastler on April 09, 2019, 03:34:52 pmIn the time it took me to make my post, and test Excel to see what it would do (because I have been merely aware of Excel's order of operations for many years, and had to see rather than recall it), you made your post above. I saw the red warning banner. I see it a lot, but am getting too lazy to go back and see what someone has posted. Usually it would not affect my post, so I would still post the same. In this case, I would have edited my post to acknowledge the redundancy I created, but is leaving myself open for you more enjoyable? I can't always be perfect.This time, I see the red banner as I'm posting. I want to finish this post anyway, because I have another one open to add below. I probably will not have time to address those posts I've missed, sorry in advance...Quote from: RandallMcRee on April 09, 2019, 03:58:20 pmI am not at all confused and not trolling. I wasn't confused last night when I started this topic. I was more frustrated that I got the wrong answer, as I should have known. I really do not recall how my first exposure to exponents was presented in school. I provided an example that makes it obvious in my follow-up post, and one that I'm sure is not ambiguous in an algebraic expression.Anyway, I was confident that I'd learn more than I ever knew about operators by posting here, and I was curious how wrong I really was. I mean, if I walked up to an average engineer and just asked them what is minus two squared, or even wrote it down, how many would get it wrong too? I was never a practicing physicist or engineer. My life took a turn in another direction.

author: rstofer
author_rank: Super Contributor
timestamp: April 09, 2019, 09:11:19 pm
content: Quote from: metrologist on April 09, 2019, 08:42:32 pmYou would probably get more wrong answers than you expect. It's not that engineers don't know operator precedence, it just doesn't come up a lot unless you do some kind of math that involves precedence. I'm sure if they sat down and thought for a few seconds, they would get the right answer but it would probably involve some conscious thinking, not just a quickie answer. They would have to mentally run through the rules.I can tell you for a fact, at first glance, I'm not sure what answer I got. Sure, I know how it should work but I still have to stop and think. I don't rely on operator precedence, I use parentheses.

author: metrologist
author_rank: Super Contributor
timestamp: April 09, 2019, 11:53:46 pm
content: Operator precedence was the only thought on my mind. I even thought of this expression in parenthetical terms. I knew the point of the question, but did not arrive. That irritates me.There is an adage,use it or lose it, andyou are your own worst enemy.I had to look these things up and now see terms like ngram (or is that n-gram?) that I do not recall. And what is an obelus, or what we know as a division symbol?In some ways I feel a victim of thetrain me stupidsystem that is designed to achieve a certain objective, and in other ways I feel there are people who areborn to be...I do really appreciate everyone's posts here. Thank you.

author: soldar
author_rank: Super Contributor
timestamp: April 10, 2019, 06:12:32 am
content: Excel gives different results for -3^4 (81) and for 0-3^4 (-81) which I find very strange. I don't know how they came up with that but I find it to be confusing and a bad idea.

author: magic
author_rank: Super Contributor
timestamp: April 10, 2019, 06:19:22 am
content: Well, having studied computer science at a somewhat maths-heavy uni I can say with certainty:No one would ever read -3⁴ as (-3)⁴, it's definitely -(3⁴).I can understand why a naively written parser could misinterpret -3^4.Ergo, bigfor Microsoft.OK, somebody just asked how they come up with it. Simple: their software just doesn't realize that - without anything on the left is still subtraction, albeit from implied zero. So it ignores it and treats it as part of the number. Then it sees ^ and calculates the exponent.

author: soldar
author_rank: Super Contributor
timestamp: April 10, 2019, 07:31:21 am
content: I started using Excel when it was still called Multiplan. I bet few people remember that name or that spreadsheet. It used the row-column notation R4C5 for absolute address and R[-2]C[-1] for relative addressing which I still use in Excel because, thankfully, you can choose that.In these decades of using Multiplan and Excel I never noticed this quirk which they should have corrected from the beginning. As has been said, changing it now might create a compatibility problem with older sheets.In the early 1980s, before using Multiplan, I was using another spreadsheet, Dynacalc, on a UNIX-like operating system called OS9, on a Dragon (Tandy) computer. It is just amazing what they could do with such limited hardware.

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 10, 2019, 12:35:35 pm
content: QuoteSon of a gun! You are correct. I just tested that expression in Visicalc...who knew?? I guess you did.

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 10, 2019, 02:52:57 pm
content: Further example:Code:echo ' 3 ^ 4 ' | bcecho ' - 3 ^ 4 ' | bcecho ' - - 3 ^ 4 ' | bcalloutput81, because the negation operator-has higher precedence in bc than the exponentiation operator^.That is, the above expressions are equivalent toCode:echo ' 3 ^ 4 ' | bcecho ' (-3)^4 ' | bcecho ' (-(-3))^4 ' | bcSimilarly for Bash,bash -c 'echo $[-3**4]',bash -c 'echo $[--3**4]', andbash -c 'echo $[---3**4]'all output81. (The same withbash -c 'echo $(( -3**4 ))'and so on, for the same reason.)This is explained in their documentation by stating that the negation operator-has higher precedence than the exponentiation operator (^in bc,**in Bash), which has higher precedence than subtraction (-).However, Python, Perl, and Ruby all parse/associate the expressions correctly:Code:python -c 'print(-3**4)'perl -E 'say -3**4'ruby -e 'puts -3**4'all output-81.Their documentation, fortunately, clearly says that exponentiation**has higher precedence than negation-. (Note, however, that they do have slightly different operator precedences from each other, so expressions in one are not necessarily parsed the exact same way in the other. Trap for young players!)In general, because many programmers aren'tthatgood at math and changing the precedence/associativity rules when your users have gotten used to them would be downright evil, one must assume that software environments do not always parse or compute expressions correctly. However, they can almost always be forced to Do The Right Thing, by using parentheses.(It would be better if there was a separate operators for negation and subtraction instead. I wouldn't mind a superscript minus,-, myself. It would completely remove the ambiquity. Similarly for exclusive-or/exponentiation (^). I blame ASCII for not having suitable glyphs to port to thePortable Character Set.In all the above environments and languages, adding parentheses will fix the issue:-(3**4)or-(3^4)(depending on what is used to signify exponentiation) will yield the expected answer,-81.TL;DR: Consider it a human interface problem in various applications and programming languages. Always use parentheses to avoid mistakes.

author: ebastler
author_rank: Super Contributor
timestamp: April 10, 2019, 03:15:25 pm
content: Quote from: Nominal Animal on April 10, 2019, 02:52:57 pmYou have a point there, but nevertheless it's pretty disappointing. By the same token, you could argue that one should expect some spelling errors in programming languages' keywords -- programmers aren'tthatgood at spelling, and cannot break backwards compatibility once a language has been rolled out. But I have yet to see a language with a "prnit" or "inputt" command.

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 10, 2019, 04:14:30 pm
content: Quote from: ebastler on April 10, 2019, 03:15:25 pmWouldcolorvs.coloursuffice?Kidding aside, typos are different from spelling errors, and spelling errors are in fact quite common in various APIs. Typos are usually caught by other developers (or the developers themselves after a while), but spelling errors do creep in; mostly in library interfaces, since the core languages tend to get reviewed by people who can actually spell before they become too widespread to fix. The first example that comes to mind that I've seen in a library isparallellinstead ofparallel.A real example of a syntax mistake isprintin Python 2. Although it is a function, it did not require parentheses around its argument. This was corrected in Python 3. (A counterexample isreturn, which is a statement and not a function, and therefore does not need parentheses around the argument(s).)That might look like pedantic picking, but the difference does matter at the implementation level a lot in Python. In C, it is actually very important: for example,sizeof(i++)does not increment the value of variablei, becausesizeofis an operator that evaluates to the size of its argument without evaluating the argument for side effects (like increments, decrements, or memory accesses). This, and similar issues with optional macros (assert()et cetera), often surprise new programmers, and cause hard to debug problems.(They are not hard to debug because they're difficult to see, quite the contrary; they are hard to debug because the programmer's intent is not written anywhere, so to see that the intent and the implementation do not match, one has to divine the original programmer's intent. That divination part is the hard part.)So yeah, you do need to expect some errors/oddities in programming language syntaxes, and library interfaces.

author: magic
author_rank: Super Contributor
timestamp: April 10, 2019, 05:18:40 pm
content: Well, we have HTTP Referer field. Not sure if it originally was a typo or a deliberate attempt at shaving one byte from each request

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 10, 2019, 11:20:54 pm
content: I'd say "referer" was a spelling mistake. (Consider e.g. referee. I'd say it is an easy mistake, something I could make myself.)As an example of the stranger choices devs have made, is the legendary Boolean implementation with tristate values:True,False, andFILE_NOT_FOUND.

author: Wimberleytech
author_rank: Super Contributor
timestamp: April 10, 2019, 11:55:55 pm
content: QuoteYou are soooo old! Oh dang!

author: Brumby
author_rank: Unknown
timestamp: April 11, 2019, 12:59:18 am
content: Here is the core of the problem!:Quote from: Nominal Animal on April 10, 2019, 02:52:57 pmThese are two different operations that give the same result in many situations - but even so, I still stand by my earlier statement:Quote from: Brumby on April 09, 2019, 02:37:31 amMathematical expressions are usually a representation of some part of the universe in which we live. As such, there will be only one correct way to write them (commutative laws aside) - so if there is any chance of ambiguity, the simple answer is to use parentheses.If the person writing the expression does not do this, then they will be reliant on the expression being evaluated according to the rules they observed when drafting it. As we have seen, this has risks - and mathematical expressions are a class of study where this sort of risk has no place.

author: rstofer
author_rank: Super Contributor
timestamp: April 11, 2019, 01:51:22 am
content: Quote from: ebastler on April 10, 2019, 03:15:25 pmThere was a FORTRAN compiler, way back when, that would accept DAMNITALL for the DIMENSION keyword. 9 characters and the D & M matched. It may have been the IBM 1130, I don't recall. Nor did I ever try to disprove it. I had enough problems doing my own keypunch.I just wanted the compiler to fix my missing parentheses at the end of FORMAT statements.

author: Rick Law
author_rank: Super Contributor
timestamp: April 11, 2019, 02:17:30 am
content: Quote from: ebastler on April 10, 2019, 03:15:25 pmre: "In general, because many programmers aren'tthatgood at math..."What is ironic is that in the early days of computer science, many universities didn't yet have CS as a major and they rolled it into the math department. So most programmers back then had math degree instead of CS degree.Purdue Univ was the first in the USA to offer CS degree in 1962. So you can bet in the 1960's, 90% of the programmers are "math" majors.Herman Cain, a computer guy (pizza company CEO, one time presidential candidate, currently being nominated for the Federal Reserve) spoke of his PhD in "math" that he is a "mathematician" only because the U he attended didn't have CS yet.This gives interesting meaning to the title BS in Math.

author: 0culus
author_rank: Super Contributor
timestamp: April 11, 2019, 03:27:22 am
content: Bullshit, More Shit, and Shit Piled Higher and Deeper!

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 11, 2019, 10:50:36 am
content: Quote from: Brumby on April 09, 2019, 02:37:31 amWith programming languages, libraries, applications and environments, the problem is that the rules areimplemented, not juststated. This means that when you input an expression, the environment may not parse it according to the stated or assumed rules. My point is that because their implementors are human, the possibility of such errors always exists.The simple solution, which we seem to agree on, is to use parentheses to ensure an unambiguous parsing and evaluation of the expression.And, one could add, to verify the correctness of the environment via known expressions:1+2×3and so on.To rephrase: while the mathematical identities and formulae are exact and unambiguous, we humans can express them in different ways. We have different notations and so on. Essentially, when a human writes a mathematical expression, the thing it describes is exact, but the expression uses formatting rules set by us fallible humans. The problem is not with the underlying math or its exactness, it is only that those formatting rules do vary.Quote from: Rick Law on April 11, 2019, 02:17:30 amHow many of the mathematicians you know can state the order of precedence of the basic arithmetic operators offhand? Among those I know, not many; most would struggle a lot. Or laugh, then Google it.Quote from: 0culus on April 11, 2019, 03:27:22 amMaybe lay off the drugs for a while, eh?

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 12:16:18 pm
content: Quote from: Nominal Animal on April 11, 2019, 10:50:36 amAll of them, full stop.The point is that there has to be some commonly understood and shared meaning, otherwise communication cannot happen. If a person chooses new meanings that are different to the standard meanings, then it is up to that person to state what they mean.If they don't do that then there's nothing to prevent "I'm going to get a cup of coffee" meaning "You're going to drive the car"Hence, in the original question, it is reasonable to ask where the parentheses are, and reasonable to answer "no parentheses, normal laws of arithmetic", or "no parentheses, in Excel spreadsheets". It is to be deprecated that the answers are different.

author: ebastler
author_rank: Super Contributor
timestamp: April 11, 2019, 12:21:15 pm
content: Quote from: tggzzz on April 11, 2019, 12:16:18 pmBut "I'm going to have a few beers now"doesindeed mean "You're going to drive the car"

author: Buriedcode
author_rank: Super Contributor
timestamp: April 11, 2019, 01:52:11 pm
content: I'm still unsure why this thread has so many replies (I'm aware I'm adding to this!). Precedence is indeed important and despite what nominal animal suggested, I'm pretty sure almost all "mathematicians" could state the order, perhaps with the acronyms BODMAS or PEDMAS. Especially as it is so fundamental to even basic algebra.Whilst the average Joe who was taught this in basic mathematics has probably forgotten because most simply do not need to use this, I am willing to bet Engineers will be more likely to know this.If the OP struggles with where to use parenthesis (I'm not suggesting he does, I don't know) then playing around with Excel can be handy, as that is quite strict in its use of them. Even when they are correctly closed moving them about will give different answers, and breaking up an equation - so you can see the output of each part in its own cell - is a good way of seeing whats happening. Algebra is just one of those things that tends to "click", and once basic rules are known/realized, can be a powerful tool.

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 11, 2019, 02:09:23 pm
content: Quote from: tggzzz on April 11, 2019, 12:16:18 pmNo, I mean that us "users" must verify we agree what the rules/meanings/precedences are, and not just assume they are some standard ones, because they do vary.Just because thePEMDASinfix notation is the only one you have been taught, does not mean it is the only one used. It is the only one you've ever used, perhaps... but the rest of us have used RPN and others, especially when using practical tools to solve practical problems. (Conversion between infix and postfix notation, using theshunting yard algoritm, is a very common exercise in computer science.)For example, if you show$$ y = c_i x^i $$to a mathematician, they probably think it is an odd way to specify a monomial whose degree depends on some constant named \$ i \$; but physicists know this is just shorthand,Einstein notation(as having the constant factor name depend on the degree of the monomial makes no sense!), equivalent to$$ y = \sum_i c_i x^i $$In quantum mechanics you have Dirac orbra-ket notation, \$ \left\lt\varphi\right\rvert \$ and \$ \left\lvert\theta\right\gt \$, that follow the rules of linear algebra, and actually represent matrices; but because of their properties, they are rarely if ever expanded to their actual matrix representations. For example, the superposition of wave functions \$\varphi\$ and \$\theta\$ is \$ \left\lt\varphi\right\rvert\left.\theta\right\gt = \int \left\lt\varphi\right\rvert\left. x \right\gt \left\lt x \right \rvert \left . \theta \right \gt dx = \int \overline{\varphi(x)} \theta(x) dx\$, where \$ \overline{\varphi(x)} \$ is the complex conjugate of the wave function \$\varphi(x)\$, \$\left\lvert \varphi \right\gt\$ is the state (column) vector for the wave function \$\varphi\$, and \$\left\lt \theta \right\rvert\$ is the Hermitian conjugate of the state vector for the wave function \$\theta\$.Here, you don't just need to know the notation, you need to know the domain-specific rules that apply to this notation, to save yourself a fuckton of extra work.(Stuff like Gaussian error functions, elliptic integrals, and so on, being already implemented in many programming languages and math libraries is what typical programmers might not know, and instead open-code inferior/approximate versions of. And that some languages/applications use a different order of arithmetic and unary/binary/boolean operators than you might expect.)Notation rules are not universal, they do vary. The more complex the application domain is, the more likely it is they use their own notation and rules to simplify it.Quote from: tggzzz on April 11, 2019, 12:16:18 pmFully agreed; and the core of what I am trying to say too.

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 02:20:59 pm
content: Quote from: Buriedcode on April 11, 2019, 01:52:11 pmEngineers ought to. I wouldn't bet on UK primary school teachers knowing thoughQuoteIt may be strict, but it is wrong (except within its own self-contained world). Shades of "Through the Looking Glass":Quote

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 02:28:58 pm
content: Quote from: Nominal Animal on April 11, 2019, 02:09:23 pmSee the "Through the Looking Glass" quote in my previous message.QuoteAh, but which is it more likely that people should know:something that has been invariant for hundreds of years across all civilisations, and they were taught in schoolone specific computer program created a few decades ago, that was then copied by other programsThe latter makes me wince, and I think it is unreasonable.

author: ebastler
author_rank: Super Contributor
timestamp: April 11, 2019, 02:57:58 pm
content: Quote from: Buriedcode on April 11, 2019, 01:52:11 pmYou are nicely illustrating why there are so many replies here. Besides people being chatty (myself included), some posters don't read the previous posts carefully and then make comments which add to the confusion.Excel was one of the very few examples highlighted in this thread which got operator precedencewrong, compared to mathematical convention. So playing around with Excel isnotthe recommended way to learn about mathematical notation conventions.

author: Buriedcode
author_rank: Super Contributor
timestamp: April 11, 2019, 02:59:11 pm
content: Quote from: tggzzz on April 11, 2019, 02:20:59 pmWhy would they need to know? Whilst I vaguely remember learning some algebra in primary school, I'm not sure it was required. Why pick on primary school teachers? They have an ever growing work load and constant changes to curriculum from a government who wants "all UK children to be above average"(Direct quote from Michael Gove there).I have noticed a lot of threads that deal with education or the basics of engineering/mathematics have this air of "in my day things were better" from the older generation. Of course people are going to think that, because otherwise it implies that their education - and by extension, themselves - is/was substandard or outdated. It doesn't mean that we are in fact "going backwards", it just appears that way as we get older, because of inevitable changes to education.Quote from: tggzzz on April 11, 2019, 02:20:59 pmAs for Excel being wrong, I guess this is what the bulk of the replies are about. What one considers to be right. According to my Excel, -3^4 = 81. Which I believe to be correct. And -(3^4) = -81. Also correct. So I'm not sure what your point is?

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 03:04:13 pm
content: Quote from: Buriedcode on April 11, 2019, 02:59:11 pmUsing similar reasoning, I consider 6*9=42 to be correct, because itiscorrect.But that's not very helpful, and could be considered peverse.

author: ebastler
author_rank: Super Contributor
timestamp: April 11, 2019, 03:05:45 pm
content: Quote from: Buriedcode on April 11, 2019, 02:59:11 pmGrmpf. Justreadthe posts above.Or read this, quoted a couple of times in this thread:https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_signExcel is one of the few programs which implements unary minus the wrong way, i.e. different from mathematical notation. The correct math is -34= - (34) = -81.

author: Buriedcode
author_rank: Super Contributor
timestamp: April 11, 2019, 03:08:41 pm
content: Quote from: ebastler on April 11, 2019, 02:57:58 pmOk, I think I see your point. The idea that the sign is in fact a multiplication by -1, so -34should be -1*34, and because of precedence, the exponent should be calculated before multiplication, giving -1*81 = -81? If we add parentheses around that assumption: (-1 * 3)4then the answer is of course 81 - parentheses first, then exponent.I still maintain that without parentheses, there is ambiguity. So the OP's original question has the answer: it depends. As for excel being "wrong", anyone who doesn't use parentheses correctly is relying on whatever rules their software uses which as can be seen from this thread, varies. As to which software is "right", again this depends on what rules it uses, and will just go around in circles of people saying "but but but its wrong!".The take home message is - correct/strict use of parentheses isn't optional. Complaining that software doesn't do things how you expect when you don't use them isn't the fault of the software, it is the fault of the user.

author: ebastler
author_rank: Super Contributor
timestamp: April 11, 2019, 03:23:14 pm
content: Quote from: Buriedcode on April 11, 2019, 03:08:41 pmSorry, that's still a distorted view in my opinion.Mathematical notation came first, with a headstart of probably a couple hundred years over Excel. Then Excel came along, which clearly plays in the field of mathematics. (At least they did choose to use the conventional numerals...) And they "chose" to implement unary minus with adifferentprecedence, out of ignorance. How is that not "wrong"?As a result, we are now forced to useredundantparantheses to work around the Excel-induced errors and confusion. Not "correct" or "strict" parentheses, mind you.

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 03:23:58 pm
content: Quote from: Buriedcode on April 11, 2019, 03:08:41 pmDo youseriouslybelieve that software is a definition ofanything?Unless you are inconsistent, you have to agree that this isn't unreasonable:7 - 7 = 0and7 - 7 - 7 = 7and7 - 7 - 7 - 7 = 0and7 - 7 - 7 - 7 - 7 = 7since that's what happens in one computer language.

author: Nominal Animal
author_rank: Super Contributor
timestamp: April 11, 2019, 03:26:24 pm
content: Quote from: tggzzz on April 11, 2019, 02:28:58 pmNo such "invariant for hundreds of years across all civilisations" math notation exist. Whoever told you that, lied. See any history of mathematics book.

author: magic
author_rank: Super Contributor
timestamp: April 11, 2019, 03:42:58 pm
content: Quote from: Buriedcode on April 11, 2019, 02:59:11 pmI have noticed a lot of people trying to explain away simple and widely acknowledged facts by insinuating that they exist only in imaginations of fragile egos.I have heard old date university teachers talking about the first year students coming in "these days". I have seen highschool textbooks from 20 years prior and compared them to mine. I know what to think without any of your whataboutism, thank you very much. Don't even want to go on a rant about your assumption that "not better" somehow implies "worse or outdated". Particularly in maths and science.I have also heard similar complaints from various Westerners so it's not just my country. Maybe yours is different, but frankly, there are obvious mechanisms driving education downwards and they are ubiquitous in all of the first world, so I doubt it. Namely: more (read: dumber) people are pushed into education for longer years so standards must be adjusted accordingly, every ten years somebody invents a new and better way of teaching the same stuff, everything is being bureaucratized to the point where teachers have to teach themselves to follow the latest rules rather than teach their students, education is mostly/largely public and underfunded (is it Finland that's an exception? how many such countries?) and so on.

author: rstofer
author_rank: Super Contributor
timestamp: April 11, 2019, 03:49:56 pm
content: Quote from: tggzzz on April 11, 2019, 03:23:58 pmWe had APL on the IBM 1130 back in '70 but I never got around to playing with it. I didn't realize it evaluated from right to left.Interesting!

author: metrologist
author_rank: Super Contributor
timestamp: April 11, 2019, 04:05:11 pm
content: Quote from: Buriedcode on April 11, 2019, 02:59:11 pmThe particular school and several others around here run K through 8, and I consider them primary; although, I believe the classic definition of primary education is k through 5. I would expect primary mathematics program teachers to have earned certain credentials to be in that position, which would certainly exceed the educational requirements of the level they are instructing.The 6th grade class here appears to be in chapter 11 or 12, and should finish the program by mid June I believe. This is not the actual program but the topics are the same:http://mathonweb.com/help_ebook/index.htmI did provide some context and description of the specific issue I had.

author: rstofer
author_rank: Super Contributor
timestamp: April 11, 2019, 04:06:28 pm
content: Quote from: magic on April 11, 2019, 03:42:58 pmThings were NOT better. My grandson and I were working through one of his physics problems the other night and it involved a rather ugly polynomial. We took one look and decided to just set it up in MATLAB. Turns out one of his other classes is MATLAB - a forward thinking university that requires a MATLAB course. We kind of laughed when he asked how I would have solved it back in the early '70s. I moved my hands around in a familiar 'slide rule' fashion and mimicked writing intermediate results.I could imagine being able to learn the various material with much more depth and understanding if I wasn't bogged down doing arithmetic. Just compare solving a 5x5 matrix by hand versus dropping it into MATLAB. Statics was a fun class but it will be more fun with MATLAB. He can spend more time understanding WHY elements are in tension or compression and not wondering if he dropped a sign.Things were NOT better! The tools, the online tutorials, even the textbooks are far superior to what the 'old folks' had. I wish I were back in college! I would eat that stuff up.

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 04:15:13 pm
content: Quote from: rstofer on April 11, 2019, 03:49:56 pmWhen at university (mid 70s) I went to an APL talk by someone from IBM Hursley. It was interesting, albeit at 90degrees to everything else in the world! That's where I squirrelled that fragment away in my mind, to be excavated when "helpful".I wonder what, if anything, buried code will think of it

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 04:24:48 pm
content: Quote from: Buriedcode on April 11, 2019, 02:59:11 pmIt isn't algebra, it is arithmetic. When a mathsteacherlectures me about the evils of calculators, I expect them to know what 1+2*3 is. It can be fun to watch their faces when I show them a calculator which says "7" when they expect "9".QuoteMichael Gove will say whatever he thinks his audience wants him to say; usually he gets that rightBesides, most childrencanbe above average. Given these examples scores, 90% are above average: 5 5 5 5 5 5 5 5 5 4.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: April 11, 2019, 04:27:16 pm
content: From the Web, with all the assurance provided by that source.History LessonSo where did this order of operations come from? Whose fault is it? =^)1646 - In Van Schooten's 1646 edition of Vieta, B in D quad. + B in D is used to represent B(D^2 + BD).1800s - The term "order of operations" was starting to get used in textbooks. It was used more by textbooks than mathematicians. The mathematicians mostly just agreed without feeling the need to state anything official.1920s - In this time period, the mathematicians were debating about whether or not multiplication should take precedence over division. Although they'd still argue over who won this argument, today it's become most common (and taught predominantly) that multiplication and division are equal, read from left to right. The reasoning is to keep it simple and to let the parentheses do it's thing!1960s - As mathematicians began writing books about algebraic notation, they basically agreed on the idea that multiplication would take precedence over addition. It's a natural hierarchy that lends itself well to writing polynomials with as few parentheses as possible. So at a time when the authors of these books on mathematics had to begin their book with a list of conventions... it wasn't needed on the basic order of operations... they all seemed to have agreed.You'll still find textbooks that don't fully agree with each other, but the basics are commonly set now, and the world is full of order and peace, thanks to the Order of Operations!This actually agrees fairly well with what I understood. These conventions have simmered for quite a while, but the definitions have only stabilized in the last century. The importance grew dramatically around the 1950-1960 time frame when computers came along and multiplied the consequences of mistakes. Until machines got in the act a misunderstanding didn't propagate very far before it became obvious and could be corrected.I think Brumby said it best. There is still enough confusion in this (clearly demonstrated by the number of internet polls on the result of some sequence of operations and by Excel and APLs choice of going another direction) that if you care about the answer being determined correctly use parenthesis as required. Even if there is one true way to do precedence the odds are high that someone out there will not understand them or use the same rules. We use checksums and error correcting codes to ensure correct communications. Parenthesis serve the same purpose. Extras symbols, but correct transmission.

author: Buriedcode
author_rank: Super Contributor
timestamp: April 11, 2019, 05:53:30 pm
content: Quote from: metrologist on April 11, 2019, 04:05:11 pmI can't say I've seen the evidence for primary school teachers not knowing about precedence in mathematics, I only know two, and both seem pretty well educated to me, but it seems to be quite a specific thing to claim. And I still don't know what this really has to do with the thread. Again - why pick on primary school teachers? (I'm assuming this is specific to the UK, since the term "primary school" is generally a UK thing).It seems I've hit a few nerves in this thread. I apologise, it wasn't my intention to insult or anger anyone. I amazed (and impressed) by how passionate some get over such matters. I now see that excel, as well as other software do things differently to convention, but these can be mitigated through use of parentheses. What else is there to the thread?

author: ebastler
author_rank: Super Contributor
timestamp: April 11, 2019, 06:17:08 pm
content: Quote from: Buriedcode on April 11, 2019, 05:53:30 pmNothing, really. Except that, whenever the thread seems to have reached that consensus, someone new pops in and states the opposite.Lets give it another day. My guess is that someone will come along, wondering what all this debate is about, given the obvious fact that -34= 81.

author: tggzzz
author_rank: Super Contributor
timestamp: April 11, 2019, 06:23:44 pm
content: Quote from: Buriedcode on April 11, 2019, 05:53:30 pmIn my limited experience, slightly under half instantly give the wrong answer, and are difficult to persuade there might even be a question. A clued up minority ask where the parentheses are, and are then realise they've forgotten the normal laws of arithmetic. Very few confidently give the right answer.QuoteYup, that's the point.

author: 0culus
author_rank: Super Contributor
timestamp: April 11, 2019, 06:58:44 pm
content: Quote from: rstofer on April 11, 2019, 04:06:28 pmI agree. I think there is a certain value to learning to manipulate 2x2 and 3x3 systems by hand...beyond that it's pure drudgery and you'll spend more time correcting mistakes than you do understanding the problem.