wischi

joined 1 year ago
[–] wischi@programming.dev 5 points 11 months ago* (last edited 11 months ago)

Joules is unfortunately a vector because it's over a distance in a direction.

What? Joule is an energy unit and energy is a scalar quantity and not a vector. There is no "energy direction" and no "distance".

Edit: even your edit doesn't make sense. Provide a source that says that energy or joule is somehow a vector.

[–] wischi@programming.dev 1 points 11 months ago* (last edited 11 months ago)

Just saw the image you posted and it's awesome :-) I'm part of the group that can't solve it, because I don't know the 🌭 function from the top of my head. I also found the choice of symbols interesting that 🌭 is analytical continuation of 🍔 and not the other way round 🤣

[–] wischi@programming.dev 1 points 11 months ago

Chat GPT's answer for me:

Certainly! The expression 6/2(1+2) is ambiguous due to the implicit multiplication. Let's solve it in both ways:

  1. Implicit multiplication with higher priority:

[ \frac{6}{2}(1+2) ]

First, solve the parentheses:

[ \frac{6}{2}(3) ]

Now, perform the division:

[ 3 \times 3 = 9 ]

  1. Implicit multiplication with the same priority as division:

[ \frac{6}{2(1+2)} ]

Again, solve the parentheses:

[ \frac{6}{2(3)} ]

Now, perform the multiplication first:

[ \frac{6}{6} = 1 ]

So, depending on the interpretation of implicit multiplication, you can get different results: 9 or 1.

I think it's funny that ChatGPT figured out 1 and 9 but has the steps completely backwards. First it points out what has high priority and then does the exact opposite, both times 🤣

[–] wischi@programming.dev 2 points 11 months ago

Thank you for taking the time reading it.

[–] wischi@programming.dev 4 points 11 months ago* (last edited 11 months ago)

Standards are as mentioned in the article often extra careful to prevent confusion and thus often stricter than widespread conventions with things they allow and don't allow.

a/b*c is not ambiguous because no widespread convention would treat it any other way than (a/b)*c.

But you can certainly try to proof me wrong by showing me a calculator that would evaluate 6/2*3 to anything but 9.

So if there is not a single calculator out there that would come to a different result, how can it be ambiguous?

Update: Standards are rule-books for real projects to make it simpler to work together. It's a bit like a Scrabble dictionary. If a word is missing in the official Scrabble dictionary, it doesn't automatically mean that it's not a real word, it just means that it wouldn't be allowed to play that word in official Scrabble tournaments.

Same with (ISO) standards. Just because the standard forbids it doesn't mean it's not widespread or forbidden generally. It's only forbidden in a context where all participants agreed to follow the standard.

[–] wischi@programming.dev 1 points 11 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"

[–] wischi@programming.dev 1 points 11 months ago (2 children)

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

[–] wischi@programming.dev 4 points 11 months ago* (last edited 11 months ago)

It's practically impossible to do that because (applied) mathematics is such a diverse field and there is no global authority (and really can't be).

Math notation is very similar to natural languages what you are proposing is a bit like saying we have an ambiguity in english with the word "bat". It can mean the animal or the sport device. To prevent confusion the oxford dictionary editors just decide that from now on "bat" only refers to the animal and not the club. Problem solved globally? Probably not :-)

What you can do/try is to enforce some rules in smaller groups, like various style guides and standards are trying to do. For example it's way simpler for a university to enforce certain conventions and styles for the work they and their students produce. But all engineers in Belgium couldn't care less what a university in India is thinking about math notations.

For real projects that involve many people there are typically industry standards that are followed that work a bit like in the university example and is enforced by the participants of the project.

[–] wischi@programming.dev 2 points 11 months ago (3 children)
[–] wischi@programming.dev 1 points 11 months ago (4 children)

It depends on what you mean by global agreement as there is no single source of truth but the left-to-right rule is pretty much default for multiplications/divisions and additions/subtractions. If you however have inline power notations with "^" symbol they are evaluated right-to-left. There are exceptions but those are typically well known in the industry. For example MathCad also evaluates powers from left to right, which is fairly untypical.

It's not wrong if you make clear what you are doing. You can for example in a diagram call the axis a and b, not really wrong but pretty untypical if everybody else uses x and y, so you should have at least good reasons when doing it differently.

[–] wischi@programming.dev 2 points 11 months ago

You are right the manual isn't very clear here. My guess is that parentheses are also considered Type B functions. I actually chose those calculators because I have them here and can test things and because they split the implicit multiplication priority. Most other calculators just state "implicit multiplication" and that's it.

My guess is that the list of Type B functions is not complete but implicit multiplication with parentheses should be considered important enough for it to be documented.

[–] wischi@programming.dev 10 points 11 months ago* (last edited 11 months ago)

In the blog post there are even more. Texas Instruments, HP and Canon also have calculators, and some of them show 9 and some 1.

view more: ‹ prev next ›