Page 1 of 1

1/xy

Posted: Wed Jan 27, 2016 12:13 pm UTC
by quantropy
I couldn't decide whether to ask this in coding or computer science, so I put it here. Should multiplication ever have implied precedence over division? And how come http://www.wolframalpha.com/input/?i=1%2Fnx%2C1%2F2x?

Re: 1/xy

Posted: Wed Jan 27, 2016 9:59 pm UTC
by Flumble
Infix notation is stupid to begin with –it only really works for commutative associative operators. Polish or graph notation FTW!

Maybe, just maybe, polish notation could even accelerate the understanding of solving algebraic equations.



Clearly, variables tucked together take precedence over division or constant fractions take precedence over everything. It makes perfect sense.

Re: 1/xy

Posted: Fri Jan 29, 2016 4:42 am UTC
by Qaanol
There is no situation—none—in which I would write (1/xy) to mean (y/x).

Re: 1/xy

Posted: Fri Jan 29, 2016 5:29 am UTC
by EvanED
I think there is a clear answer -- (1/x)*y -- but I also think that anyone who seriously writes 1/xy in the first place should be banished from ever writing anything mathematical again. :-)

Re: 1/xy

Posted: Fri Jan 29, 2016 1:45 pm UTC
by doogly
But I feel like a bait and switch happened here. I voted to parse 1/xy as 1/(xy), which I stand by, but then the link complains that 1/2x is parsed as (1/2)x. And I stand by that too. Of course mathematically there shouldn't be a difference, but this is about notation, and how to make due with limited formatting options.

I would rather write \frac{1}{2}gt^2, but I will make due with other environments with 1/2gt^2 (or 1/2 gt^2, with a lil extra space there) in favor of (gt^2)/2.

Re: 1/xy

Posted: Fri Jan 29, 2016 2:29 pm UTC
by EvanED
doogly wrote:Of course mathematically there shouldn't be a difference, but this is about notation, and how to make due with limited formatting options.
But the other part of notation is to have predictable rules that lead to everyone having the same unambiguous interpretation. I agree that 1/xy seems like it should be 1/(xy), but I kind of doubt that you can pick a (i) clear (ii) simple (iii) predictable and (iv) unambiguous rule that interprets 1/xy that way but that wouldn't lead to other, bigger problems with other expressions.

For example, suppose 1/xy is 1/(xy) and 1/2x is (1/2)x. What's 1/2(x+y), or 1/x(y+z)? 1/(x+y)2, or 1/(y+z)x. I don't even know if I can tell you what I meant, and I wrote those expressions.

So there's a conflict. The only reasonable rule IMO leads to (1/x)*y, but if you look at it in isolation, 1/xy looks like it should be 1/(xy). So that means that you shouldn't write 1/xy in the first place. This is a mathematical analogue to the distinction in programming between a program "having no obvious errors" and a program "obviously having no errors."

The only thing that I can think might work is implied multiplication -- xy instead of x*y -- having its own precedence level. But that seems very silly and error-prone, and leads to 1/2x being 1/(2x) anyway.

Re: 1/xy

Posted: Fri Jan 29, 2016 4:39 pm UTC
by Flumble
EvanED wrote:
doogly wrote:Of course mathematically there shouldn't be a difference, but this is about notation, and how to make due with limited formatting options.
But the other part of notation is to have predictable rules that lead to everyone having the same unambiguous interpretation. I agree that 1/xy seems like it should be 1/(xy), but I kind of doubt that you can pick a (i) clear (ii) simple (iii) predictable and (iv) unambiguous rule that interprets 1/xy that way but that wouldn't lead to other, bigger problems with other expressions.

I'd argue that you don't need strict rules for small expressions in context. There's three things emphasised, but the third one is probably the most important: 1/2x, 1/xy and 1/2gt^2 are ill-defined without context (especially since not everyone agrees that multiplication and division have the same precedence and go left-to-right), so the context should point out which relation is linearly or inversely proportional. In the case of 1/2gt^2 it is implied that it's * * g / 1 2 ^ t 2 because it looks like the formula for gravitational acceleration.

