Jump to content

Talk:Order of operations: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
Line 128: Line 128:


The other (unlinked) sources in the paragraph again support multiplication having higher precedence than division, though whether implied multiplication is relevant is unspecified. That leaves the claim with no supporting source. [[Special:Contributions/50.86.240.11|50.86.240.11]] ([[User talk:50.86.240.11|talk]]) 20:56, 7 February 2024 (UTC)
The other (unlinked) sources in the paragraph again support multiplication having higher precedence than division, though whether implied multiplication is relevant is unspecified. That leaves the claim with no supporting source. [[Special:Contributions/50.86.240.11|50.86.240.11]] ([[User talk:50.86.240.11|talk]]) 20:56, 7 February 2024 (UTC)

::The only thing that is clear is that insisting that multiplication takes precedence over division, whether in some cases or in all cases, leads to endless argument and confusion. What sources say is: avoid ambiguity. In physics, the matter may be decided, but not in mathematics. And it seems to me unnecessary to have one rule for some disciplines and a different rule for other disciplines. [[User:Rick Norwood|Rick Norwood]] ([[User talk:Rick Norwood|talk]]) 12:02, 11 February 2024 (UTC)

Revision as of 12:03, 11 February 2024

Infix notation

The second sentence of this article is:

These rules are meaningful only when infix notation is used. When functional or Polish notation are used for all operations, the order of operations results from the notation itself.

This is certainly correct, but might be too much this early in the article. My sense is that most of our readers are not familiar with the concepts of functional or polish notation, and those systems are not what this article is about. Granted, there are links for the reader to click, but my reading (assuming the perspective of a non-mathematician) is that this sentence is a distraction from the main thrust of the article.

I'd suggest simply moving this sentence to later in the article, perhaps just a paragraph or two. Alternatively, provide a parenthetical example so the reader doesn't have to click on the link to find out that infix notation is just the familiar way of writing mathematical expressions that they have come to know and love:

These rules are meaningful only when infix notation (e.g. 3 x 4 + 5) is used. When functional or Polish notation are used for all operations, the order of operations results from the notation itself.

Other opinions? Mr. Swordfish (talk) 15:28, 2 September 2023 (UTC)[reply]

Agree . I'd suggest to move the sentence to the very end of the lead, and to change "when infix notation is used" to "when the usual notation (called infix notation) is used". Adding an example for infix isn't useful, except when it is contrasted with (e.g.) Polish notation; so we could possible add a sentence like "For example, the infix expressions 3 × 4 + 5 and 3 × (4 + 5) are written as + × 3 4 5 and × 3 + 4 5 in Polish notation, respectively.". I'm afraid, however, that such a sentence won't be understood without additional (and then distracting) explanations. Maybe, reverse Polish notation is easier to explain; in fact is has been employed by HP calculators, so it may be known better. - Jochen Burghardt (talk) 15:54, 2 September 2023 (UTC)[reply]
Agree that if we move the sentence to the end of the intro section there is no need for an example. Also agree that providing examples of other notations here would just cause confusion for most of our audience. The curious can click the links to read about the alternative notations. Mr. Swordfish (talk) 18:39, 2 September 2023 (UTC)[reply]
I do not object to the new position of the paragraph on alternative notations. However:
  • "These rules are" may be unclear after the paragraph on memes. This may be clarified either by replacing "These rules are" by "The order of operations is" or by moving the paragraph before the paragraph on memes. Maybe, the best choice is to do both changes.
  • The reason for which I placed this paragrph near the beginning, was to emphasize that there is no mathematical concept here, but only notational convention. It may be useful to clarify this near the beginning of the lead.
I am not sure enough of the best choice for doing these changes myself. So, ... D.Lazard (talk) 21:02, 2 September 2023 (UTC)[reply]
Swapping the last two paragraphs does seem to clarify things, so I've gone ahead and implemented that change. That edit seems sufficient, but I can't say I'd object to the other. Mr. Swordfish (talk) 23:05, 2 September 2023 (UTC)[reply]

left to right

I am not surprised that my removing the false information "operations with the same precedence are generally performed left to right" was reverted. So many people have been taught that false "rule" in grade school that many people insist that what they learned in grade school is true. But all mathematicians know that addition is commutative and associative and multiplication is commutative and associative, and mathematicians generally perform operations in whatever order is most convenient.

It is a bit ironic that I think 12/6*2 = 4, which is what you get when you perform operations left to right. But most physicists insist that 12/6*2 = 1. Of course, my reasoning has nothing to do with left to right. It makes sense to me that subtraction is addition of the opposite and division is multiplication by the reciprocal. It is strange that after all these centuries, there is nobody who can settle the question. Rick Norwood (talk) 10:02, 5 September 2023 (UTC)[reply]

