reddit / emacs

calc is superior to virtually all competitors

lcvas · 2022-08-07 18:20
According to the [AMS Review Guide](https://web.archive.org/web/20000815202937/http://www.ams.org/authors/guide-reviewers.html) (Formulas section) and the [APS Style and Notation Guide](https://cdn.journals.aps.org/files/styleguide-pr.pdf) (page 23), 10/2\*5 equals to 1. Python, javascript, elixir, bc, google calculator and wolfram alpha all answer 25. C-x \* c ' 10/2\*5 answers 1.
LemonBreezes · 2022-08-07 18:53
How is 2*5 a multiplication by juxtoposition? Just curious because I'm not sure that applies here.
lcvas · 2022-08-07 18:59
The \* operator is the only way to multiply in all computer calculators, so it's used whether you're copying a explicit or a juxtaposed multiplication from paper. Only the AMS source is about juxtaposition, the APS is non-specific.
[deleted] · 2022-08-07 19:33
[deleted]
PhantomSeahorse · 2022-08-07 19:46
I’m not sure what you’re getting at. Seems like your example directly contradicts the AMS guide…?
lcvas · 2022-08-07 20:09
How so? The thing about juxtaposition is that when used it becomes obvious that multiplication gets higher precedence than division, so practically every source that relies on a division-multiplication precedence order relies on juxtaposition or vertical splits. Because calculators have neither, it's easier to paste a too-ambiguous-to-be-generally-used formula (like my example) from paper and get wrong results (unless you're using emacs). The APS is clear about multiplication coming first, but as this is a very corner case on paper math, almost every calculator is wrong and people don't even notice it.
[deleted] · 2022-08-07 20:17
[deleted]
janoc · 2022-08-07 20:21
Sorry but this isn't actually "correct" or even something universally agreed upon. The convention that multiplication by juxtaposition has higher priority is something that is very much a North American thing. Also the convention mentioned in the APS guide that multiplication has higher priority than division is not something universally accepted (APS - **American** Physical Society). (BTW, the APS guide explicitly tells you to parenthesize such expressions to avoid any ambiguity.) E.g. in Europe it is commonly taught that the multiplication (any type!) has the same priority as division and operations with equal priority are executed left to right. See e.g. the usual order of operations expressed here: [https://en.wikipedia.org/wiki/Order\_of\_operations](https://en.wikipedia.org/wiki/Order_of_operations) vs US using the PEMDAS rule: [https://www.splashlearn.com/math-vocabulary/algebra/order-of-operations](https://www.splashlearn.com/math-vocabulary/algebra/order-of-operations) (**multiplication before division**) vs New Zealand using the BEDMAS rule: [http://mathsfirst.massey.ac.nz/Algebra/OrderOfOp/orderAlg.htm](http://mathsfirst.massey.ac.nz/Algebra/OrderOfOp/orderAlg.htm) (**division before multiplication**) vs France: [https://www.jeuxmaths.fr/cours/priorites-operatoires.php](https://www.jeuxmaths.fr/cours/priorites-operatoires.php) (**no difference** between multiplication & division and between addition/subtraction, same as what Wikipedia has and what most programming languages use) Also, in computing (as opposed mathematical notation in papers or textbooks and such) it is almost never possible to express multiplication without expressly putting a multiplication operator (frequently asterisk) there because the expression could not be unambiguously parsed otherwise. In addition, note that both guides you are citing are intended for dealing with *publications* (i.e. papers, textbooks, etc.). They are **not** relevant whatsoever when dealing with actual computation, especially when it has to be typed in without any special input facilities some calculators have. See also the explanation why some TI calculators give one result and others something different: [https://education.ti.com/en/customer-support/knowledge-base/ti-83-84-plus-family/product-usage/11773](https://education.ti.com/en/customer-support/knowledge-base/ti-83-84-plus-family/product-usage/11773) And also this video: [https://www.youtube-nocookie.com/embed/S3R4r2xvVYQ](https://www.youtube-nocookie.com/embed/S3R4r2xvVYQ)
lcvas · 2022-08-07 20:28
>APS guide that multiplication has higher priority than division is something universally accepted So you concede only emacs is right here. EDIT: was edited. >actually enter that expression into Calc Note the ' (algebraic mode).
Xmgplays · 2022-08-07 20:29
> The * operator is the only way to multiply in all computer calculators Not correct. `qalc` allows `2(5)` as implicit multiplication.(And does the only sane thing for a calculator app when you input `10/2(5)`, which is ask how you want implicit multiplication to be interpreted)
janoc · 2022-08-07 20:42
>So you concede only emacs is right here. EDIT: was edited. That was a typo, I was still writing it. I tend to save the comment and then edit because I had Reddit lose my unfinished comment more than once. Emacs here just follows the US PEMDAS convention - hardly surprising given where and by whom it was written. This feature is documented here: "Notice: Calc gives ‘/’ lower precedence than ‘\*’, so that ‘a/b\*c’ is interpreted as ‘a/(b\*c)’; this is not standard across all computer languages. See below for details. " [https://www.gnu.org/software/emacs/manual/html\_node/calc/Algebraic-Tutorial.html](https://www.gnu.org/software/emacs/manual/html_node/calc/Algebraic-Tutorial.html) >Note the ' (algebraic mode). Yes, that's why I have removed that bit after I have noticed it.
PhantomSeahorse · 2022-08-07 20:44
Replying here because my reply might not fit in a comment chain. A couple of points here. First of all, I'm not seeing why the APS notation guide needs to followed by parsers for programming languages. That guide is for physics papers. And there is no such as thing as an "objectively correct operator precedence" either. It's one thing for work/papers in a specific field to follow a certain convention commonly accepted in the field. It's another thing to claim that convention from one field is universal in all fields. Second of all, the AMS review guide doesn't support your example at all. It only applies when multiplication is written in the form of juxtaposition. You seem to be mixing syntax with semantics. These notation guides apply purely on a syntactic level. They basically describe how to write a parser for these respective "languages". On the semantic level (think of an AST) there is no ambiguity to begin with. Lastly, the way you phrased the statement is rather strange. Why is there a need for emacs to be "superior" to other languages?
tux68 · 2022-08-07 21:18
Thank you. I hate it.
georgehank2nd · 2022-08-07 22:02
Ah, yes, PEMDAS. And then Americans (USians) wonder why their country is bad at math…
janoc · 2022-08-07 22:08
Not sure what does order of mathematical operations have to do with assumed or actual math competence ... Dumb stereotyping much?
holgerschurig · 2022-08-07 22:22
Not sure either. On the other side, US programmers all the time invent their own systems instead of using defined standards. Just today I saw a game that used "mkph". No, it was not kilopondhours, they wanted to describe Mm/h, megameters per hour (similar to km/h, but shifted by a magnitude of 3). No idea why they wanted to use such a thing i the first place, but they were too ... stupid? ... to know that M is 10^6, and that / is used for "per"? I guess due to all 9f the imperial units they still use, they put more emphasis on the various "we need to fet it right" factors for physics calculations, instead 9fvfocusing on correct unit prefixes and unit usage. Learning to deal with the oddities of non-SI takes time, and distracts you perhaps so much, that you might lack actual math competency. So yes, when you invent your own system, even when you document it, others will STILL be confused. You may shrug that away: "The others should learn your system!!!" I would go even do far that US companies are loosing contracts from abroad because of inches and other outdated units. Un manuals, parts, tools. Which complicates spare part sourcing, for example. It increases total cost of ownership ... so the machine from Germany, Korea, Switzerland etc will be bought instead.
lcvas · 2022-08-07 22:45
>Learning to deal with the oddities of non-SI takes time, and distracts you perhaps so much, that you might lack actual math competency. To assume one would be so deeply troubled by learning a few units raises questions on nothing but your own cognition. Begone with your blind hatred toward anything that you didn't grow up using, and go learn how to convert units in calc. I too am from a SI country, that doesn't mean I deserve to live in a monocultural world, with a culture that happens to be mine.
lebensterben · 2022-08-07 23:58
I don't get why people like infix notation anyway. As an Elisp programmer I mostly use Polish notation. So `a / b * c` is `* / a b c` or in Elisp, `(* (/ a b) c)`. Or using the more mathematical reverse Polish notation, `a b / c *`. Either notation isn't ambiguous.
Targuinia · 2022-08-08 00:15
Also the variable `calc-multiplication-has-precedence` can be set to `nil` to use the more common order of operations instead (division and multiplication have the same precedence)
mpersico · 2022-08-08 01:57
* and / are equals. Strict left to right evaluation is how I learned in the United States.
janoc · 2022-08-08 08:13
Nice! Thanks for digging that out!
janoc · 2022-08-08 08:33
Sorry but most calculators don't allow to "paste a formula from paper". Nor would a verbatim copying make sense in most cases, given that the formulas often use various implicit simplifications and notations (e.g. omitting limits on sums or integrals). And also, one would assume that the person trying to use that formula understands what they are doing and what their calculator does - operator priority is in every calculator's handbook. The calculator is not "wrong". Wrong is the operator who assumes that there is a single unique way to express mathematical expressions and that everyone agrees on it. Which is not the case.
billsb · 2022-08-08 10:17
Wow TIL!
[deleted] · 2022-08-08 10:54
[deleted]
remillard · 2022-08-08 13:47
Obligatory "Dammit, Emacs." :D (Your comment reminded me of the old xkcd favorite of someone chiming in at the end of a long discussion and "Of course there's a way".)