https://zeta.one/viral-math/

I wrote a (very long) blog post about those viral math problems and am looking for feedback, especially from people who are not convinced that the problem is ambiguous.

It’s about a 30min read so thank you in advance if you really take the time to read it, but I think it’s worth it if you joined such discussions in the past, but I’m probably biased because I wrote it :)

  • wischi@programming.devOP
    link
    fedilink
    arrow-up
    1
    ·
    7 months ago

    Regarding the parenthesis the C# static code analyzer can be set to remove unnecessary parentheses.

    https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048

    IDE0047 is the static analyzer rule for “Remove unnecessary parentheses”

    The default for those rules is to enforce parentheses on binary operations (because most people aren’t as familiar with the binary operator priorities as they are with regular math operator priorities) and remove unnecessary ones in other mathematical expressions.

    Besides that I can’t remember that I saw a standard that states to only use parentheses if needed but I think it’s reasonable ro assume that most people would do that anyway. Writing ((((5+3)))*2) is obviously stupid even though I can’t think of any style guide that would explicitly state not doing that.

    What many style guides actually state is to use proper fractions (horizontal bar) where ever possible.

    Regarding the ambiguity with the implicit multiplication and division. The division is indeed required to make it ambiguous but actually only some kind of trigger

    Let’s take 6(1+2)/2. Even though the priorities with weak and strong juxtaposition are not the same with respect to the implicit multiplication the answer would be the same but if you would think about the problem like a computer the way to get to the answer would be different (for example the calculators I mentioned in the article would do different things internally)

    Strong juxtaposition: you solve the implicit multiplication first because it has higher priority than the division. After that you do the division. Answer is 9.

    Weak juxtaposition: implicit multiplication has the same priority as division. You do them left to right and actually end up with the same result even when following different conventions.

    So the implicit multiplication is the reason why there are two conflicting conventions (which are necessary for the ambiguity because if there would be only one widespread convention it wouldn’t be ambiguous) and the division is required to trigger the ambiguity (show where the two conventions differ).

    The LTR thing is actually a very wide spread convention. I’m not familiar will all cultures on earth but my guess is of you use Arabic numerals and + and - you will work left to right for multiplication/division and addition/subtraction.

    If one has a bit of math experience you can actually solve multiplication/division and subtraction/addition in any order (if you know what you are doing) like I described here: https://programming.dev/comment/5661037

    • dgmib@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      7 months ago

      I concur with everything you’ve written here.

      I concur that a left-to-right interpretation of consecutive explicit multiplication and division is wide spread and how most calculators and computers would interpret:

      a / b * c.

      But the sources you quote in your blog post and the style guides I’ve read, state that a fraction bar or parenthesis should be used to clarify if it should be interpreted as:

      (a / b) * c

      or

      a / (b * c)

      You make the argument in your post that:

      a / bc

      is ambiguous (which I agree with)

      but

      a / b * c

      is not ambiguous. Which is the part I disagree with, and I think the sources you quoted disagree with you as well. But I’m open to being wrong about that and am interested if you have sources that prove otherwise.

      If I’m understanding your response correctly, you believe that

      a / b * c

      is unambiguous, and always treated like

      (a / b) * c

      because of a wide spread convention of left-to-right interpretation (a convention that we both agree exists), not because you found a source that states that.

      Anyhow… I’m not out to convince you of anything and I appreciate you taking the time to explain your thinking to me.

      • wischi@programming.devOP
        link
        fedilink
        arrow-up
        1
        ·
        7 months ago

        Exactly a/b*c equals (a/b)*c but I’d instantly reconsider my position if you can show me a single calculator that would handle that diffently (credible calculator, not the once that some students program for homework assignments).

        Even though one shouldn’t treat calculators as some kind of authority but if all calculators handle it that way (all calculators of the five major manufacturers, Google, MathCad, Mathematics, various open source CAS) it’s probably a very good indictator that it’s not ambiguous.

        What I also mentioned in the article is that standards and guidelines are typically stricter than most conventions in the name of clarity. So some of them even forbid things like “a / b * c” even if practically everybody agrees how this should be interpreted, just to be “extra-safe”