You might see from my edit summary that my reason for the revert was that your new text was flawed, too (as was/is the previous text). If you come up with a better suggestion how to fix the false information, I won't object.
As for your 2nd paragraph above, there is no question to be settled - it is very common in mathematics that different authors introduce different ("local") conventions and use them afterwards. - Jochen Burghardt (talk) 17:14, 5 September 2023 (UTC)[reply]
Agreed. Mathematics is a human language and like any other human language there are variations and no universal "correct" standard. This article presents a set of conventions that are not universally applicable as there is not a set of rules that are universally applicable.
Also agree that the current wording is flawed. Where there is a specification to be followed (e.g. computer languages, spreadsheet and other number crunching software) almost everything evaluates addition/subtraction left-to-right (with subtraction interpreted as adding the inverse)* while other non-transitive operations such as division and exponentiation are sometimes left-to-right and sometimes right-to-left. Hence all those ambiguous memes that have everybody arguing on facebook.
In short, there is no convention for evaluating expressions like 12/6*2. And we shouldn't imply that there is.
Perhaps we should say something like addition and subtraction is usually performed left-to-right but there is no general agreement for division or exponentiation. We'd need a good source to back it up, and it may be a distraction this early in the article. Or we could just remove the sentence. Not really sure what is the best approach.
  • And when done this way, there's no need for a rule since you get the same result due to associativity.
Mr. Swordfish (talk) 18:31, 5 September 2023 (UTC)[reply]

Standards from the style sheets of academic journals in Mathematics, Physic and Engineering

Since the style sheets of academic journals in mathematics, physics and engineering all agree since about 1920, I'm not sure why this is still so controversial.

I haven't seen any variance in the rules used by journals in the relevant fields, I think it is fairly clear
 Groupings (parenthesis, brackets, fraction bars)
 Unary Subtraction
 Exponents
 Juxtaposition (also called implied multiplication)
 Multiplication and Division
 Addition and Subtraction
 - when calculations are of equal precedence they are resolved from left to right
 - and the clarification that multiple exponents are read from the top down  — Preceding unsigned comment added by 2601:180:8300:8C50:DC15:E3C6:CE13:601F (talk) 21:50, 13 September 2023 (UTC)[reply] 
