• mindbleach@sh.itjust.works
    link
    fedilink
    arrow-up
    112
    ·
    11 months ago

    Different compilers have robbed me of all trust in order-of-operations. If there’s any possibility of ambiguity - it’s going in parentheses. If something’s fucky and I can’t tell where, well, better parenthesize my equations, just in case.

    • linuxdweeb@lemm.ee
      link
      fedilink
      arrow-up
      9
      ·
      11 months ago

      This is best practice since there is no standard order of operations across languages. It’s an easy place for bugs to sneak in, and it takes a non-insignificant amount of time to debug.

    • Crozekiel@lemmy.zip
      link
      fedilink
      arrow-up
      2
      ·
      11 months ago

      This is the way. It’s an intentionally ambiguously written problem to cause this issue depending on how and where you learned order of operations to cause a fight.

        • Crozekiel@lemmy.zip
          link
          fedilink
          English
          arrow-up
          2
          ·
          8 months ago

          Please see this section of Wikipedia on the order of operations.

          The “math” itself might not be ambiguous, but how we write it down absolutely can be. This is why you don’t see actual mathematicians arguing over which one of these calculators is correct - it is not either calculator being wrong, it is a poorly constructed equation.

          As for order of operations, they are “meant to be” the same everywhere, but they are taught differently. US - PEMDAS vs UK - BODMAS (notice division and multiplication swapped places). Now, they will say they are both given equal priority, but you can’t actually do all of the multiplication and division at one time. Some are taught to simply work left to right, while others are taught to do multiplication first; but we are all taught to use parentheses correctly to eliminate ambiguity.

          • Please see this section of Wikipedia on the order of operations

            That section is about multiplication, and there isn’t any multiplication in this expression.

            The “math” itself might not be ambiguous, but how we write it down absolutely can be

            Not in this case it isn’t. It has been written in a way which obeys all the rules of Maths.

            This is why you don’t see actual mathematicians arguing over which one of these calculators is correct

            But I do! I see University lecturers - who have forgotten their high school Maths rules (which is where this topic is taught) - arguing about it.

            it is not either calculator being wrong

            Yes, it is. The app written by the programmer is ignoring The Distributive Law (most likely because the programmer has forgotten it and not bothered to check his Maths is correct first).

            US - PEMDAS vs UK - BODMAS

            Those aren’t the rules. They are mnemonics to help you remember the rules

            notice division and multiplication swapped places

            Yes, that’s right, because they have equal precedence and it literally doesn’t matter which way around you do them.

            you can’t actually do all of the multiplication and division at one time

            Yes, you can!

            Some are taught to simply work left to right

            Yes, that’s because that’s the easy way to obey the actual rule of Left associativity.

            we are all taught to use parentheses correctly to eliminate ambiguity

            Correct! So 2(2+2) unambiguously has to be done before the division.

            • Crozekiel@lemmy.zip
              link
              fedilink
              English
              arrow-up
              1
              ·
              7 months ago

              Just out of curiosity, what is the first 2 doing in “2(2+2)”…? What are you doing with it? Possibly multiplying it with something else?

              there isn’t any multiplication in this expression.

              Interesting.

              I really hope you aren’t actually a math teacher, because I feel bad for your students being taught so poorly by someone that barely has a middle school understanding of math. And for the record, I doubt anyone is going to accept links to your blog as proof that you are correct.

              • Just out of curiosity, what is the first 2 doing in “2(2+2)”…? What are you doing with it? Possibly multiplying it with something else?

                Distributing it, as per The Distributive Law. Even Khan Academy makes sure to not call it “multiplication”, because that refers literally to multiplication signs., which, as I said, there aren’t any in this expression - only brackets and division (and addition within the brackets).

                I feel bad for your students

                My students are doing well thanks.

                I doubt anyone is going to accept links to your blog as proof that you are correct

                You mean the blog that has Maths text book references, historical Maths documents, and proofs? You know proofs are always true, right? But thanks for the ad hominem anyway, instead of any actual proof or evidence to support your own claims.

      • mindbleach@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        ·
        8 months ago

        That’s the same ambiguity, numbnuts. Your added parentheses do nothing. If you wanted to express the value 8 over the value 2*(1+3), you should write 8/(2*(1+3)). That is how you eliminate other valid interpretations.

        As illustration of why there are competing valid interpretations: what human being is going to read “8/2 * (1+3)” as anything but 4*4? Those spaces create semantic separation. But obviously most calculators don’t have a spacebar, any more than they have to ability to draw a big horizontal line and place 2(1+3) underneath it. Ambiguous syntax for expressing mathematics is not some foundation-shaking contradiction. It’s a consequence of limitations in how we express even the most concrete ideas.

        “The rules of math” you keep spamming about are not mathematical proofs - they’re arbitrary decisions made by individuals and organizations. In many cases the opposite choice would be equally sensible. Unlike the innate equivalence of multiplication and division, where dividing by two and multiplying by half are interchangeable. Same with addition and subtraction.

        Do you want to argue that 8 - (2) + (1+3) should be 2?

        • Your added parentheses do nothing

          So you’re saying Brackets aren’t first in order of operations? What do you think brackets are for?

          If you wanted to express the value 8 over the value 2*(1+3), you should write 8/(2*(1+3))

          or, more correctly 8/2(1+3), as per the rules of Maths (we never write unnecessary brackets).

          That is how you eliminate other valid interpretations

          There aren’t any other valid interpretations. #MathsIsNeverAmbiguous

          what human being is going to read “8/2 * (1+3)” as anything but 4*4

          Yes, that’s right, but 8/2x(1+3) isn’t the same as 8/2(1+3). That’s the mistake that a lot of people make - disobeying The Distributive Law.

          Those spaces

          …have no meaning in Maths. The thing that separates the Terms, in your example, is the multiply. i.e. an operator.

          most calculators don’t have a spacebar

          …because it’s literally meaningless in Maths.

          any more than they have to ability to draw a big horizontal line and place 2(1+3) underneath it

          Some of them can actually.

          “The rules of math” you keep spamming about are not mathematical proofs

          You should’ve read further on then. Here’s the proof.

          they’re arbitrary decisions made by individuals

          No, they’re a natural consequence of the way we have defined operators. e.g. 2x3=2+2+2, therefore we have to do multiplication before addition.

          In many cases the opposite choice would be equally sensible

          2+2x3=2+6=8 the correct answer, but if I do addition first…

          2+2x3=4x3=12, which is the wrong answer. How is getting the wrong answer “equally sensible” as getting the right answer?

          Do you want to argue that 8 - (2) + (1+3) should be 2?

          No, why would I do that? 8-(2+1+3) does equal 2 though.

          • mindbleach@sh.itjust.works
            link
            fedilink
            arrow-up
            2
            ·
            8 months ago

            You are a smug idiot.

            8/2(1+3) is exactly the sort of thing programs love to misinterpret. I don’t give a shit what “rules of math” you insist are super duper universal, or what “we” do. They are not reliable. Clear parentheses are. Insisting you’re correct is not relevant. You stumbled into a pragmatic issue with grand philosophical assurances that aren’t even sound.

            Yes, that’s right, but 8/2x(1+3) isn’t the same as 8/2(1+3).

            … no, that’s fucking stupid.

            Some of them can actually.

            Hence the word “most.” Your cocksure months-late manic episode across this thread is the most “akshually” thing I have ever witnessed.

            Here’s the proof.

            You dense bastard! That’s a category error! You can’t prove that 2(3) means something different from 2*3. It’s only convention! It’s a thing we made up, unlike actual mathematical proofs, which are laws of the universe. If everyone disagreed with that then it would stop being true. That’s not a sentence you can say about anything that has a proof, instead of some evidence.

            You keep talking about “rules of math” when what you mean is rules of this particular notation. Reverse Polish Notation doesn’t have this issue, at all. Distribution is not even possible in RPN. So however important you think it might be… it’s not universal.

            [Those spaces] have no meaning in Maths.

            THAT’S THE POINT, NUMBNUTS. It’s semantic separation that human beings will read in for context. Which they need, because some grammars have ambiguities, which can only be resolved by convention. Like how -6 is a number, and you can add or multiply -6, but 1 + -6 looks kinda weird, -6(3) is fine, and (3) -6 is asking for trouble.

            The convention overwhelmingly used in computation is that parentheses are resolved first. Nothing is distributed over them - they are evaluated, and then used. In exactly the same way that multiplication can be treated as repeated addition, operations on parentheticals are treated as operations on equations reduced to scalars. It doesn’t fucking mean anything, to say 8/2*(1+3) is different from 8/2(1+3), because in the notation used by coders, they both become 8/2*4.

            You might as well barge in pick a fight with N=N+1.

            • You are a smug idiot

              That’s your colloquialism for Maths teachers. Ok, got it.

              8/2(1+3) is exactly the sort of thing programs love to misinterpret.

              Programs, written by programmers, who have forgotten the rules of Maths.

              that’s fucking stupid

              So you’re saying the rules of Maths are stupid. Got it.

              You can’t prove that 2(3) means something different from 2*3. It’s only convention!

              No, it’s a rule of Maths - it’s literally the opposite operation to factorising.

              It’s a thing we made up

              Nothing in Maths is made up. It’s based on our observations of how things work.

              mathematical proofs, which are laws of the universe

              Now you’re getting it.

              this particular notation

              …which is Maths.

              Reverse Polish Notation doesn’t have this issue, at all

              Neither does infix notation. All notations have to obey the rules of Maths, since the rules of Maths are universal.

              Distribution is not even possible in RPN

              Second hit in my Google results…

              (3) -6 is asking for trouble

              It’s -3 - where’s the trouble?

              say 8/2*(1+3) is different from 8/2(1+3), because in the notation used by coders, they both become 8/2*4

              Welcome to why almost every single e-calculator is wrong (as opposed to handheld calculators) - MathGPT gets it right.

              • mindbleach@sh.itjust.works
                link
                fedilink
                arrow-up
                2
                ·
                8 months ago

                Nothing in Maths is made up. It’s based on our observations of how things work.

                The notation and syntax of how we express that, is made-up. There’s multiple options. There’s disagreements. Fuck me sideways, you are a teacher, and you can’t figure out how being off-topic works?

                Evidently not, as you flip between ‘this particular notation is the notation!’ to ‘of course other notations exist’ and suffer zero cognitive dissonance. By capital-M “Maths,” do you mean the notation on paper, or the underlying laws-of-reality stuff? It depends! It’s ambiguous and requires context, or maybe you’re just factually wrong at least one of those times, and either way, that means it’s plainly not THE SAME KIND OF THING as the laws-of-reality stuff.

                It’s a category error. You can prove that the word prove isn’t spelled proove, for some reason, but the heavens would not bend the other direction if that changed. We could swap square braces and parenthesis and nothing would be different. We could use the glyph “&” instead of “7.” These details are mutable and completely fucking arbitrary. But then & - 6 = 1, and you could never proove otherwise.

                Second hit in my Google results…

                Shows B being subtracted from A before that value is multiplied by C. It’s not distribution. It’s evaluating the parenthetical.

                It’s -3 - where’s the trouble?

                The fact it’s 3 and -6, not 3 - 6. Which is why I explicitly mentioned that -6 was a number, and used two other examples with -6. I wasn’t just making conversation. Jesus fucking Christ, a state trusts you with the education of children.

                According to the textbook you’re now screenshotting at people, A(B) and (B)A are both correct - yes? They’re both valid? And spaces have no impact on an equation? And writing equations like -6 + 1 are fine, instead of (-6) + 1, since you don’t want needless parentheses?

                • ‘this particular notation is the notation!’ to ‘of course other notations exist’

                  The notation for division in some countries is the obelus, in other countries it’s a colon. Whatever country you’re in, the notation for that country is the notation for division (be it an obelus or a colon).

                  Maths,” do you mean the notation on paper, or the underlying laws-of-reality stuff

                  Both! Whatever notation your country uses, all the rules for Maths and use of that Maths notation are defined.

                  It’s ambiguous

                  No, it’s not.

                  It’s not distribution. It’s evaluating the parenthetical

                  And Distribution applies to brackets/parentheses where they have a coefficient. In other words, same same.

                  it’s 3 and -6, not 3 - 6

                  You didn’t put a comma between 3 and -6, so no, it’s not 3 and -6, it’s 3-6. That’s what you wrote, that’s what it is.

                  a state trusts you with the education of children

                  Related - have you noticed how children never get this wrong? It’s only adults who’ve forgotten the rules of Maths who get it wrong.

                  According to the textbook you’re now screenshotting at people, A(B) and (B)A are both correct - yes? They’re both valid? And spaces have no impact on an equation? And writing equations like -6 + 1 are fine, instead of (-6) + 1, since you don’t want needless parentheses?

                  Yes (though the latter is unconventional), yes (though the latter is unconventional), yes, yes (though unconventional - 1-6 is the conventional way to write that), yes, yes.

                  • mindbleach@sh.itjust.works
                    link
                    fedilink
                    arrow-up
                    1
                    ·
                    8 months ago

                    Again pointing straight at RPN: does the colon go between the operands, or after them? That too is notation. That too is negotiable.

                    The parts of mathematics that are eternal and discovered are separate from the parts that are arbitrary and invented. We are talking almost exclusively about the latter.

                    Both!

                    It’s ambiguous

                    No, it’s not.

                    Do you read the things you write?!

                    And Distribution applies to brackets/parentheses where they have a coefficient. In other words, same same.

                    No.

                    What?

                    No!

                    Do you even know what your argument is?

                    The central point you spammed a dozen people with, here in this thread from last year, is an insistence that multiplying by a parenthetical is different from distribution. You explicitly said 2(3+1) and 2*(3+1) are not the same thing. So when your hot second of Google knowledge shows (3+1), *2, converted to RPN, you do not get to claim that’s the same thing as distribution, goddammit!

                    You didn’t put a comma between 3 and -6, so no, it’s not 3 and -6, it’s 3-6. That’s what you wrote, that’s what it is.

                    No, dumbass, (3) -6 is the quantities 3 and -6 in the format (A)B. A format you go on to say is fine with zero reflection or recognition, because you’re experiencing this conversation one sentence at a time and putting absolutely zero thought into context or meaning.

                    I fucking hated teachers like you. You’re not listening. You’re just preaching.