Re: 1/xy

Posted: Tue Feb 02, 2016 11:06 pm UTC
by Derek
EvanED wrote:But the other part of notation is to have predictable rules that lead to everyone having the same unambiguous interpretation. I agree that 1/xy seems like it should be 1/(xy), but I kind of doubt that you can pick a (i) clear (ii) simple (iii) predictable and (iv) unambiguous rule that interprets 1/xy that way but that wouldn't lead to other, bigger problems with other expressions.

Under strict interpretations I would parse 1/xy as a syntax error. If I'm going to assign it a value then I have to interpret what you meant, and that may lead to inconsistent results.

Re: 1/xy

Posted: Fri Feb 05, 2016 1:20 pm UTC
by dalcde
Flumble wrote:Infix notation is stupid to begin with –it only really works for commutative associative operators. Polish or graph notation FTW!

Subtraction?

Re: 1/xy

Posted: Wed Aug 24, 2016 12:41 am UTC
by Boson Collider
dalcde wrote:
Flumble wrote:Infix notation is stupid to begin with –it only really works for commutative associative operators. Polish or graph notation FTW!

Subtraction?


1 - 2 - 3 - 1 can be parenthetized in many different ways and thus is ambiguous, unless you first do all negations and then do additions, as in 1 + (-1) + (-3) + (-1), which is what most people would expect as a result. But then it does work strictly because of associativity.

Now, commutativity I disagree with, it has nothing to do with that and infix notation handles associative noncommutative products perfectly, see matrix notation. For linear algebra algebraic notation is way, way cleaner than RPN, because RPN is terrible at handling operators that act on operators.

For non-associative operators like cross products, RPN starts being really nice. For things that are completely nonassociative, RPN is awesome.

I mean, try looking at this article on quandles, and translating the axioms into RPN. It's a lot nicer!
https://en.wikipedia.org/wiki/Racks_and_quandles

(Though two-dimensional notations can be even better.)

Re: 1/xy

Posted: Sat Dec 10, 2016 11:04 am UTC
by somitomi
And that's why I hate that slanted nonsense. It's a really nice example of the horizontal division bar being so much better.
If I'm really pressed to interpret it, it'd be 1/(xy), because anyone writing y/x as (1/x)y clearly deserves some kind of punishment for it, but otherwise I'd recommend using bracket everywhere. Altough if I were to write a program that has some mathematical formula as input, the only way to enter any form of divison would be the aforementioned horizontal divison bar (I can't for the life of me find an English word for it).

Re: 1/xy

Posted: Tue Dec 20, 2016 12:55 am UTC
by DrZiro
As EvanED points out, we do need to have a strict rule, and the rule being different for literals and variables is definitely confusing. Either they have the same precedence, or different. And having another rule for implied multiplication also sounds like a terrible idea.

The way things are, they clearly have the same precedence. So 1/xy clearly does mean (1/x)*y. Whether it should mean that is a different matter, and I'm inclined to say that it would be better the other way.

I would argue that they do have different precedence in one case, though, which is for units. If I write that 1 H = 1 N/Am, no one could reasonably interpret that as (N/A)*m.

I also think that prefix or postfix notation is neat in many ways. Although I'm not a fan of calling them "Polish" and "reverse Polish". Sounds kind of like an insult, a bit like "it's all Greek to me". I know that's not the historical reason, but still. "Prefix" and "postfix" are definitely better terms - shorter, clearer, more consistent.

Re: 1/xy

Posted: Sun Dec 25, 2016 4:22 pm UTC
by lightvector
I also tend to be a fan of "infix division has strictly lower precedence than multiplication" rather than having equal precedence. I think it's a better convention, and I use it a lot when scribbling to myself on paper or doing back-of-the-envelope math. It even fits that acronym that people learn (or at least that I heard) in grade school: PEMD(AS). The M and the D are in the right order for it to still work.