I would like to see the source for this. I do know that some physics journals prioritize juxtaposition but have never seen a math journal that did. There is no such operation as "unary subtraction". Subtraction is a binary operation. The unary minus is "negation". Rick Norwood (talk) 09:59, 14 September 2023 (UTC)[reply]
I would also like to see the source for this quote. My take is that if there really was an agreed upon standard we wouldn't see the variation among computer programming languages - the people who write the language specs are certainly capable of reading and applying a standard. Mr. Swordfish (talk) 17:19, 14 September 2023 (UTC)[reply]
Programming languages have different constraints than mathematical publication. In particular, the basic operators (+, -, *, /) do not obey the associative law: integer calculations can overflow depending on association, and floating-point calculations can give different results. So unlike in mathematics, how operations associate is important. Different languages also have different philosophies about reordering operations: some specify the order precisely, others allow the implementation to reorder. Again, this is not relevant to mathematics. Finally, mathematicians simply avoid writing anything ambiguous, whereas programming languages must accept any input they're given.
So I don't think you can draw conclusions about mathematical notation by looking at what programming languages do. --Macrakis (talk) 21:17, 15 September 2023 (UTC)[reply]
Hi, sorry, that 'quote' was me. I didn't intend it as a quote but as a generalization of many sources I've read. I guess I'm a noob in the Wikipedia editing system. First off, I did mean "unary minus" not "unary subtraction"; and also that line is wrong because -3^2 is -(3^2) not (-3)^2. So yes, that line is wrong or out of order. Second, I think exponents should be considered a type of grouping like fraction bars are. Third multiplication by Juxtaposition does seem to come before multiplication and division every where I check. Because 6/2n always means 6/(2n) not 3/n. 2601:180:8300:8C50:A1C5:F1DD:560E:BA72 (talk) 17:12, 18 September 2023 (UTC)[reply]
An interesting example is Physical Review Style and Notation Guide which says Multiplication *always* precedes division but also prohibits all multiplication signs except for a very special case involving line wraps inside an equation. So in this guide multiplication comes before division but all multiplication is by juxtaposition. 2601:180:8300:8C50:A1C5:F1DD:560E:BA72 (talk) 17:38, 18 September 2023 (UTC)[reply]
In physics they have their own rules. In mathematics, different rules. The only way to deal with this situation rationally is to use parentheses, e.g. 6/(2n) or (6/2)n. Rick Norwood (talk) 10:00, 19 September 2023 (UTC)[reply]
An expression such as unambiguously means and readers have no trouble interpreting this in ordinary circumstances, irrespective of whether they are in physics, mathematics, or any other field. If the other meaning were intended, it should instead be written or or etc. –jacobolus (t) 03:18, 12 January 2024 (UTC)[reply]
I'd never call "" unambiguous. If I meant "", I'd prefer to write "" to make that clear. If you have to write a program implementing some computation from some physics paper, and you come across "", you better complain the ambiguity to its author than translate it to the most similar x / 2 * y. - Jochen Burghardt (talk) 17:03, 14 January 2024 (UTC)[reply]
It was perfectly unambiguous until people started disagreeing on the interpretation, just like what happened to the words "trapezium" and "billion" (which, incidentally, all stem from the United States. What's up with that?). means , and if you wanted/intended then explicitly write out the multiplication symbol, . 203.218.11.233 (talk) 08:20, 5 February 2024 (UTC)[reply]
Is the trapezoid controversy you are talking about whether to consider a parallelogram a kind of trapezoid, or the controversy about whether "trapezoid" means the same as "trapezium" or whether it should mean a quadrilateral with no parallel sides?
The ancient Greek "exclusive" definition where a trapezia can't have more than one pair of parallel sides is a bad one IMO, comparable to the bad choice of definition that 1 (one), as a "unit", was not really a "number". –jacobolus (t) 17:12, 5 February 2024 (UTC)[reply]

Mixing of the rule, the implementation of the rules within different areas (calculator, programming languages)

The sentence "Calculators generally perform operations with the same precedence from left to right,[1] but some programming languages and calculators adopt different conventions. " does not fit where it is placed. The order of operation should apply on mathematical rules in general and not what calculators do in general. This is very confusing because by reading this, I only care on the rules and not what calculators do. Also, in this sentence you mix calculators (what the do most), rules within programming languages which does only explain, an implementation of the rules above. What I can not read, if the rules from left to right by the order of operation is a general rule. So this article for me explains nothing.

It would be much better to have a own section for *calculator* and what the do most, then an extra section for IT and maybe which language rules per default implements different. — Preceding unsigned comment added by Goldnas (talkcontribs) 11:24, 27 January 2024 (UTC)[reply]

The rulset itself, the implementation of the rulsets (as described in the article) are different things. Isn't it? Goldnas (talk) 11:26, 27 January 2024 (UTC)[reply]
I do not understand your concerns. Indeed, this article is about rules for interpreting formulas in view of doing the implied computation. The considered formulas consist of sequences of numbers (or variables representing them) and arithmetic operators that can be read by a human as well by a computer or a calculator. These rules are conventions, which means that human and computers can use different rules, and, depending of the context, different rules may be used. This is what is said in the article. The implementation of such rules is a very different thing it consist to write a program that follows the rules for interpreting formula. This is usually called an interpreter or a compiler, and it is not the subject of the article. D.Lazard (talk) 12:35, 27 January 2024 (UTC)[reply]
I want to see general
  • DEFINITION RULE which needs to be done if we have DIFFERENT precedence
  • DEFINITION RULE which needs to be executed if operation on SAME precedence
What I do not want to see here, if some calculators or same programming langauge IMPLEMENTATION OF Rule in calculators, in programming language. There is a own section for calculators and for programming language. But the general rule is not written down. The DEFINITION of equal precedence is mixed with IMPLEMENTATION in calculators and programming langauge.
It does not matter if humans or calculators read rules somehow. It is about the definition of rules.
Therefor the current article is not well written it is unclear and if you would refere to this article it would raise more questions like give answers. E.g.
If you refere to this article, some people might say: Yes, but there is not clear definition. Read the sentence:
"Calculators generally perform operations with the same precedence from left to right"
It does not say "Calculators always perform operations with the same precedence from left to right" which means to me, that there is no clear rule because not all calculators do the right thing. So this means I am right If I calculator 60/5*(2+1) I can do the result of 4.
You cannot prove that I am wrong and this article also prove nothing. There no sentence of the rule of evaluate operations on equal precedence, there is only a example of how some calculators and programming languages while it should be the sentence:
On higher ranked operations, evaluate from high to low, on equal rankted operations, evaluate from left to right. That would be a rule which I could implement in any programming language even on those who are not invented yet. Any developer would reject your definition and would ask the same question: How should the computer work if the operations ranked equally? And you would respond: from left to right. So lets write the article clean. The implemtation of rules is in the section available anyhow. Why write same things twice? Makes no sense at all. Goldnas (talk) 20:38, 3 February 2024 (UTC)[reply]
The convention for precedence varies from one context to another. The conventions in grade-school mnemonic mantras, pure-math papers, electronic calculators, and various programming languages all differ in various ways. –jacobolus (t) 21:17, 3 February 2024 (UTC)[reply]
No, this is not a convention thing. There are rules to execute. I could not implement the ruleset because there is no fully ruleset. And this is an easy one.
60/5*(2+1) evalutes
60/5*3 and then you have (as you can see) 2 opertion on the same level. It should be 100% clear what to do with operations on same level. This rule which is important is not described in the article. And not, this rules do not change, no matter if it is grade-school or pure-math papers. Whatever. The rule for what needs to be done on same level is missing here. Goldnas (talk) 21:37, 3 February 2024 (UTC)[reply]
The "rules" (i.e. conventions) are not universal, but vary depending on the context. –jacobolus (t) 21:42, 3 February 2024 (UTC)[reply]
Why do you double the statements. The statements about calculator and programming languages are in the other sections as well. Should't we remove it at all? Goldnas (talk) 22:26, 3 February 2024 (UTC)[reply]
What is the result of 60/5*3? Goldnas (talk) 22:30, 3 February 2024 (UTC)[reply]
I would typically interpret to mean in a technical document, and even more so if it were written in terms of variables like In a computer program, 60/5*3 instead typically means 12*3 == 36.
The interpretation depends on the context, and an expression like is somewhat ambiguous and often would be better to replace with a more explicit expression such as or depending on intention. –jacobolus (t) 22:56, 3 February 2024 (UTC)[reply]
But in this case, the section makes also no sense. In this case we would need to remove the sentence. Why? Because in section Calculators and Programming Languages the precedence is described. Goldnas (talk) 19:15, 4 February 2024 (UTC)[reply]
The fun part is, that in footnote 11 the write exact the same as I write. So we give a source how it should be done based on the same rule I wrote multiple times in the article but you revert it. Did you read the sources of this article and studied, if there is no contradiction?
Quote:
"BODMAS is an acronyn that serves as a reminder of the order in which operations have to be
carried out when working with equations and formulas:
Brackets pOwers Division Multiplication Addition Subtraction
where division and multiplication have the same priority, and so do addition and subtraction. If
you have several operations of the same priority then you work from left to right."
Sure that we want fo write different in the article compared to its sources? Goldnas (talk) 22:45, 3 February 2024 (UTC)[reply]
The sections are already their, my bad. But I still believe it does not fit. It is a repeation of the section below. The rule is missing. Goldnas (talk) 12:11, 27 January 2024 (UTC)[reply]

Programming languages

Logical OR and logical AND are non-associative and therefore should have equal precedence. Darcourse (talk) 13:32, 31 January 2024 (UTC)[reply]

Logical AND typically binds tighter than logical OR, because people like to write expressions like A && B || C && D and have that mean (A && B) || (C && D). It's possible there's some programming language where this doesn't hold, but it would be mildly practically inconvenient. –jacobolus (t) 15:34, 31 January 2024 (UTC)[reply]

Misrepresentation of Source

"In academic literature, multiplication denoted by juxtaposition (also known as implied multiplication) is interpreted as having higher precedence than division, so that 1 ÷ 2n equals 1 ÷ (2n), not (1 ÷ 2)n. For example, the manuscript submission instructions for the Physical Review journals state that multiplication is of higher precedence than division,[28]"

I looked at the source, and yes, it says that multiplication is of higher precedence than division. However, it does NOT say that this is only true in cases where there is implied multiplication. The phrase "for example" implies that this source should support the previous sentence, which is does not.

The other (unlinked) sources in the paragraph again support multiplication having higher precedence than division, though whether implied multiplication is relevant is unspecified. That leaves the claim with no supporting source. 50.86.240.11 (talk) 20:56, 7 February 2024 (UTC)[reply]

The only thing that is clear is that insisting that multiplication takes precedence over division, whether in some cases or in all cases, leads to endless argument and confusion. What sources say is: avoid ambiguity. In physics, the matter may be decided, but not in mathematics. And it seems to me unnecessary to have one rule for some disciplines and a different rule for other disciplines. Rick Norwood (talk) 12:02, 11 February 2024 (UTC)[